Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The file Time.h contains a Time class. Design a class called MilTime that is derived from the Time class. //Time.h #indef TIME_H #define TIME_H class

The file Time.h contains a Time class. Design a class called MilTime that is derived from the Time class.

//Time.h

#indef TIME_H

#define TIME_H

class Time

{

protected:

int hour;

int min;

int sec;

public;

//Default constructor

Time()

{hour = 0; min = 0; sec = 0;}

//Constructor

Time(int h, int m, int s)

{hour=h; min=m, sec=s;}

//Accessor functions

int getHour() const

{return hour;}

int getMin() const

{return min;}

int getSec() const

{return sec;}

};

#endif

The MilTime class should convert time in military (24 hour) format to the standard time format used by the Time class. The class should include the following member variables:

-milHours: Contains the hour in 24-hour format.

-milSeconds: Contains the seconds in standard format.

-Constructor: Should accept arguments for the hour and seconds, in military format. The time should then be converted to standard time and stores in the hours,min, and sec variables of the Time class.

-setTime: Accepts arguments to be stored in the milHours and milSeconds variables. The time should then be converted to standard time and stores in the hours,min, and sec variables of the Time class.

-getHour: Returns the hour in military format.

-getStandHr: Returns the hour in standard format.

Demonstrate the class in a program that asks the user to enter the time in military format. The program should display the time in both military and standard format.

Design a class named TimeClock. This class should be derived from the MilTime class. The class should allow the programmer to pass two times to it: starting time and ending time. The class should have a member function that returns the amount of time elapsed between the two times. Ex: starting time of 900 hours, and ending time of 1300 hours, the elapsed time between the starting and ending time is 4 hours.

For both classes they should not accept hours greater than 2359, or less than 0. It should not accept seconds greater than 59 or less than 0.

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_2

Step: 3

blur-text-image_3

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

MongoDB Applied Design Patterns Practical Use Cases With The Leading NoSQL Database

Authors: Rick Copeland

1st Edition

1449340040, 978-1449340049

More Books

Students also viewed these Databases questions