File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ public class Player
2+ {
3+ private String name ;
4+ private int score ;
5+
6+ public Player (String name )
7+ {
8+ this .name = name ;
9+ this .score = 0 ;
10+ }
11+
12+ public void incrementScore ()
13+ {
14+ this .score ++;
15+ }
16+
17+ public void resetScore ()
18+ {
19+ this .score = 0 ;
20+ }
21+
22+ public int getScore ()
23+ {
24+ return score ;
25+ }
26+
27+ public String getName ()
28+ {
29+ return name ;
30+ }
31+ }
Original file line number Diff line number Diff line change 1+ public class PlayerTest
2+ {
3+ public static void main (String [] args )
4+ {
5+ Player playerName = new Player ("Silent T" );
6+
7+
8+ System .out .println ("Player Name: " + playerName .getName ());
9+ System .out .println ("Starting score: " + playerName .getScore ());
10+
11+ playerName .incrementScore ();
12+ System .out .println (playerName .getScore ());
13+
14+ playerName .incrementScore ();
15+ System .out .println (playerName .getScore ());
16+
17+ playerName .resetScore ();
18+ System .out .println (playerName .getScore ());
19+
20+
21+ }
22+
23+ }
You can’t perform that action at this time.
0 commit comments