-2

So I took a test and failed because my program didn't run and I can't figure out what I did wrong. I would appreciate any help. My interface ran so I just posted a picture of the test and the codes for the two classes I tried to do.

Test

The classes: (first class)

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;
}
}

(second class)

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){}
Jiri Tousek
  • 12,211
  • 5
  • 29
  • 43

1 Answers1

0

There are several errors on your code, i followed the instructions from your test.

GamePlayer:

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;
    }

}

Promotional Interface:

import java.io.File;
import java.util.Random;

public interface Promotional
{
    public int value ( File file );

    public boolean test ( Random random );

}

TestPlayer:

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;
    }

}

Documentation:

Rcordoval
  • 1,932
  • 2
  • 19
  • 25
  • I figured out the Promotional Interface and GamePlayer class just few minutes ago. I was able to compile them except for the TestPlayer. I REALLY appreciate this. Thank you very much sir. – Amiel Belen Dec 13 '16 at 07:10
  • @AmielBelen Please, mark the proper answer useful if you are done. – Rcordoval Dec 14 '16 at 04:03