namespace ClassesHomework
public static void Main(string[] args)
Time setTime = new Time();
Console.WriteLine("The time is: " + setTime.Hour + ":" + setTime.Minute + ":" + setTime.Second);
Console.WriteLine("Added two hours to the initial time: " + setTime.Hour + ":" +
setTime.Minute + ":" + setTime.Second);
Console.WriteLine("Added 5 minutes to the initial time: " + setTime.Hour + ":" +
setTime.Minute + ":" + setTime.Second);
Console.WriteLine("Added 15 seconds to the initial time: " + setTime.Hour + ":" + setTime.Minute + ":" +
output = "The initial time in string format after set time is: " + t.TimeStringFormat();
Console.WriteLine(output);
Time withoutCallingMethods = new Time(15, 47, 32);
withoutCallingMethods.SetTime(15, 47, 32);
output = "String format: " + withoutCallingMethods.TimeStringFormat();
Console.WriteLine(output);
Time now = new Time(DateTime.Now);
Console.WriteLine(now.TimeStringFormat());
Console.WriteLine("{0} --> Past:{1} Present:{2} Future:{3}", now.TimeStringFormat(), now.Past, now.Present, now.Future);
namespace ClassesHomework
public void SetTime(int h, int m, int s)
hour = ((h >= 0 && h < 24) ? h : 0);
minute = ((m >= 0 && m < 60) ? m : 0);
second = ((s >= 0 && s < 60) ? s : 0);
public int AddHour(int h)
public int AddMinute(int m)
public int AddSeconds(int s)
public string TimeStringFormat()
return String.Format("{0:D2}", hour) + ":" + string.Format("{0:D2}", minute) + ":" + string.Format("{0:D2}", second) + " " +
((hour > 12) ? "PM" : "AM");
public Time(int hour, int minute, int second)
Console.WriteLine("Time without calling the methods: " + hour + ":" + minute + ":" + second);
SetTime(dt.Hour, dt.Minute, dt.Second);
DateTime now = DateTime.Now;
return (this.Hour * 3600 + this.Minute * 60 + this.Second < now.Hour * 3600 + now.Minute * 60 + now.Second);
DateTime now = DateTime.Now;
return (this.Hour * 3600 + this.Minute * 60 + this.Second == now.Hour * 3600 + now.Minute * 60 + now.Second);
DateTime now = DateTime.Now;
return (this.Hour * 3600 + this.Minute * 60 + this.Second > now.Hour * 3600 + now.Minute * 60 + now.Second);