Guest User

Untitled

a guest
Feb 25th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.29 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.Menu;
  6. import android.view.MenuItem;
  7. import android.view.View;
  8. import android.widget.TextView;
  9.  
  10. import java.util.Set;
  11.  
  12. public class MainActivity extends AppCompatActivity {
  13.  
  14.  
  15. @Override
  16. protected void onCreate(Bundle savedInstanceState) {
  17. super.onCreate( savedInstanceState );
  18. setContentView( R.layout.activity_main );
  19.  
  20. }
  21.  
  22. /**
  23. * Displays the given score for Team A.
  24. */
  25. public void displayForTeamA(int score) {
  26. TextView scoreView = (TextView) findViewById(R.id.team_a_score);
  27. scoreView.setText(String.valueOf(score));
  28. }
  29. int scoreTeamA = 0;
  30. /**
  31. * Increase the score for Team A by 1 point.
  32. */
  33. public void addOneForTeamA(View v) {
  34. scoreTeamA = scoreTeamA + 1;
  35. displayForTeamA( scoreTeamA );
  36. }
  37.  
  38. /**
  39. * Increase the score for Team A by 2 points.
  40. */
  41. public void addTwoForTeamA(View v) {
  42. scoreTeamA = scoreTeamA + 2;
  43. displayForTeamA( scoreTeamA );
  44. }
  45.  
  46. /**
  47. * Increase the score for Team A by 3 points.
  48. */
  49. public void addThreeForTeamA(View v) {
  50. scoreTeamA = scoreTeamA +3;
  51. displayForTeamA( scoreTeamA );
  52. }
  53.  
  54. /**
  55. * Displays the given score for Team B.
  56. */
  57. public void displayForTeamB(int score) {
  58. TextView scoreView = (TextView) findViewById(R.id.team_b_score);
  59. scoreView.setText(String.valueOf(score));
  60. }
  61. int scoreTeamB = 0;
  62. /**
  63. * Increase the score for Team B by 1 point.
  64. */
  65. public void addOneForTeamB(View v) {
  66. scoreTeamB = scoreTeamB + 1;
  67. displayForTeamB( scoreTeamB );
  68. }
  69.  
  70. /**
  71. * Increase the score for Team B by 2 points.
  72. */
  73. public void addTwoForTeamB(View v) {
  74. scoreTeamB = scoreTeamB + 2;
  75. displayForTeamB( scoreTeamB );
  76. }
  77.  
  78. /**
  79. * Increase the score for Team B by 3 points.
  80. */
  81. public void addThreeForTeamB(View v) {
  82. scoreTeamB = scoreTeamB +3;
  83. displayForTeamB( scoreTeamB );
  84. }
  85.  
  86. /**
  87. * reset the score to zreo.
  88. */
  89. public void resetScore (View v) {
  90. scoreTeamA = 0;
  91. scoreTeamB = 0;
  92. displayForTeamA( 0 );
  93. displayForTeamB( 0 );
  94. }
  95. }
Add Comment
Please, Sign In to add comment