Advertisement
ms_olin

Untitled

Feb 26th, 2017
3,933
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. package com.panelic.papanscore;
  2.  
  3. import android.os.Bundle;
  4. import android.support.v7.app.AppCompatActivity;
  5. import android.view.View;
  6. import android.widget.TextView;
  7.  
  8. public class MainActivity extends AppCompatActivity {
  9.  
  10. int scoreTeamA, scoreTeamB = 0;
  11.  
  12. @Override
  13. protected void onCreate(Bundle savedInstanceState) {
  14. super.onCreate(savedInstanceState);
  15. setContentView(R.layout.activity_main);
  16. }
  17.  
  18. public void displayForTeamA(int score) {
  19. TextView scoreView = (TextView) findViewById(R.id.team_a_score);
  20. scoreView.setText(String.valueOf(score));
  21. /*
  22. Menampilkan score Team A di dalam TextView yang di tampilkan
  23. Menset nilai score yang bertipe data integer
  24.  
  25. */
  26.  
  27.  
  28. }
  29.  
  30. public void tigaPointA(View v) {
  31. scoreTeamA = scoreTeamA + 3;
  32. displayForTeamA(scoreTeamA);
  33. //Menambah Point Team A 3
  34. }
  35.  
  36. public void duaPointA(View v) {
  37. scoreTeamA = scoreTeamA + 2;
  38. displayForTeamA(scoreTeamA);
  39. //Menambah Point Team A 2
  40.  
  41. }
  42.  
  43. public void satuPointA(View v) {
  44. scoreTeamA = scoreTeamA + 1;
  45. displayForTeamA(scoreTeamA);
  46.  
  47. //Menambah Point Team A 1
  48. }
  49.  
  50. public void displayForTeamB(int score) {
  51. TextView scoreView = (TextView) findViewById(R.id.team_b_score);
  52. scoreView.setText(String.valueOf(score));
  53. /*
  54. Menampilkan score Team B di dalam TextView yang di tampilkan
  55. Menset nilai score yang bertipe data integer
  56.  
  57. */
  58.  
  59. }
  60.  
  61. public void tigaPointB(View v) {
  62. scoreTeamB = scoreTeamB + 3;
  63. displayForTeamB(scoreTeamB);
  64. // Menambah Point Team B 3
  65.  
  66. }
  67.  
  68. public void duaPointB(View v) {
  69. scoreTeamB = scoreTeamB + 2;
  70. displayForTeamB(scoreTeamB);
  71. // Menambah Point Team B 2
  72. }
  73.  
  74. public void satuPointB(View v) {
  75. scoreTeamB = scoreTeamB + 1;
  76. displayForTeamB(scoreTeamB);
  77. // Menambah Point Team B 1
  78. }
  79.  
  80.  
  81. public void resetPoint(View v) {
  82. scoreTeamA = 0;
  83. scoreTeamB = 0;
  84. displayForTeamA(scoreTeamA);
  85. displayForTeamB(scoreTeamB);
  86. //Reset point Team A dan Team B ke 0
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement