FaultInOurPong  1
model.Player Class Reference

Public Member Functions

 Player ()
 Constructor for the player. More...
 
void decrementLife ()
 loses score if the ball touches his/her border. More...
 
int getScore ()
 gets the score of a player. More...
 
void setScore (int x)
 sets the score of the player. More...
 
boolean checkLoss ()
 checks whether the player loses the game or not More...
 
void resetScore ()
 

Private Attributes

final int LIFE = 3
 
final int NOLIFE = 0
 
int score
 

Constructor & Destructor Documentation

§ Player()

model.Player.Player ( )

Constructor for the player.

sets the current life is the full life (3).

Member Function Documentation

§ checkLoss()

boolean model.Player.checkLoss ( )

checks whether the player loses the game or not

Returns
if a player's score is 0 (NOLIFE), return the true to indicate the player loses.

§ decrementLife()

void model.Player.decrementLife ( )

loses score if the ball touches his/her border.

decreases the number of life by 1.

§ getScore()

int model.Player.getScore ( )

gets the score of a player.

Returns
playerScore returns the score of the player.

§ resetScore()

void model.Player.resetScore ( )

§ setScore()

void model.Player.setScore ( int  x)

sets the score of the player.

changes the score to the input value.

Parameters
xis the input score
Exceptions
ArithmeticExceptionscore could not be set less than zero

Member Data Documentation

§ LIFE

final int model.Player.LIFE = 3
private

Defines constant number of life of a player

  • the player has 3 lives in total
  • the player loses if the number of life is 0

§ NOLIFE

final int model.Player.NOLIFE = 0
private

§ score

int model.Player.score
private

Defines the current number of life of the player.


The documentation for this class was generated from the following file: