-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimalhw.java
More file actions
59 lines (47 loc) · 1.06 KB
/
Animalhw.java
File metadata and controls
59 lines (47 loc) · 1.06 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
class Animalhw{
private String name;
private String owner;
int leg;
public void eat() {
System.out.println("¸Ô´Ù");
}
public Animalhw(String name, String owner, int leg){
this.name=name;
this.owner=owner;
this.leg=leg;
}
public Animalhw(String owner, int leg){
this.owner=owner;
this.leg=leg;
}
public Animalhw(String name, String owner){
this.name=name;
this.owner=owner;
}
public Animalhw(String name){
this.name=name;
}
public void setName(String name){
this.name=name;
}
public String getName(){
return name;
}
public void setOwner(String owner){
this.owner=owner;
}
public String getOwner(){
return owner;
}
public static void main(String ar[]) {
Animalhw a1=new Animalhw("lion","Mike",4);
Animalhw a2=new Animalhw("Tom",4);
Animalhw a3=new Animalhw("rabbit","Alice");
Animalhw a4=new Animalhw("sheep");
Animalhw a5=new Animalhw("dog","John");
a2.setName("cat");
System.out.println(a2.getName());
a4.setOwner("Jane");
System.out.println(a4.getOwner());
}
}