-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathScoreboard.java
More file actions
42 lines (37 loc) · 947 Bytes
/
Copy pathScoreboard.java
File metadata and controls
42 lines (37 loc) · 947 Bytes
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
import java.lang.reflect.AccessFlag;
public class Scoreboard {
private String teamOne;
private String teamTwo;
private int teamOneScore;
private int teamTwoScore;
private String activeTeam;
Scoreboard(String one, String two)
{
teamOne = one;
teamTwo = two;
activeTeam = teamOne;
}
public String getScore()
{
return teamOneScore + "-" + teamTwoScore + "-" + activeTeam;
}
public void recordPlay(int score)
{
if (score > 0)
{
if (activeTeam.equals(teamOne))
{
teamOneScore += score;
}
else if (activeTeam.equals(teamTwo))
{
teamTwoScore += score;
}
}
else
{
if (activeTeam.equals(teamOne)){activeTeam = teamTwo;}
else if (activeTeam.equals(teamTwo)) {activeTeam = teamOne;}
}
}
}