From a87f3c64d4efbdad7321ba059fd2aa8c74a725a5 Mon Sep 17 00:00:00 2001 From: Blomsgaard <70745304+Blomsgaard@users.noreply.github.com> Date: Thu, 7 Oct 2021 13:38:01 +0200 Subject: [PATCH 01/13] Add files via upload --- Server/Mini-Projekt.iml | 11 ++ Server/out/production/Mini-Projekt/Card.class | Bin 0 -> 499 bytes .../production/Mini-Projekt/ProblemCard.class | Bin 0 -> 468 bytes .../production/Mini-Projekt/ProblemText.class | Bin 0 -> 3845 bytes .../out/production/Mini-Projekt/Server.class | Bin 0 -> 3419 bytes .../Mini-Projekt/ServerRunnable.class | Bin 0 -> 1847 bytes .../Mini-Projekt/SolutionCard.class | Bin 0 -> 471 bytes .../Mini-Projekt/SolutionText.class | Bin 0 -> 3928 bytes Server/src/Card.java | 11 ++ Server/src/ProblemCard.java | 10 ++ Server/src/ProblemText.java | 70 +++++++++++++ Server/src/Server.java | 70 +++++++++++++ Server/src/ServerRunnable.java | 34 ++++++ Server/src/SolutionCard.java | 10 ++ Server/src/SolutionText.java | 97 ++++++++++++++++++ 15 files changed, 313 insertions(+) create mode 100644 Server/Mini-Projekt.iml create mode 100644 Server/out/production/Mini-Projekt/Card.class create mode 100644 Server/out/production/Mini-Projekt/ProblemCard.class create mode 100644 Server/out/production/Mini-Projekt/ProblemText.class create mode 100644 Server/out/production/Mini-Projekt/Server.class create mode 100644 Server/out/production/Mini-Projekt/ServerRunnable.class create mode 100644 Server/out/production/Mini-Projekt/SolutionCard.class create mode 100644 Server/out/production/Mini-Projekt/SolutionText.class create mode 100644 Server/src/Card.java create mode 100644 Server/src/ProblemCard.java create mode 100644 Server/src/ProblemText.java create mode 100644 Server/src/Server.java create mode 100644 Server/src/ServerRunnable.java create mode 100644 Server/src/SolutionCard.java create mode 100644 Server/src/SolutionText.java diff --git a/Server/Mini-Projekt.iml b/Server/Mini-Projekt.iml new file mode 100644 index 00000000..9465dd86 --- /dev/null +++ b/Server/Mini-Projekt.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Server/out/production/Mini-Projekt/Card.class b/Server/out/production/Mini-Projekt/Card.class new file mode 100644 index 0000000000000000000000000000000000000000..5849f560e190d6d454d01f34e460bc923f0f0a1c GIT binary patch literal 499 zcmZuuO;5r=5PjQETB=|L^y;m}M1FwE#l%yi2MG72Y;Z|!lTwU7OB0QW2Y-M+$~aR< zz{q80cJ{q_Z+5?bKED85uM-qM)AZ$ z1D*>%Kofz0btB7}KqI9zR?mbElkJ32RqA|x$*^Lk1X_vC)!piGs>-pPX4DCjB9+-h zmYUC-rd2)YCFv$SoY>8|s<>PWbfS2lM02?d>PG)D@kGEM6{|8;x0=O09(uuctutE7 zpa&5YX)&rys_8{29?)q(Sx~n79}urp7&xTJ*Gy_r4Aua&aa8w098>2n`3>$1UG9?Y qz2pwM8}g9Q?9Az(zr)>1^S=QedGzZEy)|kh&(?SkcHOHLPksS=r%^xv literal 0 HcmV?d00001 diff --git a/Server/out/production/Mini-Projekt/ProblemCard.class b/Server/out/production/Mini-Projekt/ProblemCard.class new file mode 100644 index 0000000000000000000000000000000000000000..1ab7675a1a0f5e287c1aac6d9bf0b300da367dd8 GIT binary patch literal 468 zcmZut%Syvg6r7W!O`4<+W9xI}uB~7`pz22GDu~e1{cU@xSK0(_Q}MHOQ^AEF;75t) zHbDwX;E)++=FB}`-yfd_!4?M-}msJZY%1PBSi zgU+T)xhj;wTIS|&EMIa$r<**9XAv(&x`;=)R_S6;1T;c4(PH;vU*GQb{u)e+Y%U4S zM5Xe6vzkgh7QB)WCD}|YCqgTOOVY_7)tXRG_KFP%-t4zl^xqOM&x(cwf0S+XOb(UV z(b|i-GOxh}AHd>sfhX~uLY@bVhKvpG_uoPN%PriuohIVhfX&l}!(WX(hm4L2HQMMf rVjnZdoJBZ6tIUjd7^w8OsK2tvf{Cj#4X$Bg%z74-F@#e_7S4VE-&0r0 literal 0 HcmV?d00001 diff --git a/Server/out/production/Mini-Projekt/ProblemText.class b/Server/out/production/Mini-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s()48ml(&t+j zuzy;gZ(hj$8GXKe3HxVtj_Y5_{y80VUcvr(o$I`ceM&3mHSAx|dCqIuzo=(9Z(#qD zp6$Gu{mWWAZ)N|Ap5y!y_OI%Y^EURc>AB8Vuzy|8bH0lG8#>>47yCDLf%CQO-_rA) zuV;T=FL2(?{%u|8d<*+`bdmGz?BCVJ&Udh%(Iw7zv42l5biRlE`+AY{tJr^_OP$Bq zf2hlx?`8jyE_Xi2{$pL?e2D!gda?6i_MhrX=Lgt-rmLKfvHx5zaek2f7rNT{VfJ6@ z8t2!u|4N6Q-^l)J9dUj$`)_ou^IO=@>N@AQvHw=rJHMU%ce=s(o$SBYjn408|ATIF zelPnUb+hyP+5e=MI-g+wvu<(z&?)@o1Rk*o>!GK=l2R zP2V08LzMSN5TyUhb1^|#dmMR~q+Fh&9%rC&7IP>@Ln4T|q6qUu1o@&31!4o{i``ft zhEOPuphz4;v6w)KIF5y45{twXO2rwJiL)pd=TPAVvDhm@r58b!*M=qD22^{yQR59E z>>WYGJBC_s0(IVT)O(X?@TSn{ok5d#7R}x{EDZ$F5-37zAcAFqHhMPC-w#AU*xkhw Gng0g|Y$LS* literal 0 HcmV?d00001 diff --git a/Server/out/production/Mini-Projekt/Server.class b/Server/out/production/Mini-Projekt/Server.class new file mode 100644 index 0000000000000000000000000000000000000000..161d29d63acfbc0aeb34b5baeafe37a2bccea561 GIT binary patch literal 3419 zcmcImYjYb{8Geo>dF9PImhH%ClG;%dr?q3J3ZXTPGop!-25e@;0d&jnYQVT3q%G6 zXBET+x_wZ^Gp+Q)uB)%*%(ACKK}5w4XbRdj>_mrvmUk?o9DByNEH_%!t%^|==o}cl zm4W5SCEpP+#|4K+I8kFVfFI5&6EQ9pcEcXeP+-3s1hcz6*{Q}Xl`5a*k z$7CCh;vEW(X?Q0dXo_Bbt?U^qL^%~wpA5J#o%FO%rRN&@3e8q9qTyY5h`2>V;sz$e zwAScQFuF-W5S-%})0jT=H|{wB`zqdz_b7N+!y}UaAW51}q?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-Projekt/ServerRunnable.class new file mode 100644 index 0000000000000000000000000000000000000000..0c22e9a0cb9413b0f6e1c28e3f5b65b4387a0a75 GIT binary patch literal 1847 zcmaJ>>r&fB6#f>wmQe*JCWK4c!~}4`q;a9?1#HsBBs8=J(%5lI)7x6!0R>s|NNXm% zN&5u(olXNYVWtnz2k5i(M<>l$NdXHo9gn45opZkPo$Ft(Uj7MS1*VQZBs3%qyn__O z&=bDTi#B(5id)Sm!jufDvgKIv7DHlouF;P)`ZeeV-i5(1SQFm9@E&v>hc|7(V3@Wg z99eVCJwdh?ssWxOWHJ0yN@I`#3TDW_1!Ng?KftJqr(}=~4FUo+=~>QBsUH_HqT!N( zQH;eH)((6r+CnH z+k8)~x{k@^BTMem$(P)bKEw2Eh$0V+4m@+Vp8HVA&Tbu`j)={i%hloa) zy+O`3G<-lr-k1_izV39oQ5ZVrP|z@M;5t5J$ehV4MYtnmk3J#IMns86kD#O@kD@B} zM+{>Tkuxfa%OXj8xomZ1jLb~~pWstsLVkN?3iQ-*uY^1=;B)19iDCTIb4*9MF1^WM zke|CxP0^8->*!d)@4qn-{tU%$BqLvqz^ zQU7MDmLoR1?WXYRVMk}HuF35N_bhdfJ|^X^Mcpw}jrTuMkGfd~-JI~cRPTP%bsQQc z(PCiV(~PvJxNDxK+xF#Ouv?vY{$dXGCTTlmve*WK%OO6LpH^Cf0jKj?_Js6Xz}54TrrS|f;6 zZre3W3R*=!FihUgg)1w!%l%wa2q$+^t{j)kOs9gaQ~kVEoBO`-HT=vlb1w9^MWlf; zdFB6AX}^Zy(+)|~E@t?Go_%V)(t_$!D>8U98l2lCt;<$!cHjjv zg?V+nPN(OA&8pHtik=3NYH`yqg8|y7gR}uNxI>a$h=jXXqnpxKo@qtX=_~TB7~La` z(DUDUe82RnOAJ7gldxRSs$5@E2A0Oef&C9$>Qam!+ao}-w;7#4}e5^*e3$F1NhWneO3eUq|r5i?lF z*Mu{LOZWy=;<^Y88`vbo72>&t`+=8A6y3K0e)1J{`drNgL5Ai>^dBQ8eD>NCyOP)y;hmhw*-4Iocr+5sKXZsAP8cb zryH&Eth5H}M4P`^@}dd-LG&n}Wthrr6;5@bvemduXbQB@CIqXhzc(2E9WXWWWkP60 zDogG+Pm83O$wkUaH_Bs~&Sjwt-;0iZP-{Xnsx})Fy!f|Q_rEQk&dZ7ff0}QKIGHH3 zq*KkgGVj3!-@xLFfsy!Bg0aJF!rbWo=p8h=+@k)r^K==Tuo-PQ{55#ykl9h`Mh|^v rJjcp0XAw@&-e-n84%9|l9K5p0f{Alk2G=k#W<4ABF@#fQ7S4VEIu==R literal 0 HcmV?d00001 diff --git a/Server/out/production/Mini-Projekt/SolutionText.class b/Server/out/production/Mini-Projekt/SolutionText.class new file mode 100644 index 0000000000000000000000000000000000000000..4d9390f9042cfc28b31cf558b3333ad0afa26a4f GIT binary patch literal 3928 zcmZvf30PFu8HT@e2bjZnfa53#h&mz&GYE*NX~Yc?e#xhMHOOf8?DV#Xk^=Dtyy6{+h%JE6k6G?w6;iLG20evuTZ$0ZL765g{5q9 zYs(c@ux+!}uCR)2yS3E{oowCKu25LZw!_+bg$-;wt!-4;#MWc&N`)-{Q)YkcK`_bT-H$`wy4?D3ULzE>gTE7yFVLfTg@ zdPX7ZD_8y13M0O9*>ehGzH;4Pqj11iF8m>dYklR)zgFRTU%B+JQ@GJruKnv34*SZ* ze}lp;zH;^7s4(s;m;X%)xBJTVf3w1!zVZaTMd5B=c?RC9aIddC1#eTh-&dZ4w<|p0 zD^J2Z6dv-GXW^X+@4_Pj!J6*&uI-(1fs)5ciuVNZh{AjEK7stcbT*TuMP486 z8cgg@G^Z1pf#%J*(qqZZduS!rPdK|H zofsW$o3J6C8%bpb+9qDX4#49-uJ8nmK*7>fCY4(*P&RQWcjme%SLR8Dr|>kr`J)rw ze1Y)Amy*br_z1mqJN9PN$;fb`Z(k(4Co-5!rw{ff6PeM-*l=X%U?edznheo$ea7C! zM+NFHb@7Xbk9JEGN_>n$r9Cp7&C-vAlK2GW!^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7vsJhQ=98##!np z=P-p{(W#;mr6Pthu>{k^dX$S@s1Spw6o)WfjH5~%!3=Q}GsQ{F5~mRnXE0lwMYTAG zIbH}gUL|V180LCQQ0J{jy|)WdZxAu>5E{I3%=3<*(L0JJ?Dr>7#0VXP>1kbKbRyGJ)b9v{s&2>Gs6G? literal 0 HcmV?d00001 diff --git a/Server/src/Card.java b/Server/src/Card.java new file mode 100644 index 00000000..bc349dd7 --- /dev/null +++ b/Server/src/Card.java @@ -0,0 +1,11 @@ +public abstract class Card { + private String cardText; + + public String getCardText() { + return cardText; + } + + public void setCardText(String cardText) { + this.cardText = cardText; + } +} diff --git a/Server/src/ProblemCard.java b/Server/src/ProblemCard.java new file mode 100644 index 00000000..d4100ee6 --- /dev/null +++ b/Server/src/ProblemCard.java @@ -0,0 +1,10 @@ +public class ProblemCard extends Card { + + public ProblemCard(String cardText){ + this.setCardText(cardText); + } + + public String toString() { + return getCardText(); + } +} diff --git a/Server/src/ProblemText.java b/Server/src/ProblemText.java new file mode 100644 index 00000000..07ba01d6 --- /dev/null +++ b/Server/src/ProblemText.java @@ -0,0 +1,70 @@ +public enum ProblemText { + A("Maybe she's born with it, maybe it's ____."), + B("Old McDonald had a _____, Ia ia ohh"), + C("I'm going on a cleanse this week. Nothing but kale juice and ____."), + D("I got 99 problems but ____ ain't one."), + E("Hey guys, welcome to Chili's! Would you like to start the night off right with ____?"), + F("What will always get you laid?"), + G("A romantic, candlelit dinner would be incomplete without ____."), + H("White people like ____."), + I("What's that smell?"), + J("I get by with a little help from ____."), + K("Airport security guidelines now prohibit ____ on airplanes."), + L("The school trip was completely ruined by ____."), + M("Oi! Show us ____!"), + N("Science will never explain ____."), + O("During his midlife crisis, my dad got really into ____."), + P("Money can't buy me love, but it can buy me ____."), + Q("Future historians will agree that ____ marked the beginning of America's decline."), + R("When I am a billionaire, I shall erect a 20-meter statue to commemorate ____."), + S("When all else fails, I can always masturbate to ____."), + T("My plan for world domination begins with ____."), + U("What left this stain on my couch?"), + V("Introducing X-treme Baseball! It's like baseball, but with ____!"), + W("Well if you'll excuse me, gentlemen, I have a date with ____."), + X("Just once I'd like to hear you say \"Thanks, Mom. Thanks for ____.\""), + Y("Click Here for ____!!!"), + Z("Just saw this upsetting video! Please retweet!! #stop ____"), + AA("In the new Disney Channel Original Movie, Hannah Montana struggles with ____ for the first time."), + AB("I'm not going to lie. I despise ____. There, I said it."), + AC("All classes today are canceled due to ____."), + AD("Excuse me, waiter. Could you take this back? This soup tastes like ____."), + AE("It's beginning to look a lot like ____."), + AF("____: Achievement unlocked."), + AG("My body, my voice! ____, my choice!"), + AH("Donald Trump's first act as president was to outlaw ____."), + AI("You can't wait forever. It's time to talk to your doctor about ____."), + AJ("What's wrong with these gorillas?"), + AK("You say tomato, I say ____."), + AL("America is hungry. America needs ____."), + AM("Nothing says \"I love you\" like ____."), + AN(""), + AO(""), + AP(""), + AQ(""), + AR(""), + AS(""), + AT(""), + AU(""), + AV(""), + AW(""), + AX(""), + AY(""), + AZ(""); + + + + + private final String problemText; + + //Constructor for the solutiontexts + private ProblemText(String problemText){ + this.problemText = problemText; + } + + //A method to acces the String for of the list and not the label + public String printProblemText(){ + return problemText; + } + +} diff --git a/Server/src/Server.java b/Server/src/Server.java new file mode 100644 index 00000000..1a37ac16 --- /dev/null +++ b/Server/src/Server.java @@ -0,0 +1,70 @@ +import java.io.IOException; +import java.net.ServerSocket; +import java.net.Socket; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; + +public class Server { + private static int port = 6969; + + public static void main(String[] args) { + + //Creates a deck of solution cards and adds them in an arraylist + ArrayList solutionDeck = new ArrayList<>(); + for(SolutionText solutionText : SolutionText.values()){ + solutionDeck.add(new SolutionCard(solutionText.printSolutionText())); + } + + //Creates a deck of problem cards and adds them in an arraylist + ArrayList problemDeck = new ArrayList<>(); + for(ProblemText problemText : ProblemText.values()){ + solutionDeck.add(new SolutionCard(problemText.printProblemText())); + } + + //Shuffles the two decks + Collections.shuffle(solutionDeck); + Collections.shuffle(problemDeck); + + //Printing of the deck to check if it works + for(int i = 0; i < problemDeck.size();i++) + System.out.println(problemDeck.get(i).toString()); + + //Printing of the deck to check if it works + for(int i = 0; i < solutionDeck.size();i++) + System.out.println(solutionDeck.get(i).toString()); + + new Thread( () -> { + try { + ServerSocket serverSocket = new ServerSocket(port); + System.out.println("Server has started at:" + new Date() + '\n'); + + //Counts the numbers of clients + int numberOfClient = 0; + + while(true){ + Socket connectToCLient = serverSocket.accept(); + numberOfClient++; + + //Displays information about the connected clients + System.out.println("Client has connected at:" + new Date() + '\n'); + System.out.println("Total number of client connected: " + numberOfClient + '\n'); + + new Thread( + new ServerRunnable(connectToCLient, "Multithreaded Server") + ).start(); + + + } + + + } catch (IOException e) { + e.printStackTrace(); + } + + }).start(); + + } + +} diff --git a/Server/src/ServerRunnable.java b/Server/src/ServerRunnable.java new file mode 100644 index 00000000..de79eea6 --- /dev/null +++ b/Server/src/ServerRunnable.java @@ -0,0 +1,34 @@ +import java.io.DataInput; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.net.Socket; +import java.util.Date; + +public class ServerRunnable implements Runnable{ + private Socket clientSocket = null; + private String serverText = ""; + + //Constructer for the class + public ServerRunnable(Socket clientSocket, String servertext){ + this.clientSocket = clientSocket; + this.serverText = servertext; + } + + @Override + public void run() { + try{ + System.out.println("A client has been connected at:" + new Date() + '\n'); + boolean connected = true; + + DataInputStream dataFromUser = new DataInputStream(clientSocket.getInputStream()); + DataOutputStream dataToUser = new DataOutputStream(clientSocket.getOutputStream()); + + while(connected){ + //Stuff happens here that makes the program work + } + + } catch (Exception e) { + e.printStackTrace(); + } + } +} diff --git a/Server/src/SolutionCard.java b/Server/src/SolutionCard.java new file mode 100644 index 00000000..18391b08 --- /dev/null +++ b/Server/src/SolutionCard.java @@ -0,0 +1,10 @@ +public class SolutionCard extends Card { + + public SolutionCard(String cardText){ + this.setCardText(cardText); + } + + public String toString(){ + return getCardText(); + } +} diff --git a/Server/src/SolutionText.java b/Server/src/SolutionText.java new file mode 100644 index 00000000..577ba705 --- /dev/null +++ b/Server/src/SolutionText.java @@ -0,0 +1,97 @@ +//A class to handle the text fields for the solution cards +public enum SolutionText { + A("Whole pack of jellybeans up my arse"), + B("A poopoo"), + C("Midgets riding a donkey"), + D("Eating horse poop"), + E("Mad cuz bad"), + F("Donald Trump"), + G("Dead parents"), + H("People who like James Corden"), + I("A donkey"), + J("The crippling fear that a duck is watching you"), + K("The finale of Game of Thrones"), + L("Walt Disneys frozen head"), + M("A raccoon in the trash"), + N("Goat milk"), + O("A dominatrix"), + P("Semen"), + Q("Porn addiction"), + R("Bees?"), + S("69 (nice)"), + T("Dancing queen"), + U("Big Time Rush"), + V("Magnum condoms"), + W("A crossword you can't solve"), + X("Mom calling during sex"), + Y("Saturday Night Live"), + Z("Pogo the Clown"), + AA("White people"), + AB("Black people"), + AC("Jennifer Lopez's booty"), + AD("The offside rule"), + AE("Karens"), + AF("Pickles in Koolaid"), + AG("Getting drunk with strangers"), + AH("Having a deep conversation with a stranger"), + AI("Poseidon's kiss"), + AJ("The Greek Pantheon"), + AK("Getting kicked so hard in the nuts, you lose your sense of vison"), + AL("Communism"), + AM("Proud nerds"), + AN("Regretting a tattoo"), + AO("Medialogy"), + AP("K-pop"), + AQ("Psychotic murder spree"), + AR("My celebrity crush"), + AS("Getting horny by 2D chicks"), + AT("The second coming of Christ"), + AU("Farting and a little bit of poop comes out"), + AV("The casting couch"), + AW("The complete Friends box-set"), + AX("Niel Patrick Harris"), + AY("An Oedipus complex"), + AZ("Beastiality"), + AAA("IM BATMAN!"), + AAB("Jeff Bezos penis rocket"), + AAC("Diversity"), + AAD("Asians"), + AAE("Pamela Anderson's... assets"), + AAF("The Nirvana baby"), + AAG("Michelle Obama"), + AAH("Killing it on the dancefloor"), + AAI("Seeing babies being electrocuted"), + AAJ("Being born"), + AAK("Buttsex"), + AAL("The moon landing"), + AAM("Having a colonoscopy"), + AAN("Sitting on the toilet and regretting the chili from the night before"), + AAO("Omegle"), + AAP("A horny elk"), + AAQ("Movie theaters"), + AAR("Cheese?"), + AAS("360 no scope"), + AAT("Blood"), + AAU("Cookies"), + AAV("Mimes"), + AAW("Pokemon being real"), + AAX("Getting stabbed"), + AAY("HELP!"), + AAZ("The idea that killing someone annoying should be ok"); + + + + + private final String solutionText; + + //Constructor for the solutiontexts + private SolutionText(String solutionText){ + this.solutionText = solutionText; + } + + //A method to acces the String for of the list and not the label + public String printSolutionText(){ + return solutionText; + } + +} From 82943708fd31e3ac9a606cede2b23212bcc109de Mon Sep 17 00:00:00 2001 From: SlyCooper0204 <72729940+SlyCooper0204@users.noreply.github.com> Date: Thu, 7 Oct 2021 14:10:24 +0200 Subject: [PATCH 02/13] Poopoo --- .idea/.gitignore | 3 +++ .idea/misc.xml | 6 ++++++ .idea/modules.xml | 8 ++++++++ .idea/runConfigurations.xml | 10 ++++++++++ .idea/vcs.xml | 6 ++++++ MED305.iml | 11 +++++++++++ Server/src/ServerRunnable.java | 6 +++--- 7 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/runConfigurations.xml create mode 100644 .idea/vcs.xml create mode 100644 MED305.iml diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..26d33521 --- /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 00000000..abf76483 --- /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 00000000..a09fa6f9 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 00000000..797acea5 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..35eb1ddf --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/MED305.iml b/MED305.iml new file mode 100644 index 00000000..c60d140b --- /dev/null +++ b/MED305.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Server/src/ServerRunnable.java b/Server/src/ServerRunnable.java index de79eea6..ef334e14 100644 --- a/Server/src/ServerRunnable.java +++ b/Server/src/ServerRunnable.java @@ -8,10 +8,10 @@ public class ServerRunnable implements Runnable{ private Socket clientSocket = null; private String serverText = ""; - //Constructer for the class - public ServerRunnable(Socket clientSocket, String servertext){ + //Constructor for the class + public ServerRunnable(Socket clientSocket, String serverText){ this.clientSocket = clientSocket; - this.serverText = servertext; + this.serverText = serverText; } @Override From fb25957be85798c1b6724e12a67f2d673c153b43 Mon Sep 17 00:00:00 2001 From: SlyCooper0204 <72729940+SlyCooper0204@users.noreply.github.com> Date: Thu, 7 Oct 2021 14:12:40 +0200 Subject: [PATCH 03/13] Poopoo --- Server/src/ServerRunnable.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Server/src/ServerRunnable.java b/Server/src/ServerRunnable.java index ef334e14..0cc946bc 100644 --- a/Server/src/ServerRunnable.java +++ b/Server/src/ServerRunnable.java @@ -25,6 +25,7 @@ public void run() { while(connected){ //Stuff happens here that makes the program work + //Github work ploz } } catch (Exception e) { From b0429401c53d2a6b50154d66b942abceb9e7fdd5 Mon Sep 17 00:00:00 2001 From: Blomsgaard <70745304+Blomsgaard@users.noreply.github.com> Date: Thu, 7 Oct 2021 14:28:25 +0200 Subject: [PATCH 04/13] Added new class for handling a game --- Server/src/HandleAGame.java | 2 ++ Server/src/ServerRunnable.java | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 Server/src/HandleAGame.java diff --git a/Server/src/HandleAGame.java b/Server/src/HandleAGame.java new file mode 100644 index 00000000..92dca639 --- /dev/null +++ b/Server/src/HandleAGame.java @@ -0,0 +1,2 @@ +public class HandleAGame { +} diff --git a/Server/src/ServerRunnable.java b/Server/src/ServerRunnable.java index 0cc946bc..dfc9292e 100644 --- a/Server/src/ServerRunnable.java +++ b/Server/src/ServerRunnable.java @@ -25,7 +25,13 @@ public void run() { while(connected){ //Stuff happens here that makes the program work - //Github work ploz + boolean gameCreated = false; + gameCreated = dataFromUser.readBoolean(); + + if(gameCreated = true){ + + } + } } catch (Exception e) { From 398a65ac1dfc74eff61ddc8559ba0e1f2cf6c80c Mon Sep 17 00:00:00 2001 From: Blomsgaard <70745304+Blomsgaard@users.noreply.github.com> Date: Thu, 7 Oct 2021 14:37:13 +0200 Subject: [PATCH 05/13] Added a class for games --- Server/src/Game.java | 7 +++++++ Server/src/ServerRunnable.java | 5 +++++ 2 files changed, 12 insertions(+) create mode 100644 Server/src/Game.java diff --git a/Server/src/Game.java b/Server/src/Game.java new file mode 100644 index 00000000..e767c3f7 --- /dev/null +++ b/Server/src/Game.java @@ -0,0 +1,7 @@ +public class Game { + private String gameName; + + Game(String gameName){ + this.gameName = gameName; + } +} diff --git a/Server/src/ServerRunnable.java b/Server/src/ServerRunnable.java index dfc9292e..f822ff93 100644 --- a/Server/src/ServerRunnable.java +++ b/Server/src/ServerRunnable.java @@ -2,6 +2,7 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.net.Socket; +import java.util.ArrayList; import java.util.Date; public class ServerRunnable implements Runnable{ @@ -25,10 +26,14 @@ public void run() { while(connected){ //Stuff happens here that makes the program work + ArrayList gameList = new ArrayList<>(); + boolean gameCreated = false; gameCreated = dataFromUser.readBoolean(); if(gameCreated = true){ + gameList.add(new Game(dataFromUser.readLine())); + } From 6bbdefd15431fe1fe7dc26fb4894d989b80897d7 Mon Sep 17 00:00:00 2001 From: UngThousandIsland <72729946+UngThousandIsland@users.noreply.github.com> Date: Thu, 7 Oct 2021 15:13:10 +0200 Subject: [PATCH 06/13] Mini-Project Client Bare en lille client --- MP_Client/MP_Client.iml | 11 +++++++++ MP_Client/src/Client.java | 51 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 MP_Client/MP_Client.iml create mode 100644 MP_Client/src/Client.java diff --git a/MP_Client/MP_Client.iml b/MP_Client/MP_Client.iml new file mode 100644 index 00000000..c90834f2 --- /dev/null +++ b/MP_Client/MP_Client.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/MP_Client/src/Client.java b/MP_Client/src/Client.java new file mode 100644 index 00000000..e96a89d7 --- /dev/null +++ b/MP_Client/src/Client.java @@ -0,0 +1,51 @@ +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.IOException; +import java.net.Socket; +import java.net.UnknownHostException; +import java.util.Scanner; + +public class Client { + + static String host = "localhost"; + static int port = 6969; + static DataInputStream in; + static DataOutputStream out; + static Socket socket; + + public static void main(String[] args) { + + Scanner input = new Scanner(System.in); + boolean connect = true; + + try { + socket = new Socket(host, port); + in = new DataInputStream(socket.getInputStream()); + out = new DataOutputStream(socket.getOutputStream()); + + //while (connect) { + /*System.out.println("Enter annual interest rate"); + double annualInterestRate = input.nextDouble(); + + System.out.println("Enter number of years"); + int numOfYears = input.nextInt(); + + System.out.println("Enter loan amount"); + double loanAmount = input.nextDouble(); + + out.writeDouble(annualInterestRate); + out.writeInt(numOfYears); + out.writeDouble(loanAmount); + + */ + //out.flush(); + + // } + + } catch (UnknownHostException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } +} From 63d20e587ecc37354569d58324f91eefb0b40851 Mon Sep 17 00:00:00 2001 From: Blomsgaard <70745304+Blomsgaard@users.noreply.github.com> Date: Thu, 7 Oct 2021 15:20:00 +0200 Subject: [PATCH 07/13] Added a class for games --- Server/src/Game.java | 4 ++++ Server/src/ServerRunnable.java | 11 +++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Server/src/Game.java b/Server/src/Game.java index e767c3f7..1b9024cf 100644 --- a/Server/src/Game.java +++ b/Server/src/Game.java @@ -4,4 +4,8 @@ public class Game { Game(String gameName){ this.gameName = gameName; } + + public String getGameName() { + return gameName; + } } diff --git a/Server/src/ServerRunnable.java b/Server/src/ServerRunnable.java index f822ff93..5a0e6359 100644 --- a/Server/src/ServerRunnable.java +++ b/Server/src/ServerRunnable.java @@ -1,6 +1,4 @@ -import java.io.DataInput; -import java.io.DataInputStream; -import java.io.DataOutputStream; +import java.io.*; import java.net.Socket; import java.util.ArrayList; import java.util.Date; @@ -24,6 +22,7 @@ public void run() { DataInputStream dataFromUser = new DataInputStream(clientSocket.getInputStream()); DataOutputStream dataToUser = new DataOutputStream(clientSocket.getOutputStream()); + while(connected){ //Stuff happens here that makes the program work ArrayList gameList = new ArrayList<>(); @@ -32,8 +31,12 @@ public void run() { gameCreated = dataFromUser.readBoolean(); if(gameCreated = true){ - gameList.add(new Game(dataFromUser.readLine())); + gameList.add(new Game(dataFromUser.readUTF())); + //Sends the gameNames created back to the user + for (int i = 0; i < gameList.size(); i++){ + dataToUser.writeUTF(gameList.get(i).getGameName()); + } } From d98e2a91a4461c1ec2e3bfa1489fd567074b26cf Mon Sep 17 00:00:00 2001 From: Crybak20 <72729715+Crybak20@users.noreply.github.com> Date: Thu, 14 Oct 2021 13:34:22 +0200 Subject: [PATCH 08/13] Add files via upload --- GameFx/GameFx.iml | 28 ++++++ GameFx/pom.xml | 70 ++++++++++++++ .../com/example/gamefx/HelloApplication.java | 30 ++++++ .../com/example/gamefx/SceneController.java | 46 ++++++++++ GameFx/src/main/java/module-info.java | 8 ++ .../example/gamefx/CARDS_FOR_HUMANITY.fxml | 86 ++++++++++++++++++ .../com/example/gamefx/hello-view.fxml | 16 ++++ .../com/example/gamefx/second-page.fxml | 16 ++++ .../example/gamefx/CARDS_FOR_HUMANITY.fxml | 86 ++++++++++++++++++ .../com/example/gamefx/HelloApplication.class | Bin 0 -> 1274 bytes .../com/example/gamefx/SceneController.class | Bin 0 -> 1903 bytes .../com/example/gamefx/hello-view.fxml | 16 ++++ .../com/example/gamefx/second-page.fxml | 16 ++++ GameFx/target/classes/module-info.class | Bin 0 -> 250 bytes 14 files changed, 418 insertions(+) create mode 100644 GameFx/GameFx.iml create mode 100644 GameFx/pom.xml create mode 100644 GameFx/src/main/java/com/example/gamefx/HelloApplication.java create mode 100644 GameFx/src/main/java/com/example/gamefx/SceneController.java create mode 100644 GameFx/src/main/java/module-info.java create mode 100644 GameFx/src/main/resources/com/example/gamefx/CARDS_FOR_HUMANITY.fxml create mode 100644 GameFx/src/main/resources/com/example/gamefx/hello-view.fxml create mode 100644 GameFx/src/main/resources/com/example/gamefx/second-page.fxml create mode 100644 GameFx/target/classes/com/example/gamefx/CARDS_FOR_HUMANITY.fxml create mode 100644 GameFx/target/classes/com/example/gamefx/HelloApplication.class create mode 100644 GameFx/target/classes/com/example/gamefx/SceneController.class create mode 100644 GameFx/target/classes/com/example/gamefx/hello-view.fxml create mode 100644 GameFx/target/classes/com/example/gamefx/second-page.fxml create mode 100644 GameFx/target/classes/module-info.class diff --git a/GameFx/GameFx.iml b/GameFx/GameFx.iml new file mode 100644 index 00000000..cf79cfdc --- /dev/null +++ b/GameFx/GameFx.iml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/GameFx/pom.xml b/GameFx/pom.xml new file mode 100644 index 00000000..843f3cd3 --- /dev/null +++ b/GameFx/pom.xml @@ -0,0 +1,70 @@ + + + 4.0.0 + + com.example + GameFx + 1.0-SNAPSHOT + GameFx + + + UTF-8 + 5.7.1 + + + + + org.openjfx + javafx-controls + 17-ea+11 + + + org.openjfx + javafx-fxml + 17-ea+11 + + + + org.junit.jupiter + junit-jupiter-api + ${junit.version} + test + + + org.junit.jupiter + junit-jupiter-engine + ${junit.version} + test + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + 17 + 17 + + + + org.openjfx + javafx-maven-plugin + 0.0.6 + + + + default-cli + + com.example.gamefx/com.example.gamefx.HelloApplication + + + + + + + \ No newline at end of file diff --git a/GameFx/src/main/java/com/example/gamefx/HelloApplication.java b/GameFx/src/main/java/com/example/gamefx/HelloApplication.java new file mode 100644 index 00000000..1bb5bba3 --- /dev/null +++ b/GameFx/src/main/java/com/example/gamefx/HelloApplication.java @@ -0,0 +1,30 @@ +package com.example.gamefx; + +import javafx.application.Application; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.Scene; +import javafx.scene.control.Label; +import javafx.stage.Stage; + +import java.io.IOException; + + +public class HelloApplication extends Application { + @Override + public void start(Stage stage) throws IOException { + // which scene we want to be initially displayed.. load that .fxml file + FXMLLoader fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("CARDS_FOR_HUMANITY.fxml")); + Scene scene = new Scene(fxmlLoader.load()); + stage.setTitle("Card Game"); //the title of the window + stage.setScene(scene); + stage.show(); + } + + public static void main(String[] args) { + launch(); + } + +} + + diff --git a/GameFx/src/main/java/com/example/gamefx/SceneController.java b/GameFx/src/main/java/com/example/gamefx/SceneController.java new file mode 100644 index 00000000..6f48cb22 --- /dev/null +++ b/GameFx/src/main/java/com/example/gamefx/SceneController.java @@ -0,0 +1,46 @@ +package com.example.gamefx; + +import javafx.event.ActionEvent; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.Node; +import javafx.scene.Scene; +import javafx.scene.control.Label; +import javafx.stage.Stage; + +import java.io.IOException; + +public class SceneController { + @FXML + private Label welcomeText; + private Stage stage; + private Scene scene; + private FXMLLoader fxmlLoader; + + //https://www.youtube.com/watch?v=hcM-R-YOKkQ&ab_channel=BroCode + // method to switch scenes + @FXML + protected void onButtonClick(ActionEvent event) throws IOException { + welcomeText.setText("Welcome to JavaFX Application!"); + //load the correct .fxml file + fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("CARDS_FOR_HUMANITY.fxml")); + //cast the source of the event to Node, cast the entire stage to Stage + stage = (Stage)((Node)event.getSource()).getScene().getWindow(); + scene = new Scene(fxmlLoader.load()); + // set the scene to the stage + stage.setScene(scene); + stage.show(); //display it + } + + @FXML + protected void switchToScene2(ActionEvent event) throws IOException { + fxmlLoader = new FXMLLoader(HelloApplication.class.getResource("second-page.fxml")); + stage = (Stage)((Node)event.getSource()).getScene().getWindow(); + scene = new Scene(fxmlLoader.load(), 560, 440); + stage.setScene(scene); + stage.show(); + + } + + +} \ No newline at end of file diff --git a/GameFx/src/main/java/module-info.java b/GameFx/src/main/java/module-info.java new file mode 100644 index 00000000..88833793 --- /dev/null +++ b/GameFx/src/main/java/module-info.java @@ -0,0 +1,8 @@ +module com.example.gamefx { + requires javafx.controls; + requires javafx.fxml; + + + opens com.example.gamefx to javafx.fxml; + exports com.example.gamefx; +} \ No newline at end of file diff --git a/GameFx/src/main/resources/com/example/gamefx/CARDS_FOR_HUMANITY.fxml b/GameFx/src/main/resources/com/example/gamefx/CARDS_FOR_HUMANITY.fxml new file mode 100644 index 00000000..aac53222 --- /dev/null +++ b/GameFx/src/main/resources/com/example/gamefx/CARDS_FOR_HUMANITY.fxml @@ -0,0 +1,86 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/GameFx/src/main/resources/com/example/gamefx/hello-view.fxml b/GameFx/src/main/resources/com/example/gamefx/hello-view.fxml new file mode 100644 index 00000000..97133bb9 --- /dev/null +++ b/GameFx/src/main/resources/com/example/gamefx/hello-view.fxml @@ -0,0 +1,16 @@ + + + + + + + + + + + + +