Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Code: Write a class called Time that can be used to represent time in hour, minute and second values. The class Time contains the

C++ Code:

Write a class called Time that can be used to represent time in hour, minute and

second values. The class Time contains the following members:

- Three private data members: hour (0-23), minute (0-59) and second (0-59),

with default values of 0.

- A public constructor Time(), which initializes the data members hour, minute

and second with the values provided by the caller (as arguments).

- public getters and setters for private data members: getHour(),getMinute(),

getSecond(),setHour(),setMinute(),and setSecond().

- A public member function setTime() to set the values of hour, minute and

second given by the caller.

- A public member function print() to print this Time instance in the format

"hh:mm:ss", zero-filled, e.g., 01:30:04.

- A public member function nextSecond(), which increase this instance by one

second. nextSecond() of 23:59:59 shall be 00:00:00.

Write a simple tester program to test the Time class.

image text in transcribed

Write a class called Time that can be used to represent time in hour, minute and second values. The class Time contains the following members: - Three private data members: hour (0-23), minute (0-59) and second (0-59), with default values of 0 . - A public constructor Time(), which initializes the data members hour, minute and second with the values provided by the caller (as arguments). - public getters and setters for private data members: getHour(),getMinute(), getSecond(),setHour(), setMinute(), and setSecond(). - A public member function setTime() to set the values of hour, minute and second given by the caller. - A public member function print() to print this Time instance in the format "hh:mm:ss", zero-filled, e.g., 01:30:04. - A public member function nextSecond(), which increase this instance by one second. nextSecond() of 23:59:59 shall be 00:00:00. Write a simple tester program to test the Time class

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 1 Lnai 6321

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

364215879X, 978-3642158797

More Books

Students also viewed these Databases questions

Question

8. Describe how cultural spaces are formed.

Answered: 1 week ago