- Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAllBodyParts.java
More file actions
Latest commit
67 lines (51 loc) · 1.79 KB
/
Copy pathAllBodyParts.java
File metadata and controls
67 lines (51 loc) · 1.79 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
packagehw4;
publicclassAllBodyPartsextendsClassifiedimplementsHuman { // Abstraction
//Multi-level Inheritance
publicstaticStringsubjectName;
publicAllBodyParts() {
/* the default constructor, which (auto-generated during the creation of a
* class) you can call otherwise will not work */
// TODO Auto-generated constructor stub
System.out.println("default constructor");
}
AllBodyParts(StringtopPart, inttopPartNo) { // Constructor
System.out.println("All include in " + topPart);
}
publicAllBodyParts(StringmiddlePart) {
System.out.println(middlePart);
}
publicAllBodyParts(inteyeNo) {
System.out.println("from constructor " + eyeNo);
}
publicvoidAllBodyParts(inteyeNo) { // A void method with the same name as class and constructor
System.out.println("from method " + eyeNo);
}
publicdoubleAllBodyParts(doublelegNo, doublehandNo) {
// A return method with the same name as class and constructor
doublelegNhand = legNo + handNo;
System.out.println("return method " + legNhand);
returnlegNhand;
}
publicvoidAllBodyPartsIn() { // Polymorphism
System.out.println("parts stolen, nothing found");
}
publicvoidAllBodyPartsIn(Stringhd) {
System.out.println(hd + " found");
}
publicvoidAllBodyPartsIn(Stringhd, inteyeNo) {
System.out.println(hd + " found and " + eyeNo + " eye found");
}
publicvoidbodyParts(StringtopPart) {
}
publicinteye(inteyeNo) {
System.out.println("this person has " + eyeNo + " eyes"); // Overridden from Interface
returneyeNo;
}
publicvoidleg(doublelegNo) {
}
publicvoidhand(doublehandNo) {
}
publicvoidtail() {
System.out.println(subjectName + " has a tail");
}
}