Coder Social home page Coder Social logo

boatracejms's Introduction

BoatRaceJms

CLI App with Jms API, simulating a boat race.

Concept

The idea of the app is pretty straight forward: we have a boat race. The time left to finish the race for each boat is determined at the beginning randomly.

Once all the boats have a time left of 0 the race is over.

To simulate the time ticking we have a while loop with a sleep between each iteration, in this loop we will update the ranking if necessary.

JMS

A queue and topic between the organizer and each boat.

Queue:

  • Producers: boats
  • Consumer: organizer

Data: all boat ids

The organizer can then display the ranking and send a topic message if a boat has finished the race.


Topic:

  • Producer: organizer
  • Consumers: boats

Data: id of the boat who just finished

When the remaining boats receive the information that a boat has finished the race they'll increase their speed accordingly to their ranks (velocity = velocity + rank). The lower the rank is, the bigger the acceleration is.

Classes

Core

Boat

Class representing a boat in the race.

  • id
  • totalTimeToFinish: time left at the beginning of the race
  • timeLeft: time left to finish after n loop
  • finished: true if finished the race
  • velocity: speed of the boat, represent the amount of seconds retrieved from the timeLeft after each iteration, default: 1
  • race: race object

Organizer

Class representing the organizer of the race. It will simply handle the queue and topic messages, and displaying the current rank of the race.

  • race: race object

Race

Class representing the actual boat race. It will initiate the boats, iterate over the race while loop, and update the ranking. This is also where we will initiate the Jms connection, the queue and the topic. The method timeTicking() will take care of the rank update, boats timeLeft changes and to send the queue messages to the organizer.

  • runners: list of boat objects in the race
  • ranking: list of the boat objects ranked
  • raceFinished: if true program terminate
  • organizer: organizer object
  • rankingQueue: queue object, of the boats who will send their info to the organizer
  • finishedTopic: topic object, of the organizer sending the id of the boat who just finished

JMS

Homemade classes

JmsFactory

Class that will take care of the core operation of the JMS API.


JmsQueue

Class extending the JmsFactory and implements the method necessary to initiate a queue.


JmsTopic

Class extending the JmsFactory and implements the method necessary to initiate a topic.

boatracejms's People

Contributors

plsergent avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.