Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Homework 5 : Train Schedule 1 Objective Between the two largest cities of Russia, St . Petersburg and Moscow make daily trips of N trains.
Homework : Train Schedule
Objective
Between the two largest cities of Russia, St Petersburg and Moscow make daily trips of
N trains. For each train, it is known its departure time from St Petersburg and the time
of arrival in Moscow. You need to find the fastest train and its speed. It is guaranteed
that the fastest train is determined uniquely.
In this project you need to create Objects.
User Interface
In this homework, you need to use the user interface client code for working with your
supplier classes.
Input Data Files and storage
The text file INPUT.TXT has this format:
a start with one integer on its own line represents the distance between two cities
b next line one integer the number of trains in the everyday schedule N
c followed by a series of lines that describe every train. This description contains
pieces of information:
a train name a string with a length of to characters. It can contain letters
of the English alphabet, spaces, numbers, and dashes Lowercase and
uppercase letters in the names of trains vary.
time of departure and arrival is indicated in a hour format as follows HH MM
The format specifies hours digits and minutes digits separated by a space.
The journey time for each of the trains is at least one minute and does not exceed
hours. Pay attention to this example, if the train departs at : and arrives
at : it means that it arrives the next day and the time of journey is hours
and minutes.
Code Specification
Implement the class specifications below. To get full credit, your program's public
interface must match these descriptions exactly.
In this project use only one train from the file, the whole file you will need to use in
the HW Part
Objects Youll Create
Here are UML Class Diagrams for the objects you are to create. Pay attention to the diagram
notation indicating whether methods are public or private ; ask questions if you need
clarification. Understanding the model is of critical importance here.
Class: Time Class: Train
Properties
you figure out the private data needed
Properties
you figure out the private data needed
Constructor
Timehour : Integer, minute : Integer
Accessors
getHour : Integer
getMinute : Integer
Mutators
setHourInteger
setMinuteInteger
timeBetweenTime : Time
zeroTimeInteger : String
toString : String
Constructor
Trainname : String, departure : Time,
arrival: Time, distance : Integer
Accessors
getDeparture : Time
getArrival : Time
getDistance : Integer
Mutators
setDepartureTime
setArrivalTime
setDistanceInteger
averageSpeed : Integer
travelTime : Time
toString : String
Hint. The method zeroTimeInteger uses for formatting the output as follows:
Hour minute Output should be : Us this format in the toString method.
Output
Speed output in kilometers per hour and round to the nearest whole by mathematical
rules. Follow the output format shown in the examples.
Example of output:
Night Express
Departure :
Arrival :
Travel Time :
Average speed kmh
Step 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