- Apply your knowledge of ruby to solve a real world problem.
- Get really good at array manipulation.
Create a program that models a subway system.
The program takes the line and stop that a user is getting on at and the line and stop that user is getting off at and prints the journey and the total number of stops for the trip in the console:
There are 3 subway lines:
Red line
- South Station
- Park Street
- Kendall
- Central
- Harvard
- Porter
- Davis
- Alewife
Green line
- Government Center
- Park Street
- Boylston
- Arlington
- Copley
- Hynes
- Kenmore
Orange line
- North Station
- Haymarket
- Park Street
- State
- Downtown Crossing
- Chinatown
- Back Bay
- Forest Hills
All 3 subway lines intersect at Park Street, but there are no other intersection points.
Tell the user the number of stops between stations.
stops_between_stations('Red', 'Alewife', 'Red', 'Alewife') # 0
stops_between_stations('Red', 'Alewife', 'Red', 'South Station') # 7
stops_between_stations('Red', 'South Station', 'Green', 'Kenmore') # 6
Tell the user the number of stops between stations AND the stops IN ORDER that they will pass through or change at.
stops_between_stations('Red', 'South Station', 'Green', 'Kenmore')
# "You must travel through the following stops on the Red line:"
# "South Station and Park Street"
# "Change at Park Street."
# "Your trip continues through the following stops on Green Line:"
# "Boylston, Arlington, Copley, Hines, and Kenmore."
# "7 stops in total."
Use get
to allow the user to input their start line, start station, end line, and end station.
Your opinion for this homework is very important! Please fill up the following questions when you pull request:
- on a scale from 1 to 5, how comfortable were you with this assignment?
- How long did it take?
- What was a challenge you had with this assignment?
- Is there anything that you'd like some further information on?
- Do you have any suggestions to improve this assignment?