-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathAllBodyParts.java
More file actions
67 lines (51 loc) · 1.79 KB
/
AllBodyParts.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
package hw4;
public class AllBodyParts extends Classified implements Human { // Abstraction
//Multi-level Inheritance
public static String subjectName;
public AllBodyParts() {
/* 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(String topPart, int topPartNo) { // Constructor
System.out.println("All include in " + topPart);
}
public AllBodyParts(String middlePart) {
System.out.println(middlePart);
}
public AllBodyParts(int eyeNo) {
System.out.println("from constructor " + eyeNo);
}
public void AllBodyParts(int eyeNo) { // A void method with the same name as class and constructor
System.out.println("from method " + eyeNo);
}
public double AllBodyParts(double legNo, double handNo) {
// A return method with the same name as class and constructor
double legNhand = legNo + handNo;
System.out.println("return method " + legNhand);
return legNhand;
}
public void AllBodyPartsIn() { // Polymorphism
System.out.println("parts stolen, nothing found");
}
public void AllBodyPartsIn(String hd) {
System.out.println(hd + " found");
}
public void AllBodyPartsIn(String hd, int eyeNo) {
System.out.println(hd + " found and " + eyeNo + " eye found");
}
public void bodyParts(String topPart) {
}
public int eye(int eyeNo) {
System.out.println("this person has " + eyeNo + " eyes"); // Overridden from Interface
return eyeNo;
}
public void leg(double legNo) {
}
public void hand(double handNo) {
}
public void tail() {
System.out.println(subjectName + " has a tail");
}
}