Write a program which controls a metro train and that keeps track of stations and who gets on and off.  write a short description of how the code is designed.   Design and implement a class called train, which has at least the following:   At least the following attributes (you can include others):   metroID stationNum which keeps track of the station that the train is at. iii. direction which keeps track of the direction the train is travelling in. passTotal which keeps track of the number of passengers currently on the train. A default constructor which sets the metroID to a random number between 1 and 1000, the station number to 0, the direction (int), and the passTotal to 0 (train is empty). A constructor with one parameter; the parameter is the metro id. The constructor assigns the passed integer to the metroID attribute; the rest of the attributes are set as described in the default constructor. Accessor methods for each attributes. Mutator methods for each attributes. nextStation(int lastStation) which determines the next station the train is to go to, and changes the direction of the train when necessary. This method should return a integer value which will specify the action that needs to be done: passengers leaving, passengers boarding or passengers getting off and boarding A string representation method (str) will return in a string the metroID, the current station number, the direction the train is travelling in as well as the number of passengers on the train.     Using all of these methods may not be necessary in your design but they must be present either way (can also be used to add something interesting).       Your program driver should:   - Display a welcome message - Ask the user for the number of metro stations. There should be at least 3 stations. Make sure the user enters a number ≥ 3, if not keep asking until they enter at least 3. You may as well ask the user for input to name the stations. - Create a Train object using the default constructor. - As long as the user wants:   Advance the train to the next station. At each station, using a random number generate the number of people who will disembark the train (where applicable), and the number of people who have arrived wishing to embark on the train (where applicable). Rules:   - If the metro train is at the 1st station in any given direction, there will only be people waiting to get on as the train is empty. - If the metro train is at the last station, all passengers must get off and no one can get on until the train turns around. - Any other station, there are people waiting to get on (a max of 300), and some people will get off the train (can’t have more people getting off than there are people on the train). -The metro train can hold a maximum of 250 people at any given time - If the number of places available on the train, after people leave is less than the number of people waiting to get on, some people will be left waiting on the platform for the next train.   Keep track of the number of people who did not get on the train, as they will try and embark on the next train.   Display the Train ID, the station that the train is leaving and the number of passengers. As well:   -indicate the number of people who got off the train -the number of people who were left behind at this station the last time and are hoping to embark the train this time -the new people who arrived on the platform -the number of people who actually got on the train -the number who are left behind on the platform because the train was full this time.   Include the train id, the station number and the direction the train is travelling in (info that is displayed when output a train object).   Ask the user if they would like to continue following the metro - If yes, continue to next station and repeat the process - If no, quit and end the program with a closing message.     The metro train travels from one end of the line to the other. When it reaches the end in either direction, all passengers must get off. The train turns around and starts again with an empty train from the same station heading in the opposite direction. part of sample output attached in images

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Write a program which controls a metro train and that keeps track of stations and who gets on and off.  write a short description of how the code is designed.

 

Design and implement a class called train, which has at least the following:

 

  1. At least the following attributes (you can include others):

 

  1. metroID
  2. stationNum which keeps track of the station that the train is at.

iii. direction which keeps track of the direction the train is travelling in.

  1. passTotal which keeps track of the number of passengers currently on the train.
  2. A default constructor which sets the metroID to a random number between 1 and 1000, the station number to 0, the direction (int), and the passTotal to 0 (train is empty).
  3. A constructor with one parameter; the parameter is the metro id. The constructor assigns the passed integer to the metroID attribute; the rest of the attributes are set as described in the default constructor.
  4. Accessor methods for each attributes.
  5. Mutator methods for each attributes.
  6. nextStation(int lastStation) which determines the next station the train is to go to, and changes the direction of the train when necessary. This method should return a integer value which will specify the action that needs to be done: passengers leaving, passengers boarding or passengers getting off and boarding
  7. A string representation method (str) will return in a string the metroID, the current station number, the direction the train is travelling in as well as the number of passengers on the train.

 

 

Using all of these methods may not be necessary in your design but they must be present either way (can also be used to add something interesting).

 

 

 

Your program driver should:

 

- Display a welcome message

- Ask the user for the number of metro stations. There should be at least 3 stations. Make sure the user enters a number ≥ 3, if not keep asking until they enter at least 3. You may as well ask the user for input to name the stations.

- Create a Train object using the default constructor.

- As long as the user wants:

 

  1. Advance the train to the next station. At each station, using a random number generate the number of people who will disembark the train (where applicable), and the number of people who have arrived wishing to embark on the train (where applicable). Rules:

 

- If the metro train is at the 1st station in any given direction, there will only be people waiting to get on as the train is empty.

- If the metro train is at the last station, all passengers must get off and no one can get on until the train turns around.

- Any other station, there are people waiting to get on (a max of 300), and some people will get off the train (can’t have more people getting off than there are people on the train).

-The metro train can hold a maximum of 250 people at any given time

- If the number of places available on the train, after people leave is less than the number of people waiting to get on, some people will be left waiting on the platform for the next train.

 

  1. Keep track of the number of people who did not get on the train, as they will try and embark on the next train.

 

  1. Display the Train ID, the station that the train is leaving and the number of passengers. As well:

 

-indicate the number of people who got off the train

-the number of people who were left behind at this station the last time and are hoping to embark the train this time

-the new people who arrived on the platform

-the number of people who actually got on the train

-the number who are left behind on the platform because the train was full this time.

 

Include the train id, the station number and the direction the train is travelling in (info that is displayed when output a train object).

 

  1. Ask the user if they would like to continue following the metro

- If yes, continue to next station and repeat the process

- If no, quit and end the program with a closing message.

 

 

The metro train travels from one end of the line to the other. When it reaches the end in either direction, all passengers must get off. The train turns around and starts again with an empty train from the same station heading in the opposite direction.

part of sample output attached in images

A Output Example.pdf - Adobe Acrobat Reader DC (32-bit)
File Edit View Sign Window Help
Home
Tools
Output Example.pdf x
Sign In
1 /5
116%
Do you want to continue following Metro train 411?
Type "y" or "Y" for yes, anything else for no: y
Search 'Header
LO Export PDF
All out
Metro 411 leaving station 3 east bound with o passenger (s).
Adobe Export PDF
Passenger (s) got off:97
Passenger(s) new passengers waiting to board: 0
Passenger (s) got on: 0
Passenger(s) left behind waiting for next train: 0
Convert PDF Files to Word
or Excel Online
Select PDF File
Output Example.pdf
Do you want to continue following Metro train 411?
Type "y" or "Y" for yes, anything else for no: y
Convert to
Microsoft Word (*.docx)
Only in
(New Passengers waiting 25)
(Passengers Left from last time 0)
Document Language:
English (U.S.) Change
Metro 411 leaving station 3 west bound with 25 passenger(s).
Passenger(s) got off:0
Convert, edit and e-sign PDF
forms & agreements
Free 7-Day Trial
2:33 PM
P Type here to search
(?
O G 4))
video
3/21/2021
Transcribed Image Text:A Output Example.pdf - Adobe Acrobat Reader DC (32-bit) File Edit View Sign Window Help Home Tools Output Example.pdf x Sign In 1 /5 116% Do you want to continue following Metro train 411? Type "y" or "Y" for yes, anything else for no: y Search 'Header LO Export PDF All out Metro 411 leaving station 3 east bound with o passenger (s). Adobe Export PDF Passenger (s) got off:97 Passenger(s) new passengers waiting to board: 0 Passenger (s) got on: 0 Passenger(s) left behind waiting for next train: 0 Convert PDF Files to Word or Excel Online Select PDF File Output Example.pdf Do you want to continue following Metro train 411? Type "y" or "Y" for yes, anything else for no: y Convert to Microsoft Word (*.docx) Only in (New Passengers waiting 25) (Passengers Left from last time 0) Document Language: English (U.S.) Change Metro 411 leaving station 3 west bound with 25 passenger(s). Passenger(s) got off:0 Convert, edit and e-sign PDF forms & agreements Free 7-Day Trial 2:33 PM P Type here to search (? O G 4)) video 3/21/2021
A Output Example.pdf - Adobe Acrobat Reader DC (32-bit)
File Edit View Sign Window Help
Home
Tools
Output Example.pdf x
Sign In
2 / 5
116%
Search 'Header
Passenger (s) new passengers waiting to board: 25
Passenger(s) got on: 25
Passenger(s) left behind waiting for next train: 0
LO Export PDF
Do you want to continue following Metro train 411?
Type "y" or "Y" for yes, anything else for no: y
Adobe Export PDF
Convert PDF Files to Word
or Excel Online
In the middle
(Passengers Left from last time 0)
Select PDF File
Output Example.pdf
Metro 411 leaving station 2 west bound with 87 passenger(s).
Passenger (s) got off:15
Passenger(s) new passengers waiting to board: 77
Passenger(s) got on: 77
Passenger(s) left behind waiting for next train: 0
Convert to
Microsoft Word (*.docx)
Document Language:
Do you want to continue following Metro train 411?
Type "y" or "Y" for yes, anything else for no: y
English (U.S.) Change
All out
Metro 411 leaving station 1 west bound with e passenger (s).
Convert, edit and e-sign PDF
forms & agreements
Passenger(s) got off:87
Passenger (s) new passengers waiting to board: 0
Passenger (s) got on: 0
Passenger (s) left behind waiting for next train: 0
Free 7-Day Trial
2:33 PM
P Type here to search
(?
O G 4))
video
3/21/2021
Transcribed Image Text:A Output Example.pdf - Adobe Acrobat Reader DC (32-bit) File Edit View Sign Window Help Home Tools Output Example.pdf x Sign In 2 / 5 116% Search 'Header Passenger (s) new passengers waiting to board: 25 Passenger(s) got on: 25 Passenger(s) left behind waiting for next train: 0 LO Export PDF Do you want to continue following Metro train 411? Type "y" or "Y" for yes, anything else for no: y Adobe Export PDF Convert PDF Files to Word or Excel Online In the middle (Passengers Left from last time 0) Select PDF File Output Example.pdf Metro 411 leaving station 2 west bound with 87 passenger(s). Passenger (s) got off:15 Passenger(s) new passengers waiting to board: 77 Passenger(s) got on: 77 Passenger(s) left behind waiting for next train: 0 Convert to Microsoft Word (*.docx) Document Language: Do you want to continue following Metro train 411? Type "y" or "Y" for yes, anything else for no: y English (U.S.) Change All out Metro 411 leaving station 1 west bound with e passenger (s). Convert, edit and e-sign PDF forms & agreements Passenger(s) got off:87 Passenger (s) new passengers waiting to board: 0 Passenger (s) got on: 0 Passenger (s) left behind waiting for next train: 0 Free 7-Day Trial 2:33 PM P Type here to search (? O G 4)) video 3/21/2021
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY