Task 1
Define a class with name Time for a clock time. This class shall have following members:

· a private integer attribute minuteOfDay storing the minutes from 00:00 o’clock of a day (saving one variable instead of two for hour and minute with a value inbetween 0 and 24*60-1=1439).

· a public overloaded constructor with an unsigned integer parameter and default parameter value 0 to initialise the attribute – calculate modulo midnight=24*60=1440 such that in no case a wrong clock time would be stored.

· a public overloaded constructor with two parameters for the hour and the minute initialising the time by calling following setter member function.

· a public method with name set_time with an hour and a minute as parameters calculating the minutes from 00:00 o’clockand assigning the result to the respective attribute. Check that hour and minute are given correctly otherwise write an error message and assign value 0.

· two public methods with names get_hour and get_minute without parameters calculating the hour resp. the minute and return the result (hint: integer division by 60 with rest).

· a public methods with name get_minuteOfDay without parameter returning the value of the respective attribute.

· a public overloaded member operator +  with an unsigned integer parameter increasing the time by the value of minutes of the parameter. E.g.getting a value of 30 (minutes) the returned time is half an hour ahead, for 90 (minutes) one and a half hour, for 120 (minutes) two hours. Also take care that 30 minutes after 23:45 o’clock it is 00:15 o’clock.
Hint: a clever solution uses one of the constructors and results in a single line of code.

Task 2
Define outside of the class an overloaded input operator >> for a clock time in format hh:mm (the colon you can read as a character and ignore), for example 00:00, 09:08 or 14:20.

Task 3
Furthermore outside of the class an overloaded output operator << for a clock time shall be defined always outputted by five characters in form hh:mm, for example 00:00, 09:08 or 14:20.

Task 4
Define a class with name Train with following members:

· three private attributes with names no (train number), to (destination) and over which other stops all of type C++ string.

· a public prototype for a constructor with three C++ string parameters.

· a public prototype for a destructor.

· three public prototypes for getter functions with names get_no, get_to and get_over without parameters and appropriate return types.

Define outside of the class

· the constructor initialising the three attributes with the three respective parameter values.

· the destructor with an output of the three attribute values as shown in the examples below.

· the three getter member functions.

Task 5

Define a class with name Station with following members:

· a private constant attribute with name station of type C++ string.

· a private constant class attribute with name platforms (number of platforms) of type unsigned integer initialised with 15.

· class Train with names schedule for the departure plan (possible departure of a train at each minute of a day at each platform).

· a public constructor with a C++ string parameter to initialise the constant station name as well as all pointers in the array to a null pointer.

· a public destructor deleting also all objects/trains pointer in the array schedule point to outputting for all also the time and platform together with the train like in the example below as well as the name of the station at its end.

· a public member function with name addDeparture with a time, a platform and a pointer to a train as three parameters scheduling the train into the array at the time and platform given.

· a public member function named showDepartures with a time of class Time and an unsigned integer number for minutes as two parameters printing the departure schedule from given time in first parameter for the following number of minutes given in second parameter like in the example shown below.

Task 6

Write a C++ main function with following definitions and statements:

· Define an object duisburg of class Station for Duisburg main train station.

· As example add into its schedule simplified around the clock each a new train on heap – use a loop:

· at platform 9 every 20 minutes (:07, :27, :47) trains S1 to Dortmund Hbf over Muelheim(Ruhr)Styrum – Muelheim(Ruhr) – Essen.

· at platform 5 every 20 minutes (:15, :35, :55) trains S1 to Solingen Hbf over Duisburg-Schlenk – Duesseldorf Flughafen.

· at platform 2 hourly (:35) trains S2 to Dortmund Hbf over Oberhausen – Gelsenkirchen – Wanne-Eickel.

· at platform 4 hourly (:22) trains RE1 to Aachen Hbf over Duesseldorf Flughafen – Duesseldorf – Koeln.

· at platform 10 hourly (:24) trains RE2 to Muenster Hbf over Muelheim(Ruhr) – Essen – Gelsenkirchen.

· Write a small menue like in the example that you can input further trains and output a schedule from a to input time for the following to input minutes as shown in the example below.

At the end of the program automatically by the called destructors the deletion of all objects of trains as well as object duisburgshall be printed.

在这里你可以获得CS作业代写帮助