Projekt

Obecné

Profil

Stáhnout (1.5 KB) Statistiky
| Větev: | Tag: | Revize:
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using System.Xml.Serialization;
7

    
8
namespace ServerApp.Connection.XMLProtocolHandler
9
{
10
    public class Date : IComparable<Date>
11
    {
12
        [XmlIgnore]
13
        public static int MIN_HOUR = 7;
14
        [XmlIgnore]
15
        public static int MAX_HOUR = 18;
16

    
17
        [XmlElement]
18
        public int day;
19

    
20
        [XmlElement]
21
        public int month;
22

    
23
        [XmlElement]
24
        public int year;
25

    
26
        [XmlElement]
27
        public int hour;
28

    
29
        public static Date Randomize()
30
        {
31
            Date d = new Date();
32

    
33
            d.day = DateTime.Now.Day;
34
            d.month = DateTime.Now.Month;
35
            d.year = DateTime.Now.Year;
36
            d.hour = new Random().Next(7, 18);
37

    
38
            return d;
39
        }
40

    
41
        public Date Clone()
42
        {
43
            Date clone = new Date();
44
            clone.day = day;
45
            clone.month = month;
46
            clone.year = year;
47
            clone.hour = hour;
48
            return clone;
49
        }
50

    
51
        public int CompareTo(Date other)
52
        {
53
            if (year < other.year) return -1;
54
            if (year > other.year) return 1;
55

    
56
            if (month < other.month) return -1;
57
            if (month > other.month) return 1;
58

    
59
            if (day < other.day) return -1;
60
            if (day > other.day) return 1;
61

    
62
            if (hour < other.hour) return -1;
63
            if (hour > other.hour) return 1;
64

    
65
            return 0;
66
        }
67
    }
68
}
(2-2/7)