Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

time.h : #include using namespace std; class Time { protected:// int hour; int min; int sec; public: // Default constructor Time() { hour = 0;

image text in transcribed

time.h :

#include using namespace std;

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; } }; class MilTime : public Time { protected: int milHours; int milSeconds; public: MilTime(int h = 0, int s = 0) : Time() { if (h = 0 && s = 0) setTime(h, s); else cout = 0 && milS = 0) { milHours = milH; milSeconds = milS; sec = milSeconds; min = milHours % 100; if (milHours > 1259) hour = (milHours - 1200) / 100; else hour = milHours / 100; } else cout = 0 && startTime = 0 && startTime = 0 && startTime = 0 && endTime

int main() { TimeClock TC; TC.setStartTime(2200); TC.setEndTime(2300); cout

TimeClock TC2(900, 1330); cout

cout

cout

return 0; }

//MilTime.cpp

#include "MilTime.h"

using namespace std;

MilTime::MilTime() { hour = 0; sec = 0; min = 0; milHours = 0; milSeconds = 0; } MilTime::~MilTime() {

}

void MilTime::setTime(int mh, int ms) { milHours = mh; milSeconds = ms; hour = mh % 100; min = mh / 100; sec = ms; }

string MilTime::getStandHr() const { return to_string(milHours / 100) + ":" + to_string(milHours % 100) + ":" + to_string(milSeconds); }

_________________________

Source:

#include #include "MilTime.h" using namespace std;

int main() { int h, s;

do { cout > h; if (h2359) cout 2359); do { cout > s; if (s59) cout 59);

MilTime mt;

return 0; }

MilTime.h;

--------------------------------------------------------

MilTime.h:

#ifndef MILTIME_H #define MILTIME_H

#include "Time.h" #include

class MilTime : public Time { public: MilTime(); ~MilTime(); void setTime(int, int); string getStandHr() const; int getHour() const { return milHours; }//get hours

private: int milHours; int milSeconds; };

#endif

// Specification file for the Time class #ifndef 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

Modify the MilTime class you created for Programming Challenge 4 of Chapter 15. The class should implement the following exceptions: BadHour Throw when an invalid hour ( 2359) is passed to the class. Badseconds Throw when an invalid number of seconds ( 59) is passed to the class. Demonstrate the class in a driver program

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

Excel As Your Database

Authors: Paul Cornell

1st Edition

1590597516, 978-1590597514

More Books

Students also viewed these Databases questions

Question

4. What advice would you give to Carol Sullivan-Diaz?

Answered: 1 week ago