Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.android.courtcounter;
- import android.os.Bundle;
- import android.support.v7.app.AppCompatActivity;
- import android.view.View;
- import android.widget.Button;
- import android.widget.TextView;
- import android.content.res.Resources;
- public class MainActivity extends AppCompatActivity {
- Button add, sub;
- int Ascore;
- int Bscore;
- @Override
- protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
- super.onApplyThemeResource(theme, resid, first);
- setContentView(R.layout.activity_main);
- add = findViewById(R.id.team_a_b1);
- add = findViewById(R.id.team_a_b2);
- add = findViewById(R.id.team_a_b3);
- sub = findViewById(R.id.team_a_b4);
- add = findViewById(R.id.team_b_b1);
- add = findViewById(R.id.team_b_b2);
- add = findViewById(R.id.team_b_b3);
- sub = findViewById(R.id.team_b_b4);
- }
- /**
- * Increase the score for Team A by 1 point.
- */
- public void addOneForTeamA(View v) {
- displayForTeamA(Ascore += 1);
- }
- /**
- * Increase the score for Team A by 2 points.
- */
- public void addTwoForTeamA(View v) {
- displayForTeamA(Ascore += 2);
- }
- /**
- * Increase the score for Team A by 3 points.
- */
- public void addThreeForTeamA(View v) {
- displayForTeamA(Ascore += 3);
- }
- /**
- * Decrease the score for Team by 2 points.
- */
- public void subtractTwoForTeamA(View v) {
- displayForTeamA(Ascore -= 2);
- }
- /**
- * Displays the given score for Team A.
- */
- public void displayForTeamA(int Ascore) {
- TextView scoreView = findViewById(R.id.team_a_score);
- scoreView.setText(String.valueOf(Ascore));
- }
- /**
- * /**
- * <p>
- * Increase the score for Team B by 1 point.
- */
- public void addOneForTeamB(View v) {
- displayForTeamB(Bscore += 1);
- }
- /**
- * Increase the score for Team b by 2 points.
- */
- public void addTwoForTeamB(View v) {
- displayForTeamB(Bscore += 2);
- }
- /**
- * Increase the score for Team B by 3 points.
- */
- public void addThreeForTeamB(View v) {
- displayForTeamB(Bscore += 3);
- }
- /**
- * Decrease the score for Team B by 2 points.
- */
- public void subtractTwoForTeamB(View v) {
- displayForTeamB(Bscore -= 2);
- }
- /**
- * Displays the given score for Team B.
- */
- public void displayForTeamB(int Bscore) {
- TextView scoreView = findViewById(R.id.team_b_score);
- scoreView.setText(String.valueOf(Bscore));
- }
- /**
- * Displays the given score for Team B.
- */
- public void reset(View v) {
- Ascore = 0;
- Bscore = 0;
- displayForTeamA(Ascore);
- displayForTeamB(Bscore);
- }
- }
Add Comment
Please, Sign In to add comment