From f84334fb59f0473ac90923c3752c2244bec89fc8 Mon Sep 17 00:00:00 2001 From: Riley Spicer Date: Mon, 4 Apr 2016 13:31:52 -0700 Subject: [PATCH] adding java files for Planet Express game --- Planet Express/bin/App.class | Bin 0 -> 1321 bytes Planet Express/bin/PlanetExpress.class | Bin 0 -> 3694 bytes Planet Express/src/App.java | 29 +++++ Planet Express/src/PlanetExpress.java | 158 +++++++++++++++++++++++++ 4 files changed, 187 insertions(+) create mode 100644 Planet Express/bin/App.class create mode 100644 Planet Express/bin/PlanetExpress.class create mode 100644 Planet Express/src/App.java create mode 100644 Planet Express/src/PlanetExpress.java diff --git a/Planet Express/bin/App.class b/Planet Express/bin/App.class new file mode 100644 index 0000000000000000000000000000000000000000..36cd8c3237f314b8600d6cb54423ebae3df1118e GIT binary patch literal 1321 zcmZ`&>sC`o7~R9|oTO2K0HtW#L90msNn3i8*b1ef)&yNfI3u<`Y_r(Nm^y8f99LZciG>b{r&yo&%XeyVb{Zm!02YT>tRe_@<2US zh>tP()@90!4H3Y`COjBnuicAjUm=HKu4P(8VcJ_7hKP`+HU_oHS6`LKD3QhTT+)XX3Y1OG@ zk;ets%ZCE<#kabY8m_{}IY=y$2a}SPSIO=X^nb~GToPD#q@%!ew6sPJdXU2=7PGjF zf`=;t`F+NfMU(`*uFDuX#6vv&5BZ-RAIkz4_e`2d%MN7NlLu+f%9gg4{K=kG ziPgLfBqlSIc>_McWA%WFA&fiL;@ zv3^PhXNsja|K5G`*ExLScoBR9s{gH+Zfy~X#+P1vg*uKyDDrr%Q`L{@qj{);IRi9EH6`LcP(8Tw(YU+g1 z1MIKMkWLc=CpQCc$eN0-TNNDERJT799`2kLY+wBX**fV9^iJqz$>+GNx>Q&MJLk*- zBiwQHxOzO5X$9^0(h2-O`p;Re?imbtk85t=KzoL#49?;lZx}4*=rP8--=1S~?}VtI zBfs|yvnM!TdxnpuFCOC)XP1U{WoTE2_ETEkeZISV^%!3{&v$zqe)Jh<7l>bpk$-<%#krDf-j1O5Fa2vY A9RL6T literal 0 HcmV?d00001 diff --git a/Planet Express/bin/PlanetExpress.class b/Planet Express/bin/PlanetExpress.class new file mode 100644 index 0000000000000000000000000000000000000000..5dad4d45cc4623885ccfd79d4de8abd946d92220 GIT binary patch literal 3694 zcmai0-*Xe!75=VdTWfi3i;a+7VTgc+*s^T5P?`jT6Cjw78k=BZVwVKg(%M>E)+*A< z#dd%vjWA%lT=mD4-Rsv}G6E65o|vb23MznBZi;owwZq zfnaCX7|jnm87qt+HtA?aOCtpC(NT{EDQ(sf@}xE$nkRirN24cg(Gm8ftvZ^Z3$zZ| zd26^lH)$15c{>_IPTI_knMGU9{g-w0pKi4dt%1VUyy?UeJbwA-uW`*?utTF;iv9D`f4g_pSgt_ckfk$B5= zH89-z40oQ@aDZYd?Gy?7uoPX(%xO5t9WqwVp0|o&=Hjr9ewm*mI2yv>S|1l_GNTP6@P+m*-N6MdF$+0VV2`<76bLz?jbR=DMc@5=ZHV z>#fY#8E>V}B6HxapU`nou0JEN{Z!UUq>I)L*^^1P&^G^-|1W^F zbaj+5&w_LvuRsN&og4S;m+_w0u_)KpEtti;^fK+*4h3Vw4lK!#Ttuo^hUu)8o|OPE z=;%b3hL;3*;CpdV$0fYNwex1KY>i9_>{=bba1=OU!vQ<<|td6}oJRImgU=lffGTJ86)}n)B8g2c}qZ%l%V2 z@)m2+^ILWu3A@_e(wv#g^@at)qpXv(HE7FbYpm&Ry|TWropc7-?;8-1J(f~Hc33sC zzp9blRgLVeYGh~S7@;NmGoP)T5(Ed9L0Z8Bm z^)j}~xPHa>+ck}i^~Uj<#`o1Uj;=S}R?~P_P2<>l;~h1P@2_bbUvIpthH*e18K1D1 z{ABe@!XlZEu$h7(1)V}PlKBu#$sn^-L5wfrA0W&j_C7TAmU4&OGN@>dv2K7QwxFBz zrg$&)@aE}TRV0Y`8dZo#QhNSN}1>app{}@jj08DP#8%zV{x^Rq%1jcu>hlD)=B} z>{D{Gg6k<`zmn|=E~ktEB@b6{A!R(GP%>8P5X;Pgp3 zJ*}n(IUSeNAFAnYPM?<3vue7NQ*(gxKO!@3Ox;Fy>k?*+{1OUFC~*n(3&Yg+P?l%H z<8%z0Deu8+*o)W6<_$c6cX_$}f?WKHx9)Fn03TxjpYoo$#mngn9KxS*7=Phq{8tR( z?>LGtaSUJKar_HI_&2Z8yBJnENqSuSIU(z~fFE)AiWxk>Llfj`4L|0)AhQad#pXMB zB!u23^=py8{}4&wxs`&dp1|99etk7Qv8oi7Phdda0EA%c5E?fMaHF3YFAlM^+9QL% zMw{fT`*XZZ#*E7zTT*FkP`*}GMmH$0R+aI{wvX1rzFt+vHYnfpmEFHzNy={3_MW7- zW0X#lz;O~VLDJ5U@~0`CZKjLb^wkvPjzXtX^VHXK|p(ZT9 z`D(#3a*`02uymYaY&{9j5%zh)zEBgEpKczk=wt$AAzusbU#{cEOF~r8s-~>JhD+k^ zauruqhO9nc6_YhwRjI=CRdHW+*8@}qO_d;^s(f1cs;Cbrwp82n1OotGrh^w5&Lwj3 z3gWnot!y&8aD|n86?<_F58@4$%bR!-!zn_6-)-PkGV5%L>0qj(<+; m_h|V`MT=ME*H%jIifSfamA4{%2b)Awi~lEIZ_}9oe)2zV0?(NM literal 0 HcmV?d00001 diff --git a/Planet Express/src/App.java b/Planet Express/src/App.java new file mode 100644 index 0000000..8dbebff --- /dev/null +++ b/Planet Express/src/App.java @@ -0,0 +1,29 @@ +import java.util.Scanner; + +public class App { + + public static void main(String[] args) { + PlanetExpress crew = new PlanetExpress(); + Scanner actionReader = new Scanner(System.in); + + System.out.println("Welcome to Planet Express!"); + System.out.println("Your team is just getting started."); + System.out.println("What would you like do to?"); + System.out.println("Choose one: 'drink', 'eat', 'deliver', 'steal', 'account'"); + System.out.println("Type 'score' to get your current score."); + + String action = actionReader.next(); + + do { + crew.act(action); + System.out.println("What would you like do to?"); + System.out.println("Choose one: 'drink', 'eat', 'deliver', 'steal', 'account'"); + System.out.println("Type 'score' to get your current score."); + action = actionReader.next(); + } + while (crew.check()); + + System.out.println("Uh oh, your crew is no longer stable."); + System.out.println("GAME OVER"); + } +} diff --git a/Planet Express/src/PlanetExpress.java b/Planet Express/src/PlanetExpress.java new file mode 100644 index 0000000..e0f2cdb --- /dev/null +++ b/Planet Express/src/PlanetExpress.java @@ -0,0 +1,158 @@ +import java.util.Scanner; + +public class PlanetExpress { + private int thirst; + private int work; + private int horde; + private int hunger; + private int receipts; + private boolean stable; + + + public PlanetExpress() { + thirst = 50; + work = 50; + horde = 50; + hunger = 50; + receipts = 50; + stable = true; + } + + public int getHunger() { + return this.hunger; + } + + public int getThirst() { + return this.thirst; + } + + public int getWork() { + return this.work; + } + + public int getHorde() { + return this.horde; + } + + public int getReceipts() { + return this.receipts; + } + + private boolean isStable() { + if (this.hunger >= 100 || this.thirst >= 100 || this.work >= 100) { + this.stable = false; + } else if (this.receipts <= 0 || this.horde <= 0) { + this.stable = false; + } + return this.stable; + } + + public void act(String action) { + switch (action) { + case "drink": + this.drink(); + System.out.println("You drank some stuff.\n"); + break; + case "eat": + this.eat(); + System.out.println("Yum, you ate some food.\n"); + break; + case "account": + this.account(); + System.out.println("Great, you did some accounting.\n"); + break; + case "deliver": + this.deliver(); + System.out.println("The crew delivered some packages!"); + break; + case "steal": + this.steal(); + System.out.println("Oops, Bender stole some things."); + break; + case "score": + int score = this.getScore(); + System.out.println("Your score is: " + score + "."); + } + String warning = this.warn(); + System.out.println(warning); + } + + public boolean check() { + return this.isStable(); + } + + private String warn() { + String warning = ""; + if (this.hunger > 70) { + warning += "Your hunger is getting dangerously high.\n"; + } + if (this.thirst > 70) { + warning += "Your thirst is getting dangerously high.\n"; + } + if (this.work > 70) { + warning += "Your workload is getting dangerously high.\n"; + } + if (this.receipts < 30) { + warning += "You have dangerously few receipts.\n"; + } + if (this.horde < 30) { + warning += "Your horde is dangerously small.\n"; + } + return warning; + } + + private void drink() { + this.thirst -= 10; + this.work += 10; + } + + private void deliver() { + this.work -= 10; + this.receipts += 10; + } + + private void steal() { + this.horde += 10; + this.work += 10; + } + + private void eat() { + this.hunger -= 10; + this.work += 10; + } + + private void account() { + this.receipts -= 10; + this.horde -= 10; + } + + private int getScore() { + int score = 0; + if (this.hunger > 70) { + score += 1; + } else if (this.hunger < 30) { + score -= 1; + } + if (this.thirst > 70) { + score += 1; + } else if (this.thirst < 30) { + score -= 1; + } + if (this.horde > 70) { + score += 1; + } else if (this.horde < 30) { + score -= 1; + } + if (this.receipts > 70) { + score -= 1; + } else if (this.receipts < 30) { + score += 1; + } + if (this.work > 70) { + score -= 1; + } else if (this.work < 30) { + score += 1; + } + return score; + } +}