-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainActivity.java
93 lines (75 loc) · 2.39 KB
/
MainActivity.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
82
83
84
85
86
87
88
89
90
91
92
93
package com.example.android.scorekeepertkd;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
int scoreTeamA = 0;
int scoreTeamB = 0;
/**
* Displays the given score for Team A.
*/
public void displayForTeamA(int scoreTeamA) {
TextView scoreView = (TextView) findViewById(R.id.team_a_score);
scoreView.setText(String.valueOf(scoreTeamA));
}
/**
* Displays the given score for Team B.
*/
public void displayForTeamB(int score) {
TextView scoreView = (TextView) findViewById(R.id.team_b_score);
scoreView.setText(String.valueOf(score));
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
displayForTeamA(0);
displayForTeamB(0);
}
public void scoreFourA(View view) {
scoreTeamA = scoreTeamA + 4;
displayForTeamA(scoreTeamA);
}
public void scoreThreeA(View view) {
scoreTeamA = scoreTeamA + 3;
displayForTeamA(scoreTeamA);
}
public void scoreTwoA(View view) {
scoreTeamA = scoreTeamA + 2;
displayForTeamA(scoreTeamA);
}
public void scoreOneA(View view) {
scoreTeamA = scoreTeamA + 1;
displayForTeamA(scoreTeamA);
}
public void scoreDecOneA(View view) {
scoreTeamA = scoreTeamA - 1;
displayForTeamA(scoreTeamA);
}
public void scoreFourB(View view) {
scoreTeamB = scoreTeamB + 4;
displayForTeamB(scoreTeamB);
}
public void scoreThreeB(View view) {
scoreTeamB = scoreTeamB + 3;
displayForTeamB(scoreTeamB);
}
public void scoreTwoB(View view) {
scoreTeamB = scoreTeamB + 2;
displayForTeamB(scoreTeamB);
}
public void scoreOneB(View view) {
scoreTeamB = scoreTeamB + 1;
displayForTeamB(scoreTeamB);
}
public void scoreDecOneB(View view) {
scoreTeamB = scoreTeamB - 1;
displayForTeamB(scoreTeamB);
}
public void reset(View view) {
scoreTeamA = 0;
displayForTeamA(scoreTeamA);
scoreTeamB = 0;
displayForTeamB(scoreTeamB);
}
}