Question

Determine how all of your classes are related, and create a complete UML class diagram representing...

Determine how all of your classes are related, and create a complete UML class diagram representing your class structure. Don't forget to include the appropriate relationships between the classes.

GameDriver

import java.util.Scanner;

public class GameDriver {

Scanner in = new Scanner(System.in);

public static void main(String[] args) {

Move move1 = new Move("Vine Whip", "Grass", 45, 1.0f);

Move move2 = new Move("Tackle", "Normal", 50, 1.0f);

Move move3 = new Move("Take Down", "Normal", 90, 0.85f);

Move move4 = new Move("Razor Leaf", "Grass", 55, 0.95f);

Monster monster = new Monster("Bulbasaur", "Grass", 240, 45, 49, 49, move1, move2, move3, move4);

HumanPlayer player = new HumanPlayer(monster);

move1 = new Move("Scratch", "Normal", 40, 1.0f);

move2 = new Move("Ember", "Fire", 40, 1.0f);

move3 = new Move("Peck", "Flying", 35, 1.0f);

move4 = new Move("Fire Spin", "Fire", 35, 0.85f);

monster = new Monster("Torchic", "Fire", 240, 45, 60, 40, move1, move2, move3, move4);

CPUPlayer enemy = new CPUPlayer(monster);

while ((!player.hasLost()) && (!enemy.hasLost())) {

System.out.println("");

System.out.printf("%s has %d HP\n", player.getMonster().getName(), player.getMonster().getHP());

System.out.printf("%s has %d HP\n", enemy.getMonster().getName(), enemy.getMonster().getHP());

int playerMove = player.chooseMove();

int enemyMove = enemy.chooseMove();

if (player.isFasterThan(enemy)) {

player.attack(enemy, playerMove);

if (!enemy.hasLost()) {

enemy.attack(player, enemyMove);

}

} else {

enemy.attack(player, enemyMove);

if (!player.hasLost()) {

player.attack(enemy, playerMove);

}

}

}

if (player.hasLost()) {

System.out.printf("You and %s have lost the battle.\n", player.getMonster().getName());

} else {

System.out.printf("You and %s are victorious!\n", player.getMonster().getName());

}

}

}

HumanPlayer

import java.util.Random;

import java.util.Scanner;

public class HumanPlayer extends Player

{

   HumanPlayer(Monster monster)

   {

this.monster=monster;

   }

   public int chooseMove()

   {

System.out.println("1. Vine Whip");

System.out.println("2. Tackle");

System.out.println("3. Tak Down");

System.out.println("4. Razor Leaf");

System.out.print("Which Move(1-4): ");

int choice=input.nextInt();

while(choice<0 || choice >4)

{

System.out.println("Invalid move!");

System.out.print("Enter your move(1-4): ");

}

return choice;

   }

}

Monster

public class Monster{

   private String name;

   private String type;

   private int hp;

   private int speed;

   private int attack;

   private int defence;

   private Move move1;

   private Move move2;

   private Move move3;

   private Move move4;

public Monster(String name,String type,int hp,int speed,int attack,int defence,Move move1,Move move2,Move move3,Move move4){

   this.name = name;

   this.type=type;

   this.hp=hp;

   this.speed=speed;

   this.attack=attack;

   this.defence=defence;

   this.move1=move1;

   this.move2=move2;

   this.move3=move3;

   this.move4=move4;

   }

   String getName(){

return name;

   }

   int getHP(){

return hp;

   }

   void setHP(int hp){

this.hp=hp;

   }

   int getSpeed(){

return speed;

   }

   int getAttack(){

return attack;

   }

   int getDefense(){

return defence;

   }

   Move getMove1(){

return move1;

   }

   Move getMove2(){

return move2;

   }

   Move getMove3(){

return move3;

   }

   Move getMove4(){

return move4;

   }

   }

Move

public class Move{

   private float accuracy;

   private int power;

   private String type;

   private String name;

   public Move(final String name,final String type,final int power,final float accuracy){

   this.name=name;

   this.type=type;

   this.power=power;

   this.accuracy=accuracy;

   }

   float getAccuracy()

   {

return accuracy;

   }

   int getPower()

   {

return power;

   }

   String getName()

   {

return name;

   }

   String getType()

   {

return type;

   }

}

Player

import java.util.Random;

import java.util.Scanner;

public class Player{

   Random rand=new Random();

   Scanner input=new Scanner(System.in);

   protected Monster monster;

   public boolean hasLost()

   {

if(monster.getHP()<=0)

return true;

else{

return false;

   }

   public Monster getMonster()

   {

return monster;

   }

   public int chooseMove()

   {

return 0;

   }

   public boolean isFasterThan(Player enemy)

   {

if(this.monster.getSpeed()>enemy.getMonster().getSpeed())

return true;

else

return false;

   }

public void attack(Player enemy, int playerMove)

   {

float acc=rand.nextFloat();

float movAcc=0;

int movPower=0;

if(playerMove==1)

{

movAcc=this.getMonster().getMove1().getAccuracy();

movPower=this.getMonster().getMove1().getPower();

System.out.println(this.getMonster().getName()+" uses "+this.getMonster().getMove1().getName());

}

else if(playerMove==2)

{

movAcc=this.getMonster().getMove2().getAccuracy();

movPower=this.getMonster().getMove2().getPower();

System.out.println(this.getMonster().getName()+" uses "+this.getMonster().getMove2().getName());

}

else if(playerMove==3)

{

movAcc=this.getMonster().getMove3().getAccuracy();

movPower=this.getMonster().getMove3().getPower();

System.out.println(this.getMonster().getName()+" uses "+this.getMonster().getMove3().getName());

}

else if(playerMove==4)

{

movAcc=this.getMonster().getMove4().getAccuracy();

movPower=this.getMonster().getMove4().getPower();

System.out.println(this.getMonster().getName()+" uses "+this.getMonster().getMove4().getName());

}

   if(acc<movAcc)

{

int damageDealth = this.getMonster().getAttack() + movPower - enemy.getMonster().getDefense();

System.out.println(this.getMonster().getName()+" hit for "+damageDealth+" points of damage");

enemy.getMonster().setHP(enemy.getMonster().getHP()-damageDealth);

}

   }

}

CPUPlayer

import java.util.Random;

public class CPUPlayer extends Player

{

   CPUPlayer(Monster monster)

   {

this.monster=monster;

   }

   public int chooseMove(){

return rand.nextInt(4)+1;

   }

}

Important: Please submit pictures of the UML diagram

Homework Answers

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Provide A UML for the Following CODE public class Employee{ public String strName, strSalary; public Employee(){...
Provide A UML for the Following CODE public class Employee{ public String strName, strSalary; public Employee(){    strName = " ";    strSalary = "$0";    } public Employee(String Name, String Salary){    strName = Name;    strSalary = Salary;    } public void setName(String Name){    strName = Name;    } public void setSalary(String Salary){    strSalary = Salary;    } public String getName(){    return strName;    } public String getSalary(){    return strSalary;    } public String...
<<<<<<<< I need only the UML diagram for ALL classes.Java???????????? public class House {    private...
<<<<<<<< I need only the UML diagram for ALL classes.Java???????????? public class House {    private int houseNumber;    private int bedrooms;    private int sqFeet;    private int year;    private int cost;    public House(int houseNumber,int bedrooms,int sqFeet, int year, int cost)    {        this.houseNumber = houseNumber;        this.bedrooms = bedrooms;        this.sqFeet = sqFeet;        this.year = year;        this.cost = cost;    }    public int getHouseNumber()    {        return houseNumber;    }   ...
Complete the // TODO sections in the EasyRental class. Create a method that implements an iterative...
Complete the // TODO sections in the EasyRental class. Create a method that implements an iterative sort that sorts the vehicle rentals by color in ascending order (smallest to largest) Create a method to binary search for a vehicle based on a color, that should return the index where the vehicle was found or -1 You are comparing Strings in an object not integers. Ex. If the input is: brown red white blue black -1 the output is: Enter the...
Q:Could you fill in the blank。 class Employee{ // field private String name; private (1) _float__...
Q:Could you fill in the blank。 class Employee{ // field private String name; private (1) _float__ salary; // constructor (2) ________________________________________ // method public (3) __String____ getName( ){ return name; } public float getSalary( ){ return Salary; } public (4) ________ compare( (5) _________________ { (6) ____________________________________ } }// class Employee public class EmployeeUI{ public static void main(String[ ] args){ Employee e1 = new Employee(“William”); Employee e2 = new Employee(“Rchard”); if(Employee.compare(e1, e2)) System.out.println(“same employee”); else System.out.println(“different employee”); } }//class EmployeeUI
please fix code to delete by studentname import java.util.Scanner; public class COurseCom666 {     private String...
please fix code to delete by studentname import java.util.Scanner; public class COurseCom666 {     private String courseName;     private String[] students = new String[1];     private int numberOfStudents;     public COurseCom666(String courseName) {         this.courseName = courseName;     }     public String[] getStudents() {         return students;     }     public int getNumberOfStudents() {         return numberOfStudents;     }     public void addStudent(String student) {         if (numberOfStudents == students.length) {             String[] a = new String[students.length + 1];            ...
import java.util.Scanner; public class AroundTheClock {    public static void main(String[] args)    {       ...
import java.util.Scanner; public class AroundTheClock {    public static void main(String[] args)    {        Scanner input = new Scanner(System.in);        int departureTime = input.nextInt();        int travelTime = input.nextInt();        int arrivalTime;            departureTime =12;            departureTime = 0;            arrivalTime = (int) (departureTime + travelTime);            (arrivalTime = (arrivalTime >=12));            if (arrivalTime = arrivalTime %12)            {            System.out.println(arrivalTime);...
In java create a dice game called sequences also known as straight shooter. Each player in...
In java create a dice game called sequences also known as straight shooter. Each player in turn rolls SIX dice and scores points for any sequence of CONSECUTIVE numbers thrown beginning with 1. In the event of two or more of the same number being rolled only one counts. However, a throw that contains three 1's cancels out player's score and they mst start from 0. A total of scores is kept and the first player to reach 100 points,...
I am a beginner when it comes to java codeing. Is there anyway this code can...
I am a beginner when it comes to java codeing. Is there anyway this code can be simplified for someone who isn't as advanced in coding? public class Stock { //fields private String name; private String symbol; private double price; //3 args constructor public Stock(String name, String symbol, double price) { this.name = name; this.symbol = symbol; setPrice(price); } //all getters and setters /** * * @return stock name */ public String getName() { return name; } /** * set...
How do I get this portion of my List Iterator code to work? This is a...
How do I get this portion of my List Iterator code to work? This is a portion of the code in the AddressBookApp that I need to work. Currently it stops at Person not found and if it makes it to the else it gives me this Exception in thread "main" java.lang.NullPointerException    at AddressBookApp.main(AddressBookApp.java:36) iter.reset(); Person findPerson = iter.findLastname("Duck"); if (findPerson == null) System.out.println("Person not found."); else findPerson.displayEntry(); findPerson = iter.findLastname("Duck"); if (findPerson == null) { System.out.println("Person not found.");...
in java need uml diagram import java.util.ArrayList; import java.util.*; public class TodoList { String date=""; String...
in java need uml diagram import java.util.ArrayList; import java.util.*; public class TodoList { String date=""; String work=""; boolean completed=false; boolean important=false; public TodoList(String a,String b,boolean c,boolean d){ this.date=a; this.work=b; this.completed=c; this.important=d; } public boolean isCompleted(){ return this.completed; } public boolean isImportant(){ return this.important; } public String getDate(){ return this.date; } public String getTask(){ return this.work; } } class Main{ public static void main(String[] args) { ArrayList<TodoList> t1=new ArrayList<TodoList>(); TodoList t2=null; Scanner s=new Scanner(System.in); int a; String b="",c=""; boolean d,e; char...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT