-
Notifications
You must be signed in to change notification settings - Fork 0
/
Time.cs
58 lines (53 loc) · 1.47 KB
/
Time.cs
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
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Time;
class Time {
private int hour;
private int minute;
private int second;
private bool RightHour(int hour)
{
return hour >= 0 && hour <=23;
}
private bool RightMinute(int minute)
{
return minute >= 0 && minute <= 59;
}
private bool RightSecond(int second)
{
return second >= 0 && second <= 59;
}
public Time(int hour, int minute, int second) {
this.hour = hour;
this.minute = minute;
this.second = second;
}
public int GetHour() {return hour;}
public int GetMinute() { return minute;}
public int GetSecond() { return second;}
public void SetHour(int hour) { this.hour = hour;}
public void SetMinute(int minute) { this.minute = minute;}
public void SetSecond(int second) { this.second = second;}
public void setTime(int hour,int minute, int second) {}
public string toString() {
return ($"{hour:D2}:{minute:D2}:{second:D2}");
}
/*public Time nextSecond() {
return (hour,minute,second + 1);
}
public Time previousMinute() {
return (hour, minute,second - 1);
}
*/
}
class TestTime {
public static void Mainx()
{
Time t1 = new Time(20,20,20);
Console.WriteLine(t1.toString());
}
}