Guest User

Untitled

a guest
Jan 20th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. package com.example.android.courtcounter;
  2.  
  3. import android.support.v7.app.AppCompatActivity;
  4. import android.os.Bundle;
  5. import android.view.View;
  6. import android.widget.TextView;
  7.  
  8. public class MainActivity extends AppCompatActivity {
  9.  
  10. int scoreTeamA = 0;
  11. int scoreTeamB = 0;
  12. /**
  13. * Displays the given score for Team A.
  14. */
  15. public void displayForTeamA(int score) {
  16. TextView scoreView = (TextView) findViewById(R.id.team_a_score);
  17. scoreView.setText(String.valueOf(score));
  18. }
  19.  
  20. /**
  21. * Displays the given score for Team B.
  22. */
  23. public void displayForTeamB(int score) {
  24. TextView scoreView = (TextView) findViewById(R.id.team_b_score);
  25. scoreView.setText(String.valueOf(score));
  26. }
  27.  
  28. @Override
  29. protected void onCreate(Bundle savedInstanceState) {
  30. super.onCreate(savedInstanceState);
  31. setContentView(R.layout.activity_main);
  32. }
  33.  
  34. public void addOneForTeamA(View v){
  35. scoreTeamA = scoreTeamA +1;
  36. displayForTeamA(scoreTeamA);
  37. }
  38.  
  39. public void addOTwoForTeamA(View v){
  40. scoreTeamA = scoreTeamA + 2;
  41. displayForTeamA(scoreTeamA);
  42. }
  43.  
  44. public void addThreeForTeamA(View v){
  45. scoreTeamA = scoreTeamA + 3;
  46. displayForTeamA(scoreTeamA);
  47. }
  48.  
  49.  
  50. public void addOneForTeamB(View v){
  51. scoreTeamB = scoreTeamB +1;
  52. displayForTeamB(scoreTeamB);
  53. }
  54.  
  55. public void addOTwoForTeamB(View v){
  56. scoreTeamB = scoreTeamB + 2;
  57. displayForTeamB(scoreTeamB);
  58. }
  59.  
  60. public void addThreeForTeamB(View v){
  61. scoreTeamB = scoreTeamB + 3;
  62. displayForTeamB(scoreTeamB);
  63. }
  64.  
  65. public void Reset(View v){
  66. scoreTeamB = 0;
  67. scoreTeamA = 0;
  68. displayForTeamB(scoreTeamB);
  69. displayForTeamA(scoreTeamA);
  70. }
  71. }
Add Comment
Please, Sign In to add comment