-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest.java
93 lines (69 loc) · 2.5 KB
/
Test.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import java.util.concurrent.ThreadLocalRandom;
public class Test {
private static int randomInt() {
return ThreadLocalRandom.current().nextInt(0, 101);
}
private static boolean testDefaultInstance() {
MyHouse test = new MyHouse();
return test.getLocation() == "NT"
&& test.getLength() == 15
&& test.getWidth() == 5
&& test.getNumOfFloor() == 1;
}
private static boolean testInstance() {
String location = String.valueOf(randomInt());
int length = randomInt(),
width = randomInt(),
numOfFloor = randomInt();
MyHouse test = new MyHouse(location, length, width, numOfFloor);
return test.getLocation().equals(location)
&& test.getLength() == length
&& test.getWidth() == width
&& test.getNumOfFloor() == numOfFloor;
}
private static boolean testSetLocation() {
MyHouse test = new MyHouse();
String output = String.valueOf(randomInt());
test.setLocation(output);
return test.getLocation().equals(output);
}
private static boolean testSetLength() {
MyHouse test = new MyHouse();
double output = randomInt();
test.setLength(output);
return test.getLength() == output;
}
private static boolean testSetWidth() {
MyHouse test = new MyHouse();
double output = randomInt();
test.setWidth(output);
return test.getWidth() == output;
}
private static boolean testSetNumOfFloor() {
MyHouse test = new MyHouse();
int output = randomInt();
test.setNumOfFloor(output);
return test.getNumOfFloor() == output;
}
private static boolean isEqual() {
MyHouse a = new MyHouse("DT2", 15, 3.5, 1), b = new MyHouse();
return a.equals(b) && b.equals(a);
}
private static boolean isNotEqual() {
MyHouse a = new MyHouse("DT2", 15, 3, 1), b = new MyHouse();
return !a.equals(b);
}
private static void print(boolean a) {
System.out.println(a ? "True" : "False");
}
public static void main(String[] args) {
print(testDefaultInstance());
print(testInstance());
print(testSetLocation());
print(testSetLength());
print(testSetWidth());
print(testSetNumOfFloor());
print(isEqual());
print(isNotEqual());
}
}