-
Notifications
You must be signed in to change notification settings - Fork 0
/
Domino.java
62 lines (51 loc) · 1.1 KB
/
Domino.java
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
public class Domino
{
private int num1, num2;
public Domino(int n, int j) {
this.setNum1(n);
this.setNum2(j);
}
public Domino (Domino d)
{
this.setNum1(d.num1);
this.setNum2(d.num2);
}
public int getNum1()
{
return this.num1;
}
public int getNum2()
{
return this.num2;
}
public void setNum1(int n)
{
this.num1 = n;
}
public void setNum2(int n)
{
this.num2 = n;
}
public String toString()
{
return String.format("[" + this.num1 + "|" + this.num2 + "]");
}
public Boolean equals(Domino d)
{
Domino c = (Domino) d;
return Integer.compare(num1, c.num1) == 0 || Integer.compare(num1, c.num2) == 0 || Integer.compare(num2, c.num1) == 0 || Integer.compare(num2, c.num2) == 0;
}
public void swapNumbers()
{
int holder;
holder = this.num1;
this.num1 = this.num2;
this.num2 = holder;
}
public int getValue()
{
int total;
total = this.num1 + this.num2;
return total;
}
}