Question: Define a time class named HoursMinutes that will encapsulate time calculations. Store the time in a single private data member named totalMinutes. The class should

 Define a time class named HoursMinutes that will encapsulate time calculations.

Define a time class named HoursMinutes that will encapsulate time calculations. Store the time in a single private data member named totalMinutes. The class should provide the following methods: 1. a Constructor that takes two integer parameters named h and m that represent the desired hours and minutes. The minutes pa rameter does not need to be restricted to 60" A time of two hours can be constructed as HoursMinutes (2, 0) or HoursMinutes(0, 120). Keep this in mind when writing the add method 2. a getHours method returning an integer that is the whole number of hours 3. a getMinutes method returning an integer that is the number of minutes remaining after the whole number of hours Example: if time t is constructed as HoursMinutes (1, 20) then the totalMinutes data member would store 80, t.getHours() would return 1 and t.getMinutes() would return 20 4. a printHoursMinutes method that prints the time. For the time t described above, it would print 1 h 20 m 5. an addHoursMinutes method that takes an HoursMinutes object as a parameter and adds it to the calling object time, returning a new HoursMinutes object that is the sum of the two times 6. a scaleHoursMinutes method that takes an integer as a parameter and multiplies the calling object time by the integer, returning a new HoursMinutes object that is the scaled time Write a main function that creates two time objects, prints them then adds the two times and prints the result. Also, use the scaling method to double the first time and triple the second time and print the results For this assignment you do not need to separate the class definition and implementation into separate parts of the program or separate files. For now, we can restrict things to positive times only. I have provided two sample classes for feet and inches objects. The 2d program uses some advanced features we will learn later, but if you have some programming experience, you can try adding them to your code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!