Player object – Java

What it is: 

This is a Player object which I created to use with various programs I have created or will create at the minute its fairly basic as it only has a name, score and a toString method.


public class Player
   private String name;
   private int score;

   public Player()


   public void setName(String pName)
      name = pName;

   public String getName()
      return name;

   public void setScore(int pScoreIncrease)
      score += pScoreIncrease;

   public int getScore()
      return score;

   public String toString()
      return "Players Name: " +  + "\nScore: " + this.score;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s