Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You need to put the classes in bluejay. Edit the final superherovsvillain with ArrayList to enter in as many superhero and villains make sure it

image text in transcribed

You need to put the classes in bluejay. Edit the final superherovsvillain with ArrayList to enter in as many superhero and villains make sure it battles correctly. PLEASE USE JAVA AND FOLLOW THE INSTRUCTIONS CAREFULLY! THANK YOU! EDIT THE SUPERHEROVSVILLAIN ON THE BOTTOM.

Superhero Class

public class Superhero{ private String alias; private String superpower; private int health;

public Superhero(){ alias= "unkown"; superpower= "unknown"; health= 50; } public Superhero(String alias1, String superpower1,int health1 ){ alias=alias1; superpower=superpower1; if(health1>=0 && health150) health=25; } public void setalias(String alias1){ alias=alias1; } public void setsuperpower(String superpower1){ superpower=superpower1; } public void sethealth(int health1){ if (health1>=0 && health150){ health=25; } } public String getalias(){ return alias; } public String getsuperpower(){ return superpower; } public int gethealth(){ return health; } public String toString(){ String info = "Alias: " + alias + " " + "Superpower: " + superpower+ " " + "Health: " + health + " "; return info; } public int numberofPeopleSaved(){ int numberpeoplesaved= (int) (101*Math.random()); return numberpeoplesaved; } public void harmtoHealth(){ health= health-5; if (health

Villain Class

import java.lang.Math; public class Villain{ private String alias; private String evilpower; private int health;

public Villain(){ alias= "unkown"; evilpower= "unknown"; health= 75; } public Villain(String alias2, String superpower2,int health2 ){ alias=alias2; evilpower=superpower2; if(health2>=0 && health275) health=50; } public void setalias(String alias2){ alias= alias2; } public void setsuperpower(String superpower2){ evilpower= superpower2; } public void sethealth(int health2){ if (health2>=0 && health275) health=50; } public String getalias(){ return alias; } public String getsuperpower(){ return evilpower; } public int gethealth(){ return health; } public String toString(){ String info = "Alias: " + alias + " " + "Superpower: " + evilpower+ " " + "Health: " + health + " "; return info; } public int numberofPeopleHarmed(){ int numberpeopleharmed= (int) (101*Math.random()); return numberpeopleharmed; } public void harmtoHealth(){ health= health-10; if (health

SuperherovsVillain

import java.util.Scanner;

public class SuperHeroVSVillain{ public static void main (String[]args){ Superhero sh = new Superhero(); Villain v = new Villain(); Scanner reader = new Scanner(System.in); System.out.print("Superhero alias: "); sh.setalias(reader.nextLine()); System.out.print("Villain alias: "); v.setalias(reader.nextLine()); System.out.print("Superhero power: "); String shpower= reader.nextLine(); sh.setsuperpower(shpower); System.out.print("Villain power: "); String vpower= reader.nextLine(); v.setsuperpower(vpower); System.out.print("Superhero health: "); int shhealth= (reader.nextInt()); sh.sethealth(shhealth); System.out.print("Villain health: "); int vhealth=(reader.nextInt()); v.sethealth(vhealth); System.out.println(""); System.out.println("For years the world has been tormented by the evil " + v.getalias()+"."); System.out.println("Now the fate of the world rests in the hands of "+ sh.getalias()+"."); System.out.println("With the his power of "+ sh.getsuperpower()+ " he may be able to win."); System.out.println("However, the evil power of " + v.getsuperpower()+ " is formidable as well."); System.out.println("Now the two will battle to determine the fate of the world."); System.out.println(""); while(shhealth>0&&vhealth>0){ int sf = sh.fight(); int vf = v.fight(); if(sf>vf) v.harmtoHealth(); else if(vf>sf) sh.harmtoHealth(); System.out.println(sh.toString()); System.out.println(v.toString()); System.out.println(" "); shhealth = sh.gethealth(); vhealth = v.gethealth(); } if(shhealth>vhealth) System.out.println(sh.getalias() + " won! " + sh.numberofPeopleSaved() + " people were saved. THE WORLD IS SAVED!!!"); else System.out.println(v.getalias() + " won! " + v.numberofPeopleHarmed() + " people were harmed. THE WORLD IS DOOMED!!!"); } }

Activity 3: Update your SuperHero vs. Villain story so that the user can enter in as many Super Heroes and as many Villains as they want. Then during the battle one Super Hero and one Vill ain will battle until one of them reaches a health of zero. The winner will then battle the next Super Hero or Villain in the list. The last Super Hero or Vill ain will determine if the Super Heroes or Vill ains won as a whole unit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions