-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAnimalhw.java.bak
More file actions
42 lines (35 loc) · 845 Bytes
/
Animalhw.java.bak
File metadata and controls
42 lines (35 loc) · 845 Bytes
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
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;
}
//a2 setName() »ý¼º
//a2 getName() È£Ãâ
//a4 setOwner()»ý¼º
//a4 getOwner()È£Ãâ
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");
}
}