Assignment Help

Any help with this assignment would be appreciated. Thank you!


For this assignment you are to design and implement a class Time. Objects of this class are intended to represent time values that are viewed as consisting of an hour, minute, and second values. The values associated with a Time object can range between 00:00:00 (midnight) and 23:59:59, inclusively. The public interface for this class should consist of the following sets of functions:

Constructors: Time(): This function defines a default initial value of 00:00:00 for a Time object.
Time(int h, int m, int s): This function initializes a Time object so that its hours is h, its minutes is m, and its seconds is s. The parameters that correspond to the minutes and seconds should be specified with a default value of 0.

Access Functions: int getHours() const; Returns the hours value of a Time object. int getMinutes() const; Returns the minutes value of a Time object. int getSeconds() const; Returns the seconds value of a Time object. bool LessThan(Time); For two Time objects t1 and t2, t1.LessThan(t2) returns true if t1 is less than, or comes before t2. bool GreaterThan(Time); For two Time objects t1 and t2, t1.GreaterThan(t2) returns true if t1 is greater than, or comes after t2. bool EqualTo(Time); For two Time objects t1 and t2, t1.EqualTo(t2) returns true if t1 is equal to, or is the same time as t2.
Modifier Functions: void setHours(int h); Set the hours of Time object to value specified by h. void setMinutes(int m); Set the minutes of Time object to value specified bym. void setSeconds(int s); Set the seconds of Time object to value specified by s. void setTime(int h, int m, int s); Set the hours, minutes and seconds of a Time object to the values specified by h, m and s, respectively. The parameters corresponding to the minutes and seconds value should have default values of 0.

Input/Output Functions: void Read(); t1.Read(); accepts from the keyboard a time value for t1 that is input in the form hh:mm:ss. void write(); t1.Write(); outputs to the display the value of t1 in the format hh:mm:ss.
Using the Time class you are to implement a well-designed program that can be used for sorting a sequence of up to 100 Time object values. The program should be begin by asking the user to specify the number of values to be sorted. Once a valid value, say n, has been input, the program should then prompt the user to enter n time values. Once all n values have been entered, the program should sort them in ascending order and then output them, one per line.
I may also provide you with a main() function to be used to test your Time class implementation. The only header files that you may use for this assignment are iostream, and iomanip, which can be used for formatting data if you are familiar with it.


Due Date: December 5, 2019
So what have you tried?

A very useful technique is to copy the assignment text into a source file, turn it into comments and start filling in the code. This way its unlikely that you'll miss something. Here is your assignment transcribed into comments (and slightly rearranged). with methods of class Time as specified

You can store the time with h, m, and s members of class Time. Note that it's normally easier to store it with a single number representing the elapsed time since midnight. That makes arithmetic easier. But since there is no time arithmetic in this program, storing hours, minutes and seconds is fine.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// The only header files that you may use for this assignment are
// iostream, and iomanip, which can be used for formatting data if you
// are familiar with it.
#include <iostream>
#include <iomanip>


// For this assignment you are to design and implement a class
// Time. Objects of this class are intended to represent time values
// that are viewed as consisting of an hour, minute, and second
// values. The values associated with a Time object can range between
// 00:00:00 (midnight) and 23:59:59, inclusively.
class Time {
    
    // The public interface for this class should consist of the
    // following sets of functions:
public:
    
    // Constructors:

    // Time(): This function defines a default initial value of
    // 00:00:00 for a Time object.
    Time();

    // Time(int h, int m, int s): This function initializes a Time
    // object so that its hours is h, its minutes is m, and its
    // seconds is s. The parameters that correspond to the minutes and
    // seconds should be specified with a default value of 0.
    Time(int h, int m, int s);

    // Access Functions:

    // Returns the hours value of a Time object.
    int getHours() const;

    // Returns the minutes value of a Time object.
    int getMinutes() const;

    // Returns the seconds value of a Time object.
    int getSeconds() const;

    // For two Time objects t1 and t2, t1.LessThan(t2) returns true if
    // t1 is less than, or comes before t2.
    bool LessThan(Time);

    // For two Time objects t1 and t2, t1.GreaterThan(t2) returns true
    // if t1 is greater than, or comes after t2.
    bool GreaterThan(Time);

    // For two Time objects t1 and t2, t1.EqualTo(t2) returns true if
    // t1 is equal to, or is the same time as t2.
    bool EqualTo(Time);

    
    // Modifier Functions:

    // Set the hours of Time object to value specified by h.
    void setHours(int h);

    // Set the minutes of Time object to value specified bym.
    void setMinutes(int m);

    // Set the seconds of Time object to value specified by s.
    void setSeconds(int s);

    // Set the hours, minutes and seconds of a Time object to the
    // values specified by h, m and s, respectively. The parameters
    // corresponding to the minutes and seconds value should have
    // default values of 0.
    void setTime(int h, int m, int s);

    // Input/Output Functions:

    // t1.Read(); accepts from the keyboard a time value for t1 that
    // is input in the form hh:mm:ss.
    void Read();

    // t1.Write(); outputs to the display the value of t1 in the
    // format hh:mm:ss.
    void write();
};

int main()
{
    // Using the Time class you are to implement a well-designed
    // program that can be used for sorting a sequence of up to 100
    // Time object values.

    // The program should be begin by asking the user to specify the
    // number of values to be sorted.

    // Once a valid value, say n, has been input, the program should
    // then prompt the user to enter n time values.

    // Once all n values have been entered, the program should sort
    // them in ascending order

    // and then output them, one per line.
}
    
    // I may also provide you with a main() function to be used to
    // test your Time class implementation.  

Topic archived. No new replies allowed.