Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package oop;
- class superHero
- {
- String heroName; //name of the superhero
- String realName; //alias name
- boolean human; //is he/she a human
- String powers; //special abilities
- String weakness; //not able to do
- int createdYear; //when did he/she appear
- String nemesis; //worst enemy
- public void setHName(String heroName)
- {
- this.heroName = heroName;
- }
- public void setRName(String realName)
- {
- this.realName = realName;
- }
- public void setHuman(boolean human)
- {
- this.human = human;
- }
- public void setPowers(String powers)
- {
- this.powers = powers;
- }
- public void setWeakness(String weakness)
- {
- this.weakness = weakness;
- }
- public void setCYear(int createdYear)
- {
- this.createdYear = createdYear;
- }
- public void setNemesis(String nemesis)
- {
- this.nemesis = nemesis;
- }
- public String getHName()
- {
- return this.heroName;
- }
- public String getRName()
- {
- return this.realName;
- }
- public boolean getHuman()
- {
- return this.human;
- }
- public String getPowers()
- {
- return this.powers;
- }
- public String getWeakness()
- {
- return this.weakness;
- }
- public int getCYear()
- {
- return this.createdYear;
- }
- public String getNemesis()
- {
- return this.nemesis;
- }
- }
- public class superHeroes {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- superHero[] array = new superHero[10];
- for(int i=0; i<10; i++)
- {
- array[i] = new superHero();
- int choice = -1;
- int counter = 0;
- while(choice!=4)
- {
- choice = TextIO.getInt(); //accept choice as an integer
- if(choice == 1)
- {
- System.out.println("Add the name of a superhero");
- array[counter].setHName(TextIO.getWord());
- System.out.println("What's the hero's real name?");
- array[counter].setRName(TextIO.getWord());
- System.out.println("Is he/she a human");
- array[counter].setHuman(TextIO.getBoolean());
- System.out.println("What is his/her special ability");
- array[counter].setPowers(TextIO.getWord());
- System.out.println("What isn't he/she able to do?");
- array[counter].setWeakness(TextIO.getWord());
- System.out.println("Enter the year the hero was created");
- array[counter].setCYear(TextIO.getInt());
- System.out.println("Worst enemy ever");
- array[counter].setNemesis(TextIO.getWord());
- counter++;
- }
- if(choice == 2)
- {
- System.out.println("Print detail about the superhero");
- System.out.println(array[counter].getHName());
- System.out.println(array[counter].getRName());
- System.out.println(array[counter].getHuman());
- System.out.println(array[counter].getPowers());
- System.out.println(array[counter].getWeakness());
- System.out.println(array[counter].getCYear());
- System.out.println(array[counter].getNemesis());
- counter++;
- }
- if(choice == 3)
- {
- char choice3 = 'A';
- choice3 = TextIO.getChar();
- if(choice3 == 'A')
- {
- array[counter].setCYear(TextIO.getInt());
- System.out.println(array[counter].getHName() + " since " + array[counter].getCYear());
- }
- if(choice3 == 'B')
- {
- array[counter].setNemesis(TextIO.getWord());
- System.out.println(array[counter].getHName() + "'s worst enemy is " + array[counter].getNemesis());
- }
- if(choice3 == 'C')
- {
- array[counter].setPowers(TextIO.getWord);
- System.out.println(array[counter].getHName() + "'s special ability is " + array[counter].getPowers());
- }
- }
- if(choice == 4)
- {
- System.out.println("Goodbye!");
- }
- }
- }
- } //main ends here
- } //class ends here
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement