From 3273adb6bba3bd74c9393cb8e3ebc5bbdb2745cd Mon Sep 17 00:00:00 2001 From: kriskapa88057 Date: Wed, 2 Nov 2022 15:05:16 +0100 Subject: [PATCH] git test --- .idea/.gitignore | 3 + .idea/misc.xml | 6 + .idea/modules.xml | 8 ++ .idea/uiDesigner.xml | 124 ++++++++++++++++++ Interaktion Projekt.iml | 11 ++ .../Interaktion Projekt/GameClass.class | Bin 0 -> 483 bytes .../RockPaperScissors.class | Bin 0 -> 2482 bytes src/GameClass.java | 6 + src/RockPaperScissors.java | 76 +++++++++++ 9 files changed, 234 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/uiDesigner.xml create mode 100644 Interaktion Projekt.iml create mode 100644 out/production/Interaktion Projekt/GameClass.class create mode 100644 out/production/Interaktion Projekt/RockPaperScissors.class create mode 100644 src/GameClass.java create mode 100644 src/RockPaperScissors.java diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..104cfef --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..f605a9a --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Interaktion Projekt.iml b/Interaktion Projekt.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Interaktion Projekt.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/out/production/Interaktion Projekt/GameClass.class b/out/production/Interaktion Projekt/GameClass.class new file mode 100644 index 0000000000000000000000000000000000000000..50e79d6e482901e2647829055cec450031ea266d GIT binary patch literal 483 zcmZuuJ5Iwu5Pjn~F?O6kgimPb2n9JnA}At(kjzH}MM6{?V}(r|JF*>4z)5JRsX!DQ zfb&ox1k9Q!G^{i;J2UUS8STD(y}Sb0$EF1h83VeFEOLbMNZg8+FM?s~bTIPVgpljV zKqh;H%yzSHVF{)I%SK+oE9ap*J`+bWwG!zd;g(JVL=6VE__V5(c!7cn>VZg}kx zN{$S?li6h8MHgb=bEWEpuJHRJk}97U_2fn}Deo*4+AJ{$>LQteV)jN4Tcumzi6NF5EN-iUpXvld6< znB92-J*Mpvd({S8nZ5lBKm}FKOw_Q<6-B;eF(q2fbQ)#j9`-YgJEDj0ccqkpQc@oS k=*-ThYW0*;!V2oCZWXIoW5ha}3GEXaeXuxTg9{oOKeI7g%m4rY literal 0 HcmV?d00001 diff --git a/out/production/Interaktion Projekt/RockPaperScissors.class b/out/production/Interaktion Projekt/RockPaperScissors.class new file mode 100644 index 0000000000000000000000000000000000000000..7f80f060679a68cd7a5805bc025ce4a5a93bffd9 GIT binary patch literal 2482 zcmaKuS##576oy|Vj%6##=8y%4Qiq0+4P2J6#3>X^0fPfH4oL&0MNvee*pXaG4)8mA z)2qTAH(az_Kn7;|13J@x)amp+vg{-^(+kVra+c?u@0?Hi^PdlY0JwtZ8rsmVBBrAQ zaRt3w#*UG#7|ura-rAOB1`6WywqpmE6|_%GE^A02sY27y30*o|c4 z1^prHL2(6YRg^1^1k@VN-^qip3}$25W!JJ{sN4-7|AH~uO3)_77-FsI@Qk2K6iEwC%ul4&@ObQoyf;L+c(oAqz5K)3PT*fz2mp2p)M_!rK{UVaJTM8ymXP&xVMk1ccoC(Ka%rlv@ z;iM7uTt;l()^SIQP<5>5LBR=BEHn;3q+B$db$44s5$*E0FXG=uHB(?>^X@uJx~FJ6 z*4^6nn&mASYZb1fimqu?mJQFAd9)Y{Hf?6Dzu3|#ITCm^=cchu-7Yigm@qm83LPbD zjSk^{DKO0Pf>Djkb~X2;PsDdigQ)ni5mwmG^}Y#PtlpfVtGarJEu|!wEr&(Sn73i^ zlp-Jda>PBYPfeeoq{>hAos;RHWqCYh!y6 z*v^hywz75NdKKO<%)s?tDEMW6{Y8Rxqqlf&70Vwhx^B5v&9!D^-^u~Sr59D}6XK8d z$=5H#-2QtgGLbhbm69D;yboLjozlPNCNI5=lE6=lyxGFhD(|9#G(o;%_`c<jHRyWzLdVX(~UVv=|-Ug__$%*ZjyXdRNlBIJA=HaA?n7nmXb-Mhw0(&;^Y*d?$uz zU3?7EP7H_e9acF@pcfB0V$sWe&3{4tEAm!OkGw+nTa2Ve-{Fhbc$|*CLSm%jC5F-+ zGK#-MS33R*{Uh861t&wnbM@_*2y#1A=@RAs5l%zF=}@p!jGyFC0%#8ta*R+QRtNg{ zOyLv;aEbUU#9QM9wuPh3K!9=-h>YriJfgM^tv8uWYVzYtQ(kdVXun3G&8D(N0ZOJ$ z7hmIu@Fr7dIqVbQWNMbfc-V@WD5;y0tam8n(r>t1uk#eE4!Fu_uaO~-VO($e9j1&Np5&qj29H_l zksmsdpM}Uz-$xWz-{bC`saX6S?#++vneV0uaEoCUXySI$w6uVUb?)`hi4;9QE?{xq bhNsxze>X>)Ty?@{6&}|#&VAJI42S;(n;9Hi literal 0 HcmV?d00001 diff --git a/src/GameClass.java b/src/GameClass.java new file mode 100644 index 0000000..376fa1e --- /dev/null +++ b/src/GameClass.java @@ -0,0 +1,6 @@ +public class GameClass { + + public static void main(String[] args){ + for (int i = 0; i < 7; i++) RockPaperScissors.runGame(); + } +} diff --git a/src/RockPaperScissors.java b/src/RockPaperScissors.java new file mode 100644 index 0000000..a9fb9ef --- /dev/null +++ b/src/RockPaperScissors.java @@ -0,0 +1,76 @@ +import java.util.Scanner; +import java.util.Random; + +public class RockPaperScissors { + + public static void runGame() { + int computerInput = letComputerChoose(); + int userInput = letUserInput(); + convertToWordUser(userInput); + convertToWordComputer(computerInput); + checkResults(computerInput, userInput); + } + + public static void checkResults(int computerInput, int userInput) { + + if (computerInput == userInput) { + System.out.println("Draw!"); + } else if (computerInput == 1 && userInput == 2 + || computerInput == 2 && userInput == 3 + || computerInput == 3 && userInput == 1) { + System.out.println("You win!"); + + } else if (computerInput == 2 && userInput == 1 + || computerInput == 3 && userInput == 2 + || computerInput == 1 && userInput == 3) { + System.out.println("Computer wins!"); + } else { + System.out.println("Incorrect inputs: round void"); + } + } + + private static String convertToWordUser(int userInput) { + + String userInputWord = ""; + + if (userInput == 1) { + userInputWord = "Rock"; + } else if (userInput == 2) { + userInputWord = "Paper"; + } else if (userInput == 3) { + userInputWord = "Scissors"; + } else { + userInputWord = "a false option"; + } + System.out.println("You chose " + userInputWord); + return userInputWord; + } + + public static String convertToWordComputer(int computerInput) { + String computerInputWord = ""; + + if (computerInput == 1) { + computerInputWord = "Rock"; + } else if (computerInput == 2) { + computerInputWord = "Paper"; + } else if (computerInput == 3) { + computerInputWord = "Scissors"; + } + System.out.println("Computer chose " + computerInputWord); + return computerInputWord; + } + + public static int letUserInput() { + int userInput; + Scanner input = new Scanner (System.in); + System.out.println("1 for Rock, 2 for Paper, 3 for Scissors: "); + userInput = input.nextInt(); + return userInput; + } + + public static int letComputerChoose() { + Random rgen = new Random(); + int computerInput = rgen.nextInt(1, 3); + return computerInput; + } +}