Page 1 of 1

cant get this code to run, any ideas

Posted: Sat May 14, 2022 7:34 pm
by answerhappygod
cant get this code to run, any ideas
Cant Get This Code To Run Any Ideas 1
Cant Get This Code To Run Any Ideas 1 (48.1 KiB) Viewed 71 times
DOO - ... o 99 e. д Ble Edit selection View Go Bin Jerminal Help Monste 22-deo game - Visual Studio Code [Administrator BXPLORER MONSTEX Camera O 00 OPEN EDITORS Monster.java > Monster Monster Storg, Stringt Actor jawa public class Monster ( 2 Plaver java private String type: 3 Monster public Monster(String AAP) { Gamanagerjava (A) VIDEO CAME this.type generic; Actorava 7 Carja 8 Mondejas 18 9 Player.java Aparan ano 11 naran type 12 U public Master(Stringate, String type) { 10 super(alame); 15 this.type-type; 16 ) 17 18 10 par en lane 28 @param dealth 21 * geran type 22 . 23 public Monster(String name, int ahealth, string aType) ( 24 super(alanc); 25 super.setHealth ahealth); 26 this.type - Type: 27 } 21 29 ON return the type 31 32 33 34 35 it public string getType() return type } Filer feq. test toodeticules AX POLIS 15 CUT CLIPUT DENG CONSOLE > Game Manager.java: v Monster.java 2 the constructor Ubjects bundefined 142T US131 The monstructor Objectingl kundefined 13421705) 14. Co The constructor Object[3ning uncated 134217858En 24. Cal 131 The method setHealthtin cundefined for the type Object Java(G7108964) In 25. col 19 The method gereis undefined for the type Mesle svet/103964 un an Col24 The method gor Health kundefined for the type Meester 108960 in 46 cl 38 The method display is undefined for the type Objcct lava 67108964) in 51, Cel 19 8 X build Gaile, do you canline? Source: Debugs for Extwin Prer Fa.. Com > CHILINE > TIMELINE > JAMA PROJECTS In 1 Col & Spares U-4 (Ola ?

IR 000- X DI es 99 ay 20 e д Be Edit Selection View Go Bum Terminal Help Monsterava - video game-Vesual Studio Code Administrator EXPLORER Actorjava Player Montaa GamMINOR 5D OPEN EDITORS Monster jare > : Monster Mastering int, String 20 Actor.java paran aath 21 • eparer type Player.jave 22 x Master 23 public Monster(String avamo, int Health, String atype) { Gambangan る 24 per Caine) VIDEO GAME superselle hattath); Actores 20 this.type - atype; 27 7 Games 28 MA 7 20 Playerja 38 return the tyre 11 7 12 public string getype() { 33 return type 34 7 35 36 37 enaran type th> type to a TIR 39 public wid setype(String type) { ge this.type = type: 7 42 43 44 public String Infod) { Stringlulder str ne stringbuilder(); 0 str.append(getName()+", "retHealth()+", "Retype()); 47 return str.toString(); ) 40 56 public void display() { 51 sner.display(); 52 System.out.println(" Type: +Lype); 7 54 55 1 29 The best inde modules." PROBLEMS 13 CUIN OSUL DEPUC CONSOLE > Game Manager.java Monster The instructor Oljetting is deel.6484217850 5.131 The constructor Obyact(Stnng sundhed wal134217853) Tin 14. Col 131 The coretructor Object(String) is undefined Java[134217853) Iin 24 Col 131 The methodsetHealthint is undefined for the lype Object law/105964 in 25, col 19 The method getmel) is undefined for the type Monster 671011454) In Com The method getHealth() is undoned for the type Monster JWGZ 108054) 14€ Cal 381 The method display is undefined for the type Object Java(07108964 ( 3 Col 19 X Ruas Piel, do you want to continue Source: Debugyar fer una Estetica) Prod F. Cimad C > OUTLINE > TIMELINE > JAVA PROJECTS 13 A Inta Cola Spurs F-G CRF 1) Inn

ER d File Fat Selection View GO Run Terminal Help Carmelager.jas-vilagune. Vid Suck Cole (Alminister1 LUNCE - D EXPLORER Actor java Player Meretrov Dm Game Managerians 6 X V OPEN TUNICS GameVanagerjasts Game Manager > readexistingPlayers(String EL @ hishit,નર્માત Player.java isport java.io.File; 3 import java.io.Illotloundsaception; 7 Monster.java Y9 4 import java.io.Filetriter; x Gimenes D 5 import java.io.IOException: v V VIDEO GAME a inport java.util.ArrayList; Adorjava 7 import java.util.Scanner: Sama Manaqur O Monsterjava public des Gamer { 10 Pyjava 11 A //Create arraylist to score players and monsters 12 33 static ArrayListActor actors new ArrayListActor>>(); 14 Drug 15 polit stetit void main(String[] args) { 16 Head user input wing scanner 17 Scanner scenew Scanner(System.in); 28 String flichoms" : 19 System.out.print("Enter n to start nei game na to resume exsting ganca}; 10 int norExisting sc.nextInt():sc.nextLine(): 31 Systra.out.print"Enter file na: 22 files.nextLine (); 23 if(neworexisting2) 24 readexistingplayers(fileName); 23 26 Int choice- 27 I lopp until cor que while(choicel-S AR choic!?) { (-7) 19 System.out.print(s: 1. he. Modifyin. - Dife. Delle. Print .player/Monstern Save and ex17. Exit with swing); 100 choice sc.nextInt();xc.nextLine(); 91 switch(choice) 32 1/Add a player/sonster 23 case 1: 34 add(sc): 15 break; 1 PROLENS 18 UHT DESK LONSOLE 13 Interlegtext rode modules V GameManagersa The method add actors in the type ArrayListActors not applicable for the arguments (Munster Java108979). In 19, Col32 irtible conditional and types Actor and Monte 167772321 in 45 20 Cannot cast tram Actorta Monster la(6777372) Iun 158 Col 511 Cannot cast from Actor to Monster Java(107773723 3Ln 164. Col51] The method sellealthink is undefined for the type Monster Sava[7108964) IL 100. Col 43] failed, do you want to continue? X > QUTUNE The method adorn the lype reyisco is not applicable for the arguments (Manstes 67105479 226. Calam Scuze Debuy for even Proced F. Cunul > TIMELINE > Monster.java JAVA PROJECTS 13 In 25 td Sparre UEFA CRF 1) RC

ECO- DO 31. 14 7 The 3 Ele Edit Selection View Ge Bur Jemiral Help Gorger 1200 - video game. Visual Studio Code (Administratod DAPLORER AMA OP M ja 1 cameMAGPAVAO X OPEN EDITORS Gamelanager awa> ts Gamelanager reading layering 33 case 1 Actor jawa 34 add(c): Player java 35 biroak; 99 MRVS 36 X/Modity a player/monster X Gammanager 32 case 2: VIDEO CAME 3 nodify(); break; Actor java 40 case 3 GAMA 41 giveLife(sc); Monster 42 break; Plaver 43 case 4 : д 44 deletector(sc): 45 break; AB CASE 5: 62 peint Players; 41 print Munsters(); break; 59 case 6: 51 SaveToFile(F1lNane); 52 System.out.println("Data saved to *) 53 break; Case 7: System.out.println("Thank you"); 50 break; 57 default: 59 System.out.println("Invalid choice"); 59 60 61 62 } 04 65 private static void add(scanner se) OG System.out.printi: "Entorini so add player na to add monsterin *); 67 int choice-sc.nextInt();sc.nextLine(): GA 14(chocol) 69 } POBLEMS 18 CICERE LES Game Manager.java The method od Actor in the type ArrayList Actor is not applicable for the arguments [Monster) Jara67100979 in 79, 321 Incampsite conditione per types Actor and Muster with77223 RS.201 Cannotast from Actor to Monster Ir 16777872) in 158 Col:58 Cannot cost from Actor to Monster (16777372) L 164. COST The method sedHealthine is undefined for the type Monster Jaw7108964) Iun 10, 49 9 > LINE The methods in the type Anytist Aristotle Pot the numents Monster (67100741 226 C4 > Monster > TIMELINE 3. JAMA PROJECTS 130 Tinerfed test toodt rodules Build Ciled, ki you want to continue X Sura Dubu fulansard Prod Fix. Cou In 226 Col 1 ftip: UTF-8 CE O

File Edit Selection View Go Run Terminal Help GameManager.java - video game - Visual Studio Code [Administrator] 08 х nu EXPLORER Actor.java V OPEN EDITORS ELTON 7 THE 6 Actor.java Player.java Monster.java x GameManager.java v VIDEO GAME Actor.java Game Manager.java Monster.java Player.java 6 7 SUV LL Player.java Monster.java 7 GameManager.java 6 X GameManager.java > GameManager > readExistingPlayers(String) 69 70 System.out.print(s: "Enter Player Name: "); 71 String name=sc.nextLine(); 72 Player p=new Player(name); 73 actors.add(p); 74 } 75 else if (choice==2) { 76 System.out.print( 5: "Enter Monster Name: "); 77 String name=sc.nextLine(); 78 Monster m =new Monster(name); 79 actors.add(m); 80 81 } 82 83 private static void printPlayers() { 84 System.out.println(x: "\nPLAYERS\n*******\n"); 85 for(int i=0;i<actors.size(); i++) { 86 if(actors.get(i) instanceof Player) { 87 System.out.print(i+1+". "); 88 actors.get(i).display(); 89 } 90 } 91 } 92 private static void printMonsters() { 93 System.out.println(x: "\nMONSTERS\n********\n"); 94 for(int i=0;i<actors.size();i++) { 95 if(actors.get(i) instanceof Monster) { 96 System.out.print(i+1+") "); 97 actors.get(i).display(); 98 } 99 } 100 } 101 private static void modify(Scanner sc) { 102 System.out.print( 5: "Enter\ni to modify player\n2 to modify monster\n> "); 103 int choice=sc.nextInt();sc.nextLine(); 104 if(choice==1) 10C PROBLEMS 13 OUTPUT DEBUG CONSOLE Filter (e.g. text, **/*.ts. 1**/node_modules/**) Y @ ^ X ✓ GameManager.java 6 The method add(Actor) in the type ArrayList<Actor> is not applicable for the arguments (Monster) Java(67108979) [Ln 79, Col 32] Incompatible conditional operand types Actor and Monster Java(16777232) [Ln 95, Col 28] Cannot cast from Actor to Monster Java(16777372) [Ln 158, Col 51] Cannot cast from Actor to Monster Java(16777372) [Ln 164, Col 51] The method setHealth(int) is undefined for the type Monster Java(67108964) [Ln 165, Col 43] . The method add(Actor) in the type ArrayList<Actor> is not applicable for the arguments (Monster) Java(67108979) [Ln 226, Col 48] > Monster.java 7 Build failed, do you want to continue? > OUTLINE > TIMELINE Source: Debugger for Java (Extension) Proceed Fix... Cancel > JAVA PROJECTS

DOOR- X DY PIVO E 116 1 bile got Selection View Bun Jerminal Help Edit Candanager-video game Visual Studio Code [Administrator EXPLORER Actor java Played Mentejeva Gamage X V OPEN EDITORS o > comanager.java > 94 Game Manager > manisting Players/Sing! 1615 Actor.ava System.out.prints: Enter Player Mose); J0 String nextLine(); 7 Monster.java 19 103 int index-getActorIndex(name); X GameManager 199 if(index - 1) VIDEO GAME w System.out.println("Player doesn't exist1"); Actor 111 olce 112 1 O GAMA 18 { 111 Monster.java 7 Systen.out.prints Wodifyn. Mae 2. Scarein. Healthlm. Lives"); int modify extinto);s.nextLine(); Nyer.java 115 if(indify -1){ A 116 System.out.print("Enter Player Nase: "); 117 nancesc.nextLine(); 118 actors.get(index').setNamo (a): 110 } 1241 else if(modify ?) { -121 System.out.print("Enter Player sure: "); 122 int score-sc.nextInt();c.nextLine(); 123 Player p={Player) actors.get(index); . 124 p.setScore(Score): 125 126 plse if(modity--) { 127 System.out.print(s: "Enter Player health:): : 128 in health sert) TextLine(); Player D-Player) actors.get(index) p.setHealth(health); 131 1 132 else 11(modify--) { System.out.print("Enter Player lives:) 14 Int 1lves extint();sc.nextline(); 135 Player p (Player) turs.Gelinles); 120 p.setNoLives(lives); 137 133 1 199 } 140 elco 1+(choice.2) XL Sastautinter water PROELENS OUTPUT DEUS CONSOLE 13 Genehagelj The method adidactor the type Anayekt-Actors not applicable for the argument (Monster 1571089790221 Incompatible conditional operand types Actor and Monctoru[16737232 L 35 Col2 Cannot cast from Actor to Monster Juvat10777372) IL 158, col Cecast from Actor to Monster 1/773/21 161 C 511 (9) The methodsetialth is undefined for the type Monster lava 67108964) in 165. COL 431 > OUTUNE • The method add(Actor)n the type ArrayList Actor not applicable for the arguments (Monster Java(57168079) IL 226, Col 45 > TIMELINE > Monster java 7 > HAVA PROJECTS 13 AD Fiturg.de Build failed, do you want to continue? X Sources Debugger for tension) Froced FIK Cancel Ln 224. Col.ckte Speis: UTFS CRLFD) Ja RO

DCO- ... F o 99 F. 7 w д Ele Edit Selection View Go Bur Jerminal Heb Ganger 21 - video game. Visual Studio Code (Administratod DIPLORER CANA ra MT @cam Manager X OPEN EDITORS GameManager awa> ts Gamelanager> readystingPlayer hangi 112 se 1+(odify) { Actor jawa 10 Plaverjevs System.out.print(s: Enter Player lives: "); 2 OMS 134 int lives-sc.nextInt ();s.nextLine(); 135 Player p-(player) actors.get(index); X Gammengerjava 130 p.setHolives (lives): VIDEO GAME 127 Actorjava 138 Cenej 139 } 140 Monitorja else Ef(choice 2) { 141 System.out.print(s: "Enter Poster Manet "); 9 Player 142 String name-sc.nextLine(); 143 int indexgetActorIndex(none) 144 if(index 1) 145 Systom.out.println("Monster doesn't exist!"); 146 ple 147 { 141 System.out.print("Modifyin. Nan2. typen) Health 199 Int modify-st.nextInt();sc.nextLine(); 150 if(modify--1) 151 System.out.print("Enter Monster Hanc: "); 152 nanesc.nextLine(); 153 actors.get(index').setup(name): 154 2 155 else if(modify 2) { 156 System.out.print(51 Cater Monster type: "); 157 String type-st.nextLine(); 158 Monster P-(Monster) actors.get(index); 159 p.setType(type); 166 ) 161 elta 1+(rodity-)! 12 Systcut.print("Enter Monster health "); 16 ant health sc.nextInt();s.nextLine(); The Munster p-Comter) actors.get(index); 105 p.setHealth (health); 166 162 Filtar detect "V"../node odur POEMS 15 MINUT PRICES CATTPUT DE CONSOLE Gamlanager.java The method od Actor in the type ArrayList Actor is not applicabic for the arguments Monster) 13/267105979) in 79. Col321 Incompatible conditional perand types Actor and Monster lavab/772299. Col29 Cannot reactor to Monster (16777472 in 151, 511 Cannot act from Actor to Monster av 16777372) L 164. Col SIL The methodset Healthtin bundefined for the type Monster Java 7105964 ILA 165, Col 43] The method addition in the type Anytis Actus is replicable for the arguments Munster) 67108979) L 220, Col4 > Mande 8 x lui Gailed, do you want to continue Source: Debugs for Extwin Prer Fa.. Care > CHILINE > TIMELINE > JAMA PROJECTS In 2 Cols selected Space: UTCRY I R

EEL E Elc Edit Selection View Go Bun Terminal Belp Gunu Mang wika ane Visual Sudio Cod. Adsor] EXPLORER Actorjava Mayer.sava Monster.jaws 7 Gemengerjovs & X DEN FOTOS comanagejava > ts GameManages rendesisting#layer(string) 30 AGOTAV 168 } Player.jA 160 } Monster.java 170 } 19 X GameManagorjava 6 6 171 272 private static int getActorIndex(String nano) { VIDEO GAME 173 for(int 1-0 factors.size(): 1++) { Actava La . if(use().elsignelse(mare)) { Camera 17 ; Monstrava y 170 1 Players 177 } A 178 return -1; } 189 181 private static void deleteActor Scanner sc) 16) printPlayers() IB print Monsters(); 184 System.out.print("Choose a player/Munster to delete: "); 185 int i=sc.nextInt();sc.nextLine(): 180 actors.run(1-1): Systenout.println("Remed111; 185 } 189 100 privato static void givALle(Scanner sc) 101 printPlayers(): 192 System.out.prints "Choose # player to give life to another: "); 193 int i=st.nextInt();xc.nextLine(); 194 System.out.print("choose a player to receive life: "); 195 int j-sc.nextInt():sc.nextLine(): 196 Player pt-(Player) actors.Cet(1-1): 192 Player p2-(Player) alors.get(i-1); 198 pl.giveLife(p2); 198 266 201 plate static void saveToFile(String FileName) { 282 try { 282 Filchriter writer-reu Filcriter(new Filcifilciane)); امي انا الان با انس بالا her le test mode moda PROBLEMS : UU LA CONSER ✓ Gamelanager.java The method addActors in the type ArrayList Actor not applicabic for the argument: (Monster Jawa/07108979 L 79. Col32] Incompatible conditional operand types Actor and Mortes (10777234 In 95 ccl 25 Cannot cast from Actor to Monster 6/7/3/2015 al 511 Cand cast liom Actor to Meeste [167773729 in 164. Col 511 The method spt Health Kundetined for the type Monster A710206A1 R 165 Cal 431 The mathod addActor in the type ArrayList<Actor not applicable for the argument: (Monster) Java 67108979) in 226 Col 467 > Monster.jave ? Bald failed Co you want to continue? X Source Deogger for Java (Extension) Proceed F. 8 > OUTUNE > TIMEUNE > WPROIECTS 1360 Cance in 226. Cal 51 lected Space: UTF-A CRIE IR

UUT 09 X . DO... Mosteje FileFit Selection Vow Run Terminal Help Gumanager.jas - vieta - Vinical Studio Conde Administrator] u TYSLOBTR Actor.java Playera Monster away Gamelanggara X VOPIN MOTORS GameWanger.java > GameManager > readExctroPlayers/String Actor.java 284 for(Actor actors) Mayer 28s writer.write(a.info()); writer.writer: \n"): 7 Mensten 206 go 207 3 X GameManagergana E 200 writer close(); VIDEO GAME 289 Actorava 218 catch (IOException e) { Game More 211 syster.out.printin: TOException occurred!"); 212 ? Player.java 211 214 1 A 215 216 private static void readexistingplayers (String Sloane) { 717 Scanner reader: 213 try { 215 reader - new Scanner(new File(fileName)); 220 221 while(reader.hasNext()) { 222 String liner []-reader.nextline().split(repes":"); 22J If(limer.length)) 224 f 225 Monster n=ncw Monster(lincarre). Integer.parseInt(lincarr(1)). lincarr(21); 226 actors.add(a): 227 3 2211 else 229 23e player poniew Player(lincarr[8). Integer.parseInt(lincar[1]). Integer.parseInt(lincarr(21). Integer.parseInt(lincarr[3])): 231 actors.add(p): WE הרי 217 234 235 236 237 23 2:19 roader.close(); catch (FilolotFoundException e) { System.out.println( nile not found Exiting); 3 PROBLEMS 13 DTPUT DES CONST Siri yoxdur" for history Y Y PAX CameManage The method addfactor in the type Amidt-Ador is not applicable for the arguments (Monster 7102079 | 70 Col32) Incompatible conditional operand types Actor and Monster Java/167772321 LA 05. Col 28 Cannot cast from Actor to Monster 16777372) IL 158, Col51) Cannot cast from Actor to Munster 16717972) IL 104 of 5 The methodselilintis undelines for the type Monster afh7100961) 165.col.40 The method addfactor in the type Anyt Actor is not applicable for the arguments/Monster 5700225.00 > Monster.java 9 Bulid talled do you want to contes! x > OUTUNE Suur: Debugger for Extension Pred Fin. Canced 52 > TIMEUNE > UM PROJECTS 01140 * in 22 (51celerte Spares UTF-CHIF )