所以我参加了测试但失败了,因为我的程序没有运行,我无法弄清楚我做错了什么。我将不胜感激任何帮助。我的界面运行了所以我刚刚发布了测试图片和我试图做的两个类的代码。
课程: (头等舱)
public class GamePlayer {
protected String name;
protected Object Record;
public GamePlayer(value){
this.value = value;
}
public String getNAme(){
return value;
}
public void setRecord(value){
this.value = value;
}
}
(第二课)
import java.net.URL;
import java.io.File;
import java.util.Random;
public class TestPlayer extends GamePlayer implemetents Promotional, Comparable > TestPlayer {
private URL score;
public TestPlayer (String s){}
public URL getScore(){}
public void setScore (URL s){}
public String compareTo(GamePlayer other){
return 0;
}
public File value (int k){
return null;
}
public boolean test (Random r){}
答案 0 :(得分:0)
您的代码有几处错误,我按照您的测试说明进行操作。
public class GamePlayer
{
protected String name;
protected Object record;
public GamePlayer ( String name )
{
super ( );
this.name = name;
}
public String getName ( )
{
return name;
}
public void setRecord ( Object record )
{
this.record = record;
}
@Override
public int hashCode ( )
{
final int prime = 31;
int result = 1;
result = prime * result + ( ( name == null ) ? 0 : name.hashCode ( ) );
return result;
}
@Override
public boolean equals ( Object obj )
{
if ( this == obj )
return true;
if ( obj == null )
return false;
if ( getClass ( ) != obj.getClass ( ) )
return false;
GamePlayer other = ( GamePlayer ) obj;
if ( name == null )
{
if ( other.name != null )
return false;
}
else if ( ! name.equals ( other.name ) )
return false;
return true;
}
}
import java.io.File;
import java.util.Random;
public interface Promotional
{
public int value ( File file );
public boolean test ( Random random );
}
import java.io.File;
import java.net.URL;
import java.util.Random;
public class TestPlayer extends GamePlayer implements Promotional, Comparable < TestPlayer >
{
private URL score;
public TestPlayer ( String name )
{
super ( name );
}
@Override
public int value ( File file )
{
return 0;
}
@Override
public boolean test ( Random random )
{
return false;
}
@Override
public int compareTo ( TestPlayer o )
{
return 0;
}
/**
* @return the score
*/
public URL getScore ( )
{
return score;
}
/**
* @param score the score to set
*/
public void setScore ( URL score )
{
this.score = score;
}
}
<强>文档强>