-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArmor.java
More file actions
40 lines (33 loc) · 1.02 KB
/
Copy pathArmor.java
File metadata and controls
40 lines (33 loc) · 1.02 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
package studyjava;
class zItem {
String name;
int price;
}
class Armor extends zItem {
int level;
public static void main(String[] args) {
studyjava.Armor hujia1 = new studyjava.Armor();
hujia1.name = "hujia1";
hujia1.level = 2;
hujia1.price = 2000;
System.out.println("护甲的名字" + hujia1.name);
System.out.println("护甲的价格" + hujia1.price);
System.out.println("护甲的等级" + hujia1.level);
Armor h1 = new Armor();
Armor h2 = new Armor();
h1.name = "h1";
h2.name = "h2";
hujia1.hujia(h1, h2);
}
public void hujia(Armor hujia) {
System.out.println("买了一件" + hujia.name + "护甲");
}
public void hujia(Armor hujia, int n) {
System.out.println("买了" + n + "件" + hujia.name + "护甲");
}
public void hujia(Armor... armors) {
for (int i = 0; i < armors.length; i++) {
System.out.println(name + "和" + armors[i].name);
}
}
}