Guest User

Untitled

a guest
Jul 18th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.75 KB | None | 0 0
  1. package com.example.android.courtcounter;
  2.  
  3. import android.os.Bundle;
  4. import android.support.v7.app.AppCompatActivity;
  5. import android.view.View;
  6. import android.widget.Button;
  7. import android.widget.TextView;
  8. import android.content.res.Resources;
  9.  
  10. public class MainActivity extends AppCompatActivity {
  11. Button add, sub;
  12. int Ascore;
  13. int Bscore;
  14.  
  15. @Override
  16. protected void onApplyThemeResource(Resources.Theme theme, int resid, boolean first) {
  17. super.onApplyThemeResource(theme, resid, first);
  18. setContentView(R.layout.activity_main);
  19. add = findViewById(R.id.team_a_b1);
  20. add = findViewById(R.id.team_a_b2);
  21. add = findViewById(R.id.team_a_b3);
  22. sub = findViewById(R.id.team_a_b4);
  23. add = findViewById(R.id.team_b_b1);
  24. add = findViewById(R.id.team_b_b2);
  25. add = findViewById(R.id.team_b_b3);
  26. sub = findViewById(R.id.team_b_b4);
  27. }
  28. /**
  29. * Increase the score for Team A by 1 point.
  30. */
  31. public void addOneForTeamA(View v) {
  32. displayForTeamA(Ascore += 1);
  33. }
  34. /**
  35. * Increase the score for Team A by 2 points.
  36. */
  37. public void addTwoForTeamA(View v) {
  38. displayForTeamA(Ascore += 2);
  39. }
  40. /**
  41. * Increase the score for Team A by 3 points.
  42. */
  43. public void addThreeForTeamA(View v) {
  44. displayForTeamA(Ascore += 3);
  45. }
  46. /**
  47. * Decrease the score for Team by 2 points.
  48. */
  49. public void subtractTwoForTeamA(View v) {
  50. displayForTeamA(Ascore -= 2);
  51. }
  52. /**
  53. * Displays the given score for Team A.
  54. */
  55. public void displayForTeamA(int Ascore) {
  56. TextView scoreView = findViewById(R.id.team_a_score);
  57. scoreView.setText(String.valueOf(Ascore));
  58. }
  59. /**
  60. * /**
  61. * <p>
  62. * Increase the score for Team B by 1 point.
  63. */
  64.  
  65. public void addOneForTeamB(View v) {
  66. displayForTeamB(Bscore += 1);
  67. }
  68. /**
  69. * Increase the score for Team b by 2 points.
  70. */
  71.  
  72. public void addTwoForTeamB(View v) {
  73. displayForTeamB(Bscore += 2);
  74. }
  75. /**
  76. * Increase the score for Team B by 3 points.
  77. */
  78. public void addThreeForTeamB(View v) {
  79. displayForTeamB(Bscore += 3);
  80. }
  81. /**
  82. * Decrease the score for Team B by 2 points.
  83. */
  84. public void subtractTwoForTeamB(View v) {
  85. displayForTeamB(Bscore -= 2);
  86. }
  87. /**
  88. * Displays the given score for Team B.
  89. */
  90. public void displayForTeamB(int Bscore) {
  91. TextView scoreView = findViewById(R.id.team_b_score);
  92. scoreView.setText(String.valueOf(Bscore));
  93. }
  94. /**
  95. * Displays the given score for Team B.
  96. */
  97. public void reset(View v) {
  98. Ascore = 0;
  99. Bscore = 0;
  100. displayForTeamA(Ascore);
  101. displayForTeamB(Bscore);
  102. }
  103.  
  104. }
Add Comment
Please, Sign In to add comment