This repository has been archived by the owner on Dec 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainActivity.java
56 lines (46 loc) · 1.82 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
package com.example.atli.summativeuserinput;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void incrementA(View view){
TextView scoreATextView = (TextView) findViewById(R.id.scoreA);
String value = (String) scoreATextView.getText();
int newValue;
newValue = Integer.parseInt(value);
scoreATextView.setText(newValue++);
}
public void decrementA(View view) {
TextView scoreATextView = (TextView) findViewById(R.id.scoreA);
String value = (String) scoreATextView.getText();
int newValue;
newValue = Integer.parseInt(value);
scoreATextView.setText(newValue--);
}
public void incrementB(View view){
TextView scoreBTextView = (TextView) findViewById(R.id.scoreB);
String value = (String) scoreBTextView.getText();
int newValue;
newValue = Integer.parseInt(value);
scoreBTextView.setText(newValue++);
}
public void decrementB(View view) {
TextView scoreBTextView = (TextView) findViewById(R.id.scoreB);
String value = (String) scoreBTextView.getText();
int newValue;
newValue = Integer.parseInt(value);
scoreBTextView.setText(newValue--);
}
public void reset(View view) {
TextView scoreATextView = (TextView) findViewById(R.id.scoreA);
scoreATextView.setText(0);
TextView scoreBTextView = (TextView) findViewById(R.id.scoreB);
scoreBTextView.setText(0);
}
}