Question
For this first assignment, you will create a TransitManager, which could be used to keep track of information relating to a public transit system of
For this first assignment, you will create a TransitManager, which could be used to keep track of information relating to a public transit system of a small city.
In this city, there are two kinds of public transportation: buses and the metro. You will define this transit system by creating exactly six classes: Bus, BusRoute, BusStop, Train, MetroRoute, MetroStation. You may not create any additional classes beyond these six.
Create an Eclipse project named [id]_TransitManager. You should place it in the /Assignments/Assignment1 folder of your git repository. Then create a package named transit_manager. All classes for this project should be placed in this package.
So, all class files we create for this Assignment must end up in the folder: /Assignments/Assignment1/src/transit_manager
Methods are explained in the first picture.
Can you give me java codes for this assignment( for all 6 classes)?
\begin{tabular}{|l|} \hline \multicolumn{1}{|c|}{ Bus } \\ \hline \begin{tabular}{l} busldentifier: String \\ driverName: String \\ capacity: int \\ passengers: int \\ speed: double \\ route: BusRoute \\ currentStop: BusStop \\ \hline + thankTheDriver(): void \\ + letPassengersOff(): int \\ + letPassengersOn(): int \\ + moveToNextStop(): double \\ + toString(): String \end{tabular} \\ \hline \end{tabular} \begin{tabular}{|l|} \hline \multicolumn{1}{|c|}{ Train } \\ \hline trainldentifier: String \\ conductorName: String \\ cars: int \\ passengers: int \\ speed: double \\ route: MetroRoute \\ currentStation: MetroStation \\ \hline + thankTheConductor(): void \\ + calculateCapacity(): int \\ + letPassengersOff(): int \\ + letPassengersOn(): int \\ + moveToNextStation(): double \\ + toString(): String \\ \hline \end{tabular} \begin{tabular}{|l|} \hline \multicolumn{1}{|c|}{ BusRoute } \\ \hline routeNumber: int \\ routeDescription: String \\ firstStop: BusStop \\ lastStop: BusStop \\ + calculateDistance(): double \\ + toString(): String \\ \hline \end{tabular} \begin{tabular}{|l|} \hline \multicolumn{1}{|c|}{ MetroRoute } \\ \hline routeNumber: int \\ routeDescription: String \\ firstStop: MetroStation \\ lastStop: MetroStation \\ \hline+ calculateDistance () : double \\ + toString(): String \\ \hline \end{tabular} \begin{tabular}{|l|} \hline \multicolumn{1}{|c|}{ BusStop } \\ \hline stopName:StringstopNumber:intxCoordinate:doubleyCoordinate:doublepassengersWaiting:int \\ + gainPassengers(): void \\ + losePassengers(numPassengers: int): boolean \\ + distance(other: BusStop): double \\ + toString(): String \\ \hline \end{tabular} \begin{tabular}{|l|} \hline \multicolumn{1}{|c|}{ MetroStation } \\ \hline stationName:StringstationNumber:intxCoordinate:doubleyCoordinate:doublepassengersWaiting:int \\ + gainPassengers(): void \\ + losePassengers(numPassengers: int): boolean \\ + distance(other: MetroStation): double \\ + toString(): String \\ \hline \end{tabular} Bus: - thankTheDriver (1 pt): Print a String to console that thanks the bus driver for their hard work - letPassengersOff ( 2 pts): Lets all of the passengers off the bus. Returns the number of passengers who got off the bus (should be all of them!) - letPassengersOn (2 pts): Lets as many passengers at current stop onto the bus that can fit on it without going over capacity. This should alter the currentStop object to reflect that waiting passengers have got on the bus. Returns the number of passengers who got on the bus. - moveToNextStop (2 pts): Moves this bus from its current stop to the other stop in its bus route (all bus routes have only two stops!). Uses the speed (in miles per hour) and the distance between the stops to calculate the time it took (in minutes) to travel. It returns this time as a double. - toString (2 pts): Returns a String representation of this object's state. Should at least include the busIdentifier, driverName, routeNumber of the route it's traveling on, current stop name, number of passengers, and capacity of the bus. BusRoute: - calculateDistance (2 pts): Calculates the distance between the first and last stops in the route (these are the only two stops in the route!) in miles. Returns this as a double. - toString (1 pts): Returns a String representation of this object's state. Should at least include the routeNumber and routeDescription BusStop: - gainPassengers (2 pts): Generates a random integer between 5 and 30 and adds this to the passengers waiting. This represents new people who have walked to the stop and joined the crowd waiting for a bus. - losePassengers (2 pts): Takes in an integer and removes this amount from passengers waiting, as long as it wouldn't cause passengers waiting to go negative. If the operation would cause passengers waiting to go negative, do not change passengers waiting. Returns true if the operation was successful, returns false if it was not. - distance (8 pts): Takes in another BusStop object, calculates the (Euclidean) distance between the input bus stop and this bus stop, returns that distance in miles. We're assuming the bus travels on a straight path from one stop right to the other, ignoring roads. To do this, you must use the Euclidean distance formula with the x and y coordinates of each stop. Assume x and y coordinates are given in miles from the center of the city. - toString (2 pts): Returns a String representation of this object's state. Should at least include the stopNumber, stopName, and number of passengers waiting. Train: - thankTheConductor (1 pt): Print a String to console that thanks the train conductor for their hard work - calculateCapacity (1 pt): Uses the number of cars on the train to calculate its capacity. As a rule, each train car can hold 120 people. - letPassengersOff ( 2 pts): Lets all of the passengers off the train. Returns the number of passengers who got off the train (should be all of them!) - letPassengersOn (2 pts): Lets as many passengers at the current station onto the train that can fit on it without going over capacity (you'll have to calculate this capacity...). This should alter the currentStation object to reflect that waiting passengers have got on the train. Returns the number of passengers who got on the train. - moveToNextStation (2 pts): Moves this train from its current station to the other station in its route (all metro routes have only two stops!). Uses the speed (in miles per hour) and the distance between the stops to calculate the time it took (in minutes) to travel. It returns this time as a double. - toString (2 pts): Returns a String representation of this object's state. Should at least include the trainIdentifier, name of the conductor, route number it's traveling on, station name where it's currently stopped, number of passengers, and capacity. MetroRoute: - calculateDistance (2 pts): Calculates the distance between the first and last stations in the route (these are the only two stations in the route!) in miles. Returns this as a double. - toString (1 pts): Returns a String representation of this object's state. Should at least include the routeNumber and routeDescription. MetroStation: - gainPassengers (2 pts): Generates a random integer between 20 and 200 and adds this to the passengers waiting. This represents new people who have walked to the station and joined the crowd waiting for a train. - losePassengers (2 pts): Takes in an integer and removes this amount from passengers waiting, as long as it wouldn't cause passengers waiting to go negative. If the operation would cause passengers waiting to go negative, do not change passengers waiting. Returns true if the operation was successful, returns false if it was not. - distance (8 pts): Takes in another MetroStation object, calculates the (Euclidean) distance between the input metro station and this station, returns that distance in miles. We're assuming the train travels on a straight path from one station right to the other. To do this, you must use the Euclidean distance formula with the x and y coordinates of each station. Assume x and y coordinates are given in miles from the center of the city. - toString (2 pts): Returns a String representation of this object's state. Should at least include the stationNumber, stationName, and passengers waiting at this station. 3. Add getters and setters for all properties in all classes ( 6pts). Getters and setters are not included in the diagram and they are assumed. Use your best judgment as to which fields should get getters or setters and which should not. As a bare minimum, your code must include the getters and setters called by the sample runner ("TransitManagerRunner.java") included on Canvas. 3 4. Add constructors for each of your six classes (6 pts). Similarly, you should use your best judgment as to what kind of constructors should be created. As a bare minimum, your code must include the constructors called by the sample runner ("TransitManagerRunner.java") included on Canvas. 5. Make sure your code follows our class style guide (see Canvas). You are required to follow all guidelines added to the style guide by the time this assignment was posted, else you lose up to 10% of your grade. Testing Your Code On canvas, you will be provided with a sample runner to test your code (named "TransitManagerRunner.java", it's in modules right below Assignment 1). You are encouraged to copy this file into your project and use it to test whether you have implemented these classes correctly. Sample output is also provided on Canvas. Grading Point values for correct implementation of each method, getters/setters, and constructors are listed above. This totals to 75 points. See our syllabus for grade restrictions if your code does not compile or encounters runtime errors with the provided test runner. Submission You should submit your project via the GitHub repository we configured for you. If you expect your code does not complete all requirements of the assignment, please write a summary of this code behavior in the README.md file (/Assignments/Assignment1/README.md). This will make our course grader's life a little easierStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started