Answered step by step
Verified Expert Solution
Link Copied!

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 5: Train Schedule
1 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 2 Objects.
2 User Interface
In this homework, you need to use the user interface client code for working with your
supplier classes.
3 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 1<= N <=100)
c) followed by a series of lines that describe every train. This description contains 3
pieces of information:
a train name - a string with a length of 1 to 50 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 24-hour format as follows HH MM.
The format specifies hours (2 digits) and minutes (2 digits) separated by a space.
The journey time for each of the trains is at least one minute and does not exceed
24 hours. Pay attention to this example, if the train departs at 19:50 and arrives
at 8:30, it means that it arrives the next day and the time of journey is 12 hours
and 40 minutes.
4 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 HW5- Part2.
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
+Time(hour : Integer, minute : Integer)
Accessors
+ getHour() : Integer
+ getMinute() : Integer
Mutators
+setHour(Integer)
+setMinute(Integer)
+timeBetween(Time) : Time
+zeroTime(Integer) : String
+toString() : String
Constructor
+Train(name : String, departure : Time,
arrival: Time, distance : Integer)
Accessors
+getDeparture () : Time
+getArrival () : Time
+getDistance () : Integer
Mutators
+setDeparture(Time)
+setArrival(Time)
+setDistance(Integer)
+averageSpeed() : Integer
+travelTime() : Time
+toString() : String
Hint. The method zeroTime(Integer) uses for formatting the output as follows:
Hour =8, minute =5. Output should be 08:05. Us this format in the toString() method.
5 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 23:55
Arrival 08:15
Travel Time 08:20
Average speed 78 km/h

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David Kroenke

11th Edition

0132302675, 9780132302678

More Books

Students also viewed these Databases questions

Question

Why are ratios and trends used in financial analysis?

Answered: 1 week ago