-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEdition.cs
74 lines (66 loc) · 2.07 KB
/
Edition.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace OOPLab3Csharp
{
class Edition
{
private string edname;
private DateTime edtime;
int circulation;
public Edition(string EdName, DateTime EdTime, int Circulation)
{
edname = EdName;
edtime = EdTime;
circulation = Circulation;
}
public Edition()
{
edname = "Default Edition Name";
edtime = new DateTime(1111, 1, 11);
circulation = 9238;
}
public string EdName { get; set; }
public DateTime EdTime { get; set; }
public int Circulation
{
get { return circulation; }
set
{
try
{
circulation = value;
if (circulation < 0) throw new ArgumentException();
}
catch (ArgumentException) { Console.WriteLine("Circulation cannot be < 0!"); }
}
}
public object DeepCopy()
{
Edition other = (Edition)MemberwiseClone();
other.EdName = String.Copy(EdName);
other.EdTime = EdTime;
other.Circulation = Circulation;
return other;
}
public override bool Equals(object obj)
{
if (obj.GetType() != this.GetType()) return false;
Edition ed = (Edition)obj; //preobr ot obj k person
if (this.EdName == ed.EdName && this.EdTime == ed.EdTime && this.Circulation == ed.Circulation)
{ return true; }
else { return false; }
}
public override int GetHashCode()
{
return string.Format("{0}_{1}_{2}", EdName, EdTime, Circulation).GetHashCode();
}
public override string ToString()
{
return String.Format("{0}, from {1}, circulation {2} ", EdName, EdTime.ToShortDateString(), Circulation);
}
}
}