iNoobAvicena

4 slot game java

Oct 18th, 2021 (edited)
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.78 KB | None | 0 0
  1. ImageView _slot1, _slot2, _slot3, _slot4;
  2.     Button _action;
  3.     boolean inAction = true;
  4.     Asynctask _async1, _async2, _async3, _async4;
  5.  
  6.     @Override
  7.     protected void onCreate(Bundle savedInstanceState) {
  8.         super.onCreate(savedInstanceState);
  9.         setContentView(R.layout.activity_main);
  10.  
  11.         _action = findViewById(R.id.action);
  12.         _action.setOnClickListener(this);
  13.  
  14.         _slot1 = findViewById(R.id.slot1);
  15.         _slot2 = findViewById(R.id.slot2);
  16.         _slot3 = findViewById(R.id.slot3);
  17.         _slot4 = findViewById(R.id.slot4);
  18.  
  19.     }
  20.  
  21.     @Override
  22.     public void onClick(View v) {
  23.         if (v.getId() == _action.getId()) {
  24.             if (inAction) {
  25.  
  26.                 new Asynctask(_async1).execute();
  27.  
  28.                 _async1 = new Asynctask();
  29.                 _async2 = new Asynctask();
  30.                 _async3 = new Asynctask();
  31.                 _async4 = new Asynctask();
  32.  
  33. //                _async1 = new Asynctask();
  34. //                _async1.executeOnExecutor(Asynctask.SERIAL_EXECUTOR, _slot1);
  35.  
  36.                 _async1.executeOnExecutor(Asynctask.THREAD_POOL_EXECUTOR, _slot1);
  37. //
  38. //                _async2 = new Asynctask();
  39.                 _async2.executeOnExecutor(Asynctask.THREAD_POOL_EXECUTOR, _slot2);
  40. //
  41. //                _async3 = new Asynctask();
  42. //                _async3.executeOnExecutor(Asynctask.THREAD_POOL_EXECUTOR, _slot3);
  43.  
  44. //                _async4 = (Asynctask) new Asynctask().execute(_slot4);
  45.  
  46. //                _async4 = new Asynctask();
  47.                 _async4.executeOnExecutor(Asynctask.THREAD_POOL_EXECUTOR, _slot4);
  48. //                _async4.execute(_slot4);
  49.  
  50. //                if (_async1._next == _async2._next && _async2._next == _async3._next) {
  51. //                    Toast.makeText(getApplicationContext(), "Menang Banyak", Toast.LENGTH_SHORT).show();
  52. //                } else if (_async1._next == _async2._next || _async2._next == _async3._next || _async1._next == _async3._next) {
  53. //                    Toast.makeText(getApplicationContext(), "Menang", Toast.LENGTH_SHORT).show();
  54. //                } else {
  55. //                    Toast.makeText(getApplicationContext(), "Kalah", Toast.LENGTH_SHORT).show();
  56. //                }
  57.  
  58. //                else {
  59. //                    Toast.makeText(getApplicationContext(), "Kalah", Toast.LENGTH_SHORT).show();
  60. //                }
  61.  
  62.                 _action.setText("STOP");
  63.  
  64.             } else {
  65.  
  66.                 _async1._roll = false;
  67.  
  68.                 _async2._roll = false;
  69.  
  70. //                _async3._roll = false;
  71.  
  72.                 _async4._roll = false;
  73.  
  74.                 if (_async1._next == _async2._next && _async2._next == _async4._next) {
  75.                     Toast.makeText(getApplicationContext(), "Menang Banyak", Toast.LENGTH_SHORT).show();
  76.                 } else if (_async1._next == _async2._next || _async2._next == _async4._next || _async1._next == _async4._next) {
  77.                     Toast.makeText(getApplicationContext(), "Menang", Toast.LENGTH_SHORT).show();
  78.                 } else {
  79.                     Toast.makeText(getApplicationContext(), "Kalah", Toast.LENGTH_SHORT).show();
  80.                 }
  81.  
  82.                 _action.setText("ROLL");
  83.  
  84.             }
  85.  
  86. //            if (_async1._next == _async2._next && _async2._next == _async3._next) {
  87. //                Toast.makeText(getBaseContext(), "Menang Banyak", Toast.LENGTH_SHORT).show();
  88. //            } else if (_async1._next == _async2._next || _async2._next == _async3._next || _async1._next == _async3._next) {
  89. //                Toast.makeText(getBaseContext(), "Menang", Toast.LENGTH_SHORT).show();
  90. //            } else {
  91. //                Toast.makeText(getBaseContext(), "Kalah", Toast.LENGTH_SHORT).show();
  92. //            }
  93.  
  94.             inAction = !inAction;
  95.  
  96.         }
  97.     }
Add Comment
Please, Sign In to add comment