From 6513d2a8125b2173262d614c2f7e5db3d216c9c5 Mon Sep 17 00:00:00 2001 From: Lumberjack42 Date: Tue, 7 Jun 2016 08:26:51 +0200 Subject: [PATCH] Add files via upload Hallo --- Player.class | Bin 0 -> 3881 bytes Player.ctxt | 12 ++++ Player.java | 198 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 210 insertions(+) create mode 100644 Player.class create mode 100644 Player.ctxt create mode 100644 Player.java diff --git a/Player.class b/Player.class new file mode 100644 index 0000000000000000000000000000000000000000..21ca86e5e4d1a771b87b98f9d8066d685d8fd0ba GIT binary patch literal 3881 zcmZ`*`*Ryt75-LQY4upYl-NllJ5@s-w(8i>mXb6NYR7pP>^NYPkkpi{rLDZNwCk=` zP8?`UOG_zj(-NRS873u^2_0U2Bo0G6JO&tM_#60*{{lLN@9eG~u~pCb+`IRld+s^k zch0%`=SP3|BY+3+dI~$SsKJu)LK2_Al8Ca1iU?bTBVt*^<04!URS{nN;jOg8zZ7a% zN#Y_dX;@7mg9`~+p5ay%D3c1JMzN?MVo@ZPU1#N-u~=51$@FxIGtu>^8+nAv$>njgYI&DU zR~F7uujF{As7hP>N|c>y{nJ*EnYv)C7^7vwE{)E5u4R`FP^V;iXB@Z8`#J}QrjDDo z=^Eu}W0`yE5vOP>=$f)@^JJ~EV7hb0LYXU>DW_nRPaCc!-{GR_En0LeF?FhJteP&* z#}8Vz7ryvyBQ($LP=G1aTM~Vt}3eny{+Nw0P3r-b^1q zCW_er#1sLXbHWc=;Vsc+mzGu6uo-0sw+c%PFmyXnHN8+<9h{U)qg-Lsu32$b%ww)o zsT-@-76>e3?50}+vt<{|BTmhxx^jvC7ZvDtLYNfdM6Jr?(=eC z2a5_)LYco!NYWMKQd2caqyiQKT&7p+F8Fqag#Rwusgo|Z2Aao%qzD!WiLYpSQ(<-l z>m7`VfqGWevkIX_f}y)+(KRjxoGREv{7bHB+K)MoH|i%2iB8QrHMd|Mvm`mvf$oUV zq_g(8lxn7xjsrNVV;6So*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7r@r(1MnQJJW>099JI%MrXnR;+fB5}2ha+qY zg*G=Q*FS83YJ0fYVBr9bNUlbs2iMom-?;I2|9H?0qagtDCQAh?-D8B!+~5T}%z7`9 NZM;zM81Ids^nckys#5>} literal 0 HcmV?d00001 diff --git a/Player.ctxt b/Player.ctxt new file mode 100644 index 0000000..457b370 --- /dev/null +++ b/Player.ctxt @@ -0,0 +1,12 @@ +#BlueJ class context +comment0.params= +comment0.target=int\ getStars() +comment1.params= +comment1.target=void\ addToStars() +comment2.params= +comment2.target=void\ add() +comment3.params=set +comment3.target=int\ setStars(int) +comment4.params=sub +comment4.target=int\ removeFromStars(int) +numComments=5 diff --git a/Player.java b/Player.java new file mode 100644 index 0000000..2fa05c0 --- /dev/null +++ b/Player.java @@ -0,0 +1,198 @@ +import greenfoot.*; + +/** + * Write a description of class Player here. + * + * @author (Genosse Betakevin und Genosse Julien) + * @version (version 666) + */ +public class Player extends Actor +{ + @Override public GeneralMap getWorld(){ + return (GeneralMap) super.getWorld(); + } + int stars=0; + int add=0; + int id=0; + int provZahl=0; + int provVgl=0; + int [] stats = new int [6]; + boolean [] pBesitzer = new boolean [42]; + boolean gotProv = false; + boolean lostProv = false; + + private String n; + //definiert die ID und Namens Variable + public Player( int identity,String name) + { + n = name; + id = identity; + } + //gibt die Spieler ID zurück + public int getID() + { + return id; + } + // gibt den Spielernamen zurück + public String getDisplayName () + { + return n; + } + //gibt die Sternenanzahl zurück + private int getStars () + { + return stars; + } + // erhöht die Sternenzahl um eine random ausgewählte Anzahl von 1-3 + private void addToStars () + { + + int rand; + int pre; + rand = (int)(1+6*Math.random()); + if (rand == 1 || rand == 2|| rand == 3) + { + add = 1; + } + if (rand == 4|| rand == 5) + { + add = 2; + } + if (rand == 6) + { + add = 3; + } + if (gotProv== true) + { + pre = stars; + stars+=add; + System.out.println("Deine vorherige Sternenanzahl betrug " + pre + "."); + System.out.println("Du hast " + add + " Sterne erhalten."); + System.out.println("Deine aktuelle Sternenanzahl beträgt " + stars + "."); + + } + } + //eine Methode um addToStars zu testen + public void add () + { + addToStars(); + } + //eine für das Testen gedachte Methode, die die Anzahl der Sterne auf ein gewünschtes Maß setzt + public int setStars (int set) + { + stars = set; + return stars; + } + //eine Methode, die das Abziehen von Sternen testet und, wenn das Ergebnis >= 0 ist, die Sternenanzahl um eine gewählte Anzahl verringert + public int removeFromStars(int sub) + { + int s; + + s = stars - sub; + if (s>=0) + { + stars = s; + } + else + { + System.out.println ("Du hast nur " + stars + " Sterne, du kannst also nicht " + sub + " Sterne abziehen"); + } + return stars; + } + + public int getProvinceCount () + { + GeneralMap w= getWorld(); + int[] provinces = w.getProvinceOwners(); + for (int x=0; x<=42; x++ ) + { + if ( provinces [x] ==id) + { + provZahl++; + + } + } + if(stats[2] < provZahl) + { + stats[2]=provZahl; + + } + return provZahl; + } + + private void gotEntities(int gotEnt) + { + stats[3]+= gotEnt; + } + private void lostEntity() + { + stats[4]+=1; + } + private void maxEntities(int entNumber) + { + if (stats[5]< entNumber) + { + stats[5]=entNumber; + } + } + private boolean[] getMyProvinces() + { + GeneralMap w= getWorld(); + int[] provinces = w.getProvinceOwners(); + for (int x=0; x<=42; x++) + { + if (provinces[x]== id) + { + pBesitzer[x]=true; + } + else + { + pBesitzer[x]=false; + } + + } + return pBesitzer; + } + + private void gotlostProvince() + { + if (provVgl== provZahl) + { + gotProv = false; + lostProv =false; + + } + if(provVgl< provZahl) + { + gotProv = true; + lostProv = false; + stats[0]+=1; + } + if (provVgl > provZahl) + { + gotProv = false; + lostProv = true; + stats[1]+=1; + } + provVgl = provZahl; + } + + public boolean getGotProvince () + { + return gotProv; + } + + public boolean getLostProvince() + { + return lostProv; + } + private int[] getStatistics() + { + return stats; + } + private void redrawPlayer() + { + //Platzhalter + int x=0; + } +}