package zh.codegym.task.task03.task0307;
/*
你好,《星际争霸》!
*/
public class Solution {
public static void main(String[] args) {
//在此编写你的代码
Zerg z1 = new Zerg("1");
Zerg z2 = new Zerg("2");
Zerg z3 = new Zerg("3");
Zerg z4 = new Zerg("4");
Zerg z5 = new Zerg("5");
Protoss p1 = new Protoss("51");
Protoss p2 = new Protoss("41");
Protoss p3 = new Protoss("31");
Terran t = new Terran("12");
Terran t2 = new Terran("22");
Terran t3 = new Terran("32");
Terran t4 = new Terran("42");
}
public static class Zerg {
public String name;
public Zerg(String name){
this.name = name;
}
}
public static class Protoss {
public String name;
public Protoss(String name){
this.name = name;
}
}
public static class Terran {
public String name;
public Terran(String name){
this.name = name;
}
}
}
为什么使用构造方法会出错 ?
正在讨论
评论 (2)
- 受欢迎
- 新
- 旧
你必须先登录才能发表评论
John Squirrels Website Admin 位于 CodeGym
26 四月 2022, 07:26
You are not supposed to change the Zorg/Protoss/Terran classes. Create required objects, then set the names for each new object by calling the "name" variable.
0
Anonymous #10981494
23 四月 2022, 12:28
题目要求:不要更改 Zerg、Protoss 和 Terran 类。 自己会的内容就直接复制跳过就行了
0