document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. import java.io.IOException;
  2. import java.util.Random;
  3. import java.util.Scanner;
  4.  
  5.  
  6. public class PLAY {
  7.  
  8. private static Scanner scanner;
  9.  
  10. public static void main(String[]args) throws IOException {
  11. int ulang = 3;
  12. System.out.println("Welcome to Simple RE7 Card Game");
  13. System.out.println("If you lose your points will be reduced");
  14. System.out.println("You have two chances to exchange the cards");
  15. FRONT [] playerCom = new FRONT[2];
  16. FRONT [] player1 = new FRONT[2];
  17.  
  18. System.out.println("Oppenent draw card");
  19. untuk_delay(playerCom);
  20.  
  21. System.out.println("You draw card");
  22. untuk_delay(player1);
  23.  
  24. Random tandRandom = new Random();
  25. player1[0].kartunya();
  26. player1[1].kartunya();
  27. playerCom[0].kartunya();
  28. playerCom[1].kartunya();
  29.  
  30. while (true) {
  31. System.out.println("Your card: ");
  32.  
  33. player1[0].currentKartu();
  34. player1[1].currentKartu();
  35. boolean choose = tandRandom.nextBoolean();
  36. int kartuke = tandRandom.nextInt(1);
  37.  
  38. System.out.println();
  39. System.out.println("Which card you want to exchange? (1/2/0 to stop)");
  40.  
  41. ulang--;
  42.  
  43. if(ulang == 0) {
  44. finish(playerCom, player1);
  45. break;
  46. }
  47.  
  48. scanner = new Scanner(System.in);
  49. int temp = scanner.nextInt();
  50.  
  51. if(temp != 0) {
  52. player1[temp-1].kartunya();
  53. if(choose == true) {
  54. playerCom[kartuke].kartunya();
  55. }
  56. }else {
  57. finish(playerCom, player1);
  58. break;
  59. }
  60. }
  61. }
  62.  
  63. static void untuk_delay(FRONT [] player) {
  64. try {
  65. Thread.sleep(1000);
  66. } catch (InterruptedException e) {
  67. e.printStackTrace();
  68. }
  69.  
  70. for (int i = 0; i < player.length; i++) {
  71. player[i] = new FRONT();
  72. }
  73. }
  74.  
  75. static void finish(FRONT[] playerCom, FRONT[] player1) {
  76. int jumlah_kartu1=0, jumlah_bunga1=0, jumlah_kartu2=0, jumlah_bunga2=0;
  77. System.out.println("Yours:");
  78. for (int i = 0; i < playerCom.length; i++) {
  79. player1[i].currentKartu();
  80. jumlah_kartu1 += player1[i].getAngka();
  81. jumlah_bunga1 += player1[i].getBunga();
  82. }
  83. System.out.println("Computer's:");
  84. for (int i = 0; i < playerCom.length; i++) {
  85. playerCom[i].currentKartu();
  86. jumlah_kartu2 += playerCom[i].getAngka();
  87. jumlah_bunga2 += playerCom[i].getBunga();
  88. }
  89. System.out.println("Statistic: ");
  90. System.out.println("Yours: " + "Number: " + jumlah_kartu1 + " Interest: " + jumlah_bunga1);
  91. System.out.println("Computer's: " + "Number: " + jumlah_kartu2 + " Interest: " + jumlah_bunga2);
  92. if((jumlah_kartu1+jumlah_bunga1) < (jumlah_kartu2+jumlah_bunga2)) {
  93. System.out.println("You lose, your points will be reduced!!!");
  94. }else if((jumlah_kartu1+jumlah_bunga1) == (jumlah_kartu2+jumlah_bunga2)) {
  95. System.out.println("Balance, your point will not be reduced!!!");
  96. }else {
  97. System.out.println("You win, CONGRATULATIONS you get points!!!");
  98. }
  99. }
  100. }
');