这里的(在“新”,在第二个“杀手”),在那里我收到的错误代码。
String[] classes = new String[5];
kills[0] = "Brian Moser";
kills[1] = "James Doakes";
kills[2] = "Lila Tourney";
kills[3] = "Miguel Prado";
Killer morgan = new Killer("Dexter",
"Morgan",
kills,
4.0,
"Arthur Mitchell",
3,
false);
这已经给了我相当多的麻烦,因为我看不出为什么这个声明应该工作基于我的构造函数杀手。
而这里的杀手类:
import java.util.*;
public abstract class Killer{
public String firstName;
public String lastName;
private String[] killList;
private double score;
private String nemesis;
private int accidents;
public boolean caught;
public Killer(String firstName,
String lastName,
String[] killList,
double score,
String nemesis,
int accidents,
boolean caught)
{
this.firstName = firstName;
this.lastName = lastName;
for(int i = 0; i < 5; i++)
this.killList[i] = killList[i];
this.score = score;
this.nemesis = nemesis;
this.accidents = accidents;
this.caught = caught;
} //end constructor
我知道这可能有一个简单的解决方案,但截至目前为止,我没有看到它。