-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemoClass.java
More file actions
47 lines (37 loc) · 1.07 KB
/
DemoClass.java
File metadata and controls
47 lines (37 loc) · 1.07 KB
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
public class DemoClass {
private int value;
private String name;
public DemoClass() {
this.value = 0;
this.name = "None";
}
public DemoClass(int value, String name) {
this.value = value;
this.name = name;
}
public DemoClass(DemoClass other) {
this(other.value, other.name);
//this.value = other.value;
//this.name = new String(other.name);
}
public String valueToString() {
String returnValue = "None";
switch (this.value) {
case 0: returnValue = "Zero"; break;
case 1: returnValue = "One"; break;
case 2: returnValue = "Two"; break;
default: returnValue = Integer.toString(this.value); break;
}
return returnValue;
}
public boolean equals(DemoClass other) {
boolean returnValue = true;
if (this.value != other.value) {
returnValue = false;
}
if (!this.name.equals(other.name)) {
returnValue = false;
}
return returnValue;
}
}