File tree Expand file tree Collapse file tree 1 file changed +68
-0
lines changed Expand file tree Collapse file tree 1 file changed +68
-0
lines changed Original file line number Diff line number Diff line change 1+
2+ public class score {
3+ private String t1 ;
4+ private String t2 ;
5+ private boolean status ;
6+ private int s1 ;
7+ private int s2 ;
8+
9+ public score (String t1 , String t2 ) {
10+ this .t1 = t1 ;
11+ this .t2 = t2 ;
12+ this .status = true ;
13+ this .s1 = 0 ;
14+ this .s2 = 0 ;
15+ }
16+
17+ public String getScore () {
18+ String score = s1 + "-" + s2 + "-" ;
19+ if (status ) {
20+ score += t1 ;
21+ }
22+ else if (!status ) {
23+ score += t2 ;
24+ }
25+
26+ return score ;
27+ }
28+
29+ public void setScore (int points ) {
30+ if (status ) {
31+ s1 += points ;
32+ status = false ;
33+ }
34+
35+ else if (!status ) {
36+ s2 += points ;
37+ status = true ;
38+ }
39+ }
40+
41+ public void removeScore (int points ) {
42+ if (status ) {
43+ s1 -= points ;
44+ status = false ;
45+ }
46+
47+ else if (!status ) {
48+ s2 -= points ;
49+ status = true ;
50+ }
51+ }
52+
53+ public String getWinner () {
54+ if (s1 > s2 ) {
55+ return t1 ;
56+ }
57+
58+ else if (s2 > s1 ) {
59+ return t2 ;
60+ }
61+
62+ else {
63+ return t1 + " and " + t2 + " are tied!" ;
64+ }
65+
66+ }
67+
68+ }
You can’t perform that action at this time.
0 commit comments