-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayer.java
81 lines (66 loc) · 1.41 KB
/
Player.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
/**
* Name: Player
* Description: A class that contains several helper methods that set and get the player's parameters
* @author SCOTT GRISSOM & XUE HUA
* @version 08 NOV 2018
*/
public class Player
{
private String name ;
private int score ;
private int turns ;
private int subtotal ;
/**
* Constructor for objects of class Player
*/
public Player(String pName)
{
// initialise instance variables
name = pName ;
score = 0 ;
turns = 0 ;
subtotal = 0 ;
}
public String getName(){
return name ;
}
public void setName (String n){
name = n ;
}
public int getScore(){
return score ;
}
public void setScore(int s) {
score = s ;
}
public int getSubtotal(){
return subtotal ;
}
public void setSubtotal(int s){
subtotal = s ;
}
public int getTurns(){
return turns ;
}
public void setTurns(int t){
turns = t ;
}
public void addToSubtotal (int amt){
subtotal += amt;
}
public void updateScore(){
score += subtotal ;
subtotal = 0 ;
turns += 1 ;
}
public void newGame(){
score = 0 ;
subtotal = 0 ;
turns = 0 ;
}
}