Professional Documents
Culture Documents
namespace try314
{
internal class Time
{
private int hour;
private int minute;
private int second;
class Program
{
static void Main(string[] args)
{
Time t = new Time(3, 5, 7);
Console.WriteLine(t);
t.previousSecond();
Console.WriteLine(t);
}
}
}
The changes include:
Fixing the conditional statements in the constructor and setters to use && instead
of ||, since the hour, minute, and second values should all be within their
respective ranges.
Changing the toString() method to ToString() with the proper capitalization.
Changing the return types of nextSecond() and previousSecond() to void, since they
modify the object itself rather than returning a new object.
Fixing the logic in the nextSecond() and previousSecond() methods to properly
handle cases where incrementing or decrementing the seconds causes changes to the
minutes or hours as well.
Adding a Console.WriteLine() statement in the Main() method to print the initial
and modified Time objects