From 41c9aaf99ee52b584edefd180252bc7953d87377 Mon Sep 17 00:00:00 2001 From: AlexRedDevil99 Date: Tue, 2 Nov 2021 21:02:11 +0200 Subject: [PATCH 1/2] My commit --- _1_basics/src/main/java/code/_3_in_class/HelloWorld.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_1_basics/src/main/java/code/_3_in_class/HelloWorld.java b/_1_basics/src/main/java/code/_3_in_class/HelloWorld.java index ce7a7ffe1..9a872f8a2 100644 --- a/_1_basics/src/main/java/code/_3_in_class/HelloWorld.java +++ b/_1_basics/src/main/java/code/_3_in_class/HelloWorld.java @@ -1,7 +1,7 @@ package code._3_in_class; public class HelloWorld { - + //niceeeeee public static void main(String[] args) { System.out.println("hello world 2"); } From 70320fbeaa5d86adef7bd19a124e37721f0cd6da Mon Sep 17 00:00:00 2001 From: AlexRedDevil99 Date: Sat, 27 Nov 2021 22:45:54 +0200 Subject: [PATCH 2/2] Adding the files for project 1 --- .../Hero.class | Bin 0 -> 237 bytes .../Hero_Factory.class | Bin 0 -> 694 bytes .../Heroes.class | Bin 0 -> 949 bytes .../Main.class | Bin 0 -> 2461 bytes .../Pyromancer.class | Bin 0 -> 2241 bytes .../Rogue.class | Bin 0 -> 2226 bytes .../Strategy.class | Bin 0 -> 470 bytes .../Wizard.class | Bin 0 -> 2237 bytes .../input.txt | 17 ++++++ .../src/Hero.java | 9 +++ .../src/Hero_Factory.java | 14 +++++ .../src/Heroes.java | 5 ++ .../src/Main.java | 48 +++++++++++++++ .../src/Pyromancer.java | 57 ++++++++++++++++++ .../src/Rogue.java | 57 ++++++++++++++++++ .../src/Strategy.java | 11 ++++ .../src/Wizard.java | 57 ++++++++++++++++++ .../src/input.txt | 17 ++++++ 18 files changed, 292 insertions(+) create mode 100644 Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/Hero.class create mode 100644 Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/Hero_Factory.class create mode 100644 Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/Heroes.class create mode 100644 Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/Main.class create mode 100644 Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/Pyromancer.class create mode 100644 Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/Rogue.class create mode 100644 Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/Strategy.class create mode 100644 Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/Wizard.class create mode 100644 Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/input.txt create mode 100644 Project1_Delicostea_Robert_Alexandru/src/Hero.java create mode 100644 Project1_Delicostea_Robert_Alexandru/src/Hero_Factory.java create mode 100644 Project1_Delicostea_Robert_Alexandru/src/Heroes.java create mode 100644 Project1_Delicostea_Robert_Alexandru/src/Main.java create mode 100644 Project1_Delicostea_Robert_Alexandru/src/Pyromancer.java create mode 100644 Project1_Delicostea_Robert_Alexandru/src/Rogue.java create mode 100644 Project1_Delicostea_Robert_Alexandru/src/Strategy.java create mode 100644 Project1_Delicostea_Robert_Alexandru/src/Wizard.java create mode 100644 Project1_Delicostea_Robert_Alexandru/src/input.txt diff --git a/Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/Hero.class b/Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/Hero.class new file mode 100644 index 0000000000000000000000000000000000000000..4eb8ddb0e36407ed85d2ebad55c09982cfb642aa GIT binary patch literal 237 zcmYL@&kBM-7{q7IG%d?|iuIBY;JHYUItWpx*kqB!KVTa4Y8`rj9xD2F3%Y#6e8c>h z*Zc7V5Mge^U@$kbZETnfej#omEJdA%yK^D4j=@vmDeYR($^6dX@I-y0V9#LZvfGME zGAwwI{JX2VuOi}7d|(*xASQFw#^kYTs_6KAlDKKpx0zgDN@bf!Z__uxQ*6 a7Su=^Bdrcxtz%5IdOtr^o|-ed2K*0wmn?_? literal 0 HcmV?d00001 diff --git a/Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/Hero_Factory.class b/Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/Hero_Factory.class new file mode 100644 index 0000000000000000000000000000000000000000..3b1f2736542af9ee80e6952316ccb81972abe603 GIT binary patch literal 694 zcmY*X!EVz)6r7FiY-5}@4RH#DKuZgxB_v!p1@!{5uoR$bQLCQN#xcPqv5|2Q<%4<- zTq;qC8y7wbG3%rPEcxxc_r~*Pz5DC;_a6Xycx0mhL&9`mp(s!}QJ++Itm0Ak)!-xy zGJ)cgD2}pS0i(5jSi%xY61IaYaM*hurb+lwKh9uSj@2xl4%-*UZkC@{_D7- z|2Q^qiwB{f0=PvK8P}P0xeBh<&N;-_yuHDw+nRcZ(U}vli7jRVcX5w#o%kmtnSj^+ z26=|+1bcGERo>l`aHR;y>IUBEqV5H9L#x_&KZH~zAlGclu*L8G8m$!IcKsB=P- zsKbMLj1r#lVrW;p^T`WW^nm+l9kG7erZyZcf23T?mF?Fj>SIe&l*1jx zLDX~76?g)Xf7!$x+$GJ8APPoX42$Vh3G=nx(xDn8ZCOWFhsl2*ns|gYu2Qryq$!l` zzd9-7%&qJUK9I!uW)S&r#{G^TA9|gTJf;7XvS)*0u$qIe7q+}O;P8Z_L|&h$)>V15 ztkI`{+Q_;=FY-p?m~e90Zqc$D-7t|?OcD7I8nb#^4ujzi#&Oqw74YunrrWOasc+Xw zaDlFfvc1GF1VAV4U!1ggAYbG=CxlA=GS&!hleI!8e~bxoUvd2c)@QO9D)h~W81+l* zT~F{Ekc8K;Smhjx7hoJO{eyo@9&?Jq6I4Z770BJF%>;M1& literal 0 HcmV?d00001 diff --git a/Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/Main.class b/Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..571839e5ed2c6df8f10ce993bd93aafdcf036f3d GIT binary patch literal 2461 zcmZ`*?Qc_682_EV-S+mjjE!y-K?d^D^0F%G(2W-XnG`#wjExo4?XJ5UcXVyNy`7ti ziq1Da=|>VjAbx;oj3Fi~V+k?gi_yfy#6%PS2mb(#%-^}~-Po8-?!D(c&+q)6=R7ax z^r!oG?gHq<6%`(M75Fsx5fEq?*C+K{k#J&>WCi zOm&%gBM4O>Qnqp_vrwwoZT6I{LV+d;BLcBRW{I-bw#>px+4XotF5D>KOQfZ5k8+DA468WUrRVITHLYS3ywboH4O{V;K+vM68M9yrtV<*x z-k^%@*r8yjh6IxIb}0hsf^Cc$7AZ=)RW>;NpAe;k*exJhRqREZf|Q2G@x-$H)PgDC zFPHKrX%eeMI-NYfns-m)DFsh!Xvco$S8mlP3n-I%zGC!@3T#}3Dw(O_I%PDT)zE=X zE*UdyDVA|ayMS~$T?2Q9aS(?T9M3mz9EE4QE_L zRzW{A!~pBe7SrE{0a+ngfl$KPrBiTyIIrOqDQz&Oj9kSw2Fvv&3SOfR-MU%e=U8!s zg|bH0%c;u5uwk9ihx3#)W{NpI->+MyoY#du`+~__1Tu0lBkY@SNSYI?Br-`ay}HF} zYFb6hwFP~Gc7kqVD9M|nl!!E+DL&Hz9+`;72jW_9Qff`Eb$2A7X54_#Eiul*n;IN3 zCi$JNeSNw$M%R6#Y*{9|M(K7a4Gq)L^^4NwO;5_eg?b$})G$t)$~uvCHd^aMNh?$B zcBb@%Ar=!nO_oP$!{FddUgCf-&y$_*Bj)*=Dg&R`9WV zWN;Vho<$8&y~T=^GvwjKnvkh#lZA;bc$Md={CU8@Ai(z^XDNOKzy4iSh+B?&h;OL| z4@;eItp>m_a-4-Q0)r%6?ERC7C?Nirhmvg!RT0k2BbuE@Lw0u+ja9_D=dnK9u&#;? z9sYT2%2u(tBd}){t+%nQUGcUDW5Jkm9jB$})ZWHj$}IMDgyJFZzT4Q>p~gc#4z{(2 z;~~E@(Bh$hGl<0f@jxsbS7TZ%5)01anK>Nr;OtCL+*tV5wGi~Shhm{v@VeOVTJTE? zYFw2TB(YkvpvC41_D|9QSbLb&dBlNTf4ySLZJwhkB z&u<>Wl9sZFYu2%I4VNCmk#jkYf@|oTM_+aYwu-YIzPRr}^eoQRfs2NgP!H~!z?ldG zcxEOfZruM-)`Jg2e7}RuPVQBx*nkLckto`*2K#yS9YG_HsV4Lwh5i zu2BCOHsUIe=CAN5Zj$E~T5*R3d5>4tU%a&9*d~(LE~c?Ve2$&sIufGF+v#V@f5j&8 zJBw7-;cw*c;Xi{>jIjy_un!kt(jOg3+PjD_->t}Vq|tT@COC@Fvy&*G2ruu2ev~K+ z(n<$jhXtS5itmV(xLcytVODWRw7{k;jC&%A3P&1lid3ED3(@JYgk;@glD>fdGk(Dv zm|~x75O*<+H`yQC#rJp%Z?o0f#MijQ2nKkkeTjF;r{JnMjQ2PS;xgCE4y)ncC;kIU zE<;(MlOY8&3KXZy6dY6-4FUX(zJC!GVgVl_x`gp&!Dpxl` QZkc?6kNAATu?L_22L{X$;{X5v literal 0 HcmV?d00001 diff --git a/Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/Pyromancer.class b/Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/Pyromancer.class new file mode 100644 index 0000000000000000000000000000000000000000..8fb170c6a2dc6528fe1fc8a198ca4420981e74ad GIT binary patch literal 2241 zcmaJ?T~ixn6n@^2?1pst2p^?T`6wT42-wsPT5T${MUd1$X@k&OwJu>H3(0OKyL9Bn zJI4!Wyz)YC9jD%SQ96R!3x9yW!W(Bg<9~2`-giS2XlgRE@7FocdCqg*J^Sas&;9_A zMlpsEnskH>M4$<@Z<~+IRMB*{Qn%N)t-LRwU9%nApB89JjITB$ie?=#1E*jJ#FqCe zZpn1=Rz)COv^OmQk&#BN2HMchO~)*8Gn!qnDz4?FL|MB<>{xZ%9zFrp^34@Y|h#z8sX> zZyI<@ZQs>q{!+%YzKXPtYX;s0b*s}fx99m*iBh_|RJJ>yZ@a1GitYG0zharCwB&PL z=6r+tGR3NJ9mJkB@E+y_dP?SwHS0Qg(_gdw0%x9YI=&|`kT|l>Wa`x+w(V>Y`+Y3v z$QZbV4+J`ue8=NcgtBB)bVx8!CvX*Fd{v+=k*S5DPAtx>yTLNIWo^e=+AXbHl@)Wn z$eoU?n>UNAX2q84>Sow4*d%LYYu6`D3|96Y2i8CiT-^^=99pCb4@trFt*t$Q<{;0s zid|3_LsOK9(~|Se{LZ3Tu11UH+}%pvnztpNwpz%GGJBTirtA71k;{vgUvM|PHVqGB z_zb3wbt!mWV6=A6Z0C`?W2FK$f*Q=5dEc#&)pzxJRSg5s1=HCmTHa{Zb$52l>6c}# z+d1aAvRAemm_Mkq4_?%CeYvX;vu3fFvwbTa1yk>n8V(8m3#P|s*=3o%p`x|PyJ%z_ z$EwU0P0zDD9R-20mvU~DijHmGy8k!jix}k1*Con+Blu!RII@NCQio)tP$Qdy8rcri z$VR|1M*9e|d@geJE$uaqL&;wul4lQ~CnpcklI%Y~JlP#SKv%Lma)6$Fg|Niu0CYYz zggL6t#Ahc_dl`R_5pMHzI>5v-?r=qP#Z9Q0WEWC1$*)PxB*U7o>#6|J0)GPN;&bI)UhDo-Ja>-_rNqG)TlhypIb z=a=paT*lWt{T^5F1aH^LwEyDP?c*NqQ=X5A8ih8}KHNUs(tbmJuLIHQN>5@ZOD`H! duL%zb7Q)B)M1cx?N~jHNawR*#7HsUG_dmdtn(Y7p literal 0 HcmV?d00001 diff --git a/Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/Rogue.class b/Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/Rogue.class new file mode 100644 index 0000000000000000000000000000000000000000..388553375bf1374489aa7817fa83cdd01dbd8d4a GI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o9WTQjHs)JW8am z2@%K=UUxpENb)EVxjm;|Kt!HRsmKBr11yoFwbXHUWEVXGPcg8C3)vkErCa{~4&7Nf zjM}n|*$;Ox`~x0mJMpSq_`LFkTCnz9b6XgxyMB+9a*f!^WRgA#br$1$>E%_!gJ(8{TM;Yj^(u?cy%(QKk=w8sqUxolc!ermo5Vbs%2D lwI#8m*H$#y#TMKrSO_2DBLyl*N?;i)oXLu?3JVpS_z&k~n=b$W literal 0 HcmV?d00001 diff --git a/Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/input.txt b/Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/input.txt new file mode 100644 index 000000000..f255cdab0 --- /dev/null +++ b/Project1_Delicostea_Robert_Alexandru/out/production/Project1_Delicostea_Robert_Alexandru/input.txt @@ -0,0 +1,17 @@ +5 +W 2000 0 0 +R 1500 3 4 +R 1000 4 5 +P 3000 2 3 +W 4050 6 7 +10 +3 4 +1 1 +1 1 +4 4 +-5 0 +1 1 +-1 -2 +-3 2 +5 7 +0 -4 \ No newline at end of file diff --git a/Project1_Delicostea_Robert_Alexandru/src/Hero.java b/Project1_Delicostea_Robert_Alexandru/src/Hero.java new file mode 100644 index 000000000..546feac43 --- /dev/null +++ b/Project1_Delicostea_Robert_Alexandru/src/Hero.java @@ -0,0 +1,9 @@ +public interface Hero { + void Hero_Strategy(Hero hero); + Enum getName(); + int getX(); + void setX(int x); + int getY(); + void setY(int y); + +} diff --git a/Project1_Delicostea_Robert_Alexandru/src/Hero_Factory.java b/Project1_Delicostea_Robert_Alexandru/src/Hero_Factory.java new file mode 100644 index 000000000..fdb99bdfd --- /dev/null +++ b/Project1_Delicostea_Robert_Alexandru/src/Hero_Factory.java @@ -0,0 +1,14 @@ +//Factory pattern for production of the heroes +public class Hero_Factory { + public Hero getHero(int life, Heroes name, int x, int y, int id){ + if(name == Heroes.P){ + return new Pyromancer(life, name, x, y, id); + }else if(name == Heroes.W){ + return new Wizard(life, Heroes.W, x, y, id); + }else if(name == Heroes.R){ + return new Rogue(life, name, x, y, id); + }else{ + return null; + } + } +} diff --git a/Project1_Delicostea_Robert_Alexandru/src/Heroes.java b/Project1_Delicostea_Robert_Alexandru/src/Heroes.java new file mode 100644 index 000000000..3d0b4548a --- /dev/null +++ b/Project1_Delicostea_Robert_Alexandru/src/Heroes.java @@ -0,0 +1,5 @@ +public enum Heroes { + P, + W, + R +} diff --git a/Project1_Delicostea_Robert_Alexandru/src/Main.java b/Project1_Delicostea_Robert_Alexandru/src/Main.java new file mode 100644 index 000000000..6d124177c --- /dev/null +++ b/Project1_Delicostea_Robert_Alexandru/src/Main.java @@ -0,0 +1,48 @@ +import java.io.File; +import java.io.IOException; +import java.io.*; +import java.util.ArrayList; +import java.util.List; + +public class Main { + public static void main(String[] args) throws IOException { + File file = new File("src/input.txt"); + BufferedReader br = new BufferedReader(new FileReader(file)); + String st; + Strategy strategy; + List heroes = new ArrayList<>(20); + Hero_Factory factory = new Hero_Factory(); + int n = Integer.parseInt(br.readLine()); + for(int i = 0; i < n; i++) + { + st=br.readLine(); + String[] arr = st.split(" ", 4); + + Heroes name = Heroes.valueOf(arr[0]); + int life = Integer.parseInt(arr[1]); + int x = Integer.parseInt(arr[2]); + int y = Integer.parseInt(arr[3]); + heroes.add(factory.getHero(life, name, x, y, i)); + + } + int m = Integer.parseInt(br.readLine()); + for(int i = 0; i < m; i++){ + st=br.readLine(); + String[] arr = st.split(" ", 2); + int x_dev = Integer.parseInt(arr[0]); + int y_dev = Integer.parseInt(arr[1]); + heroes.get(i%n).setX(heroes.get(i%n).getX() + x_dev); + heroes.get(i%n).setY(heroes.get(i%n).getY() + y_dev); + for(int j = (i%n) + 1; j < n; j++){ + if(heroes.get(i%n).getX() == heroes.get(j).getX() && heroes.get(i%n).getY() == heroes.get(j).getY()){ + strategy = new Strategy(heroes.get(i%n)); + strategy.execute_strategy(heroes.get(j)); + strategy = new Strategy(heroes.get(j)); + strategy.execute_strategy(heroes.get(i%n)); + } + } + } + + + } +} diff --git a/Project1_Delicostea_Robert_Alexandru/src/Pyromancer.java b/Project1_Delicostea_Robert_Alexandru/src/Pyromancer.java new file mode 100644 index 000000000..22d1bc654 --- /dev/null +++ b/Project1_Delicostea_Robert_Alexandru/src/Pyromancer.java @@ -0,0 +1,57 @@ +public class Pyromancer implements Hero { + private int life; + private Heroes name; + private int x, y; + private int id; + public Pyromancer(int life, Heroes name, int x, int y , int id){ + this.life = life; + this.name = name; + this.x = x; + this.y = y; + this.id = id; + } + public int getX(){ + return x; + } + public void setX(int x){ + this.x = x; + } + public int getY(){ + return y; + } + public void setY(int y){ + this.y = y; + } + public Heroes getName(){ + return name; + } + int getLife(){ + return life; + } + void setLife(int life){ + this.life =life; + } + @Override + public void Hero_Strategy(Hero hero) { + if(hero.getName() == Heroes.P){ + if(this.getLife() < 1000){ + this.setLife(this.getLife()/2); + }else{ + this.setLife((int) (0.75 * this.getLife())); + } + }else if(hero.getName() == Heroes.W){ + if(this.getLife() > 1000){ + this.setLife(this.getLife()/3); + }else{ + this.setLife((int) (0.66 * this.getLife())); + } + }else if(hero.getName() == Heroes.R){ + if(this.getLife() > 1000){ + this.setLife(this.getLife()/5); + }else{ + this.setLife((int) (0.5 * this.getLife())); + } + } + System.out.println("Hero " + this.getName() + " " + this.id + " has " + this.getLife() + " points left"); + } +} diff --git a/Project1_Delicostea_Robert_Alexandru/src/Rogue.java b/Project1_Delicostea_Robert_Alexandru/src/Rogue.java new file mode 100644 index 000000000..736cd262d --- /dev/null +++ b/Project1_Delicostea_Robert_Alexandru/src/Rogue.java @@ -0,0 +1,57 @@ +public class Rogue implements Hero { + private int life; + private Heroes name; + private int x, y; + private int id; + public Rogue(int life, Heroes name, int x, int y, int id){ + this.life = life; + this.name = name; + this.x = x; + this.y = y; + this.id = id; + } + public int getX(){ + return x; + } + public void setX(int x){ + this.x = x; + } + public int getY(){ + return y; + } + public void setY(int y){ + this.y = y; + } + public Heroes getName(){ + return name; + } + int getLife(){ + return life; + } + void setLife(int life){ + this.life =life; + } + @Override + public void Hero_Strategy(Hero hero) { + if(hero.getName() == Heroes.P){ + if(this.getLife() < 1000){ + this.setLife(this.getLife()/4); + }else{ + this.setLife((int) (0.25 * this.getLife())); + } + }else if(hero.getName() == Heroes.W){ + if(this.getLife() > 1000){ + this.setLife(this.getLife()/5); + }else{ + this.setLife((int) (0.4 * this.getLife())); + } + }else if(hero.getName() == Heroes.R){ + if(this.getLife() > 1000){ + this.setLife((int) (0.8 * this.getLife())); + }else{ + this.setLife((int) (this.getLife() / 5)); + } + } + System.out.println("Hero " + this.getName() + " " + this.id + " has " + this.getLife() + " points left"); + } +} diff --git a/Project1_Delicostea_Robert_Alexandru/src/Strategy.java b/Project1_Delicostea_Robert_Alexandru/src/Strategy.java new file mode 100644 index 000000000..ce0f21b37 --- /dev/null +++ b/Project1_Delicostea_Robert_Alexandru/src/Strategy.java @@ -0,0 +1,11 @@ +//Strategy pattern every hero executes his strategy considering his opponent, +// in Hero_Strategy method implemented from Hero interface +public class Strategy { + private Hero strategy; + public Strategy(Hero strategy){ + this.strategy = strategy; + } + void execute_strategy(Hero adversary){ + strategy.Hero_Strategy(adversary); + } +} diff --git a/Project1_Delicostea_Robert_Alexandru/src/Wizard.java b/Project1_Delicostea_Robert_Alexandru/src/Wizard.java new file mode 100644 index 000000000..916a285fd --- /dev/null +++ b/Project1_Delicostea_Robert_Alexandru/src/Wizard.java @@ -0,0 +1,57 @@ +public class Wizard implements Hero { + private int life; + private Heroes name; + private int x, y; + private int id; + public Heroes getName(){ + return name; + } + public Wizard(int life, Heroes name, int x, int y, int id){ + this.life = life; + this.name = name; + this.x = x; + this.y = y; + this.id = id; + } + public int getX(){ + return x; + } + public void setX(int x){ + this.x = x; + } + public int getY(){ + return y; + } + public void setY(int y){ + this.y = y; + } + int getLife(){ + return life; + } + void setLife(int life){ + this.life =life; + } + @Override + public void Hero_Strategy(Hero hero) { + if(hero.getName() == Heroes.P){ + if(this.getLife() < 1000){ + this.setLife(this.getLife()/3 + this.getLife()/5); + }else{ + this.setLife((int) (0.8 * this.getLife())); + } + }else if(hero.getName() == Heroes.W){ + if(this.getLife() > 1000){ + this.setLife(this.getLife()/2); + }else{ + this.setLife((int) (0.25 * this.getLife())); + } + }else if(hero.getName() == Heroes.R){ + if(this.getLife() > 1000){ + this.setLife(this.getLife()/6); + }else{ + this.setLife((int) (0.35 * this.getLife())); + } + } + System.out.println("Hero " + this.getName() + " " + this.id + " has " + this.getLife() + " points left"); + } +} diff --git a/Project1_Delicostea_Robert_Alexandru/src/input.txt b/Project1_Delicostea_Robert_Alexandru/src/input.txt new file mode 100644 index 000000000..f255cdab0 --- /dev/null +++ b/Project1_Delicostea_Robert_Alexandru/src/input.txt @@ -0,0 +1,17 @@ +5 +W 2000 0 0 +R 1500 3 4 +R 1000 4 5 +P 3000 2 3 +W 4050 6 7 +10 +3 4 +1 1 +1 1 +4 4 +-5 0 +1 1 +-1 -2 +-3 2 +5 7 +0 -4 \ No newline at end of file