Create a script called battle.js. In this script code the following: A. Class an
ID: 3757431 • Letter: C
Question
Create a script called battle.js. In this script code the following: A. Class and Constructor Creation (25 Points) Player Class Create a constructor function or ES6 class for a Player object. The Player object should have the following properties Name: Holds the name of the player. Pass into the constructor. Health: Defaults to 10, do not pass into the constructor, just define and set to 10 in the constructor Strength: Defaults to 2 Weapons: An array of weapons objects. Should be passed into the constructor Weapon Class Create a constructor function or ES6 class for a Weapon object. It should have the following properties: Name: Holds the name of the weapon. Passed into the constructor. Damage: Defaults to a random number between 1 and 5, do not pass into the constructor, just define in the constructor and set it.Explanation / Answer
Player_Piece has to assign the color and position to the objects which is the player piece on the game board of snakes and ladders. It also has to move the pieces
Player_Symbol is the class for the tic tac toe game it assigns and holds the players symbol, (either a nought or a cross) and positions.
public class Player {
private String PlayerName;
public Player(String name) {
PlayerName = name;
}
/**
* This set method sets the name of the player.
*
* @param Takes in a String as name.
*/
public void setName(String name) {
this.PlayerName = name;
}
/**
* This get method returns the String value of player name.
*
* @return PlayerName, a String value.
*/
public String getName() {
return PlayerName;
}
}
create a class Weapon similar to this:
public abstract class zWeapon {
//weapon attack info
protected boolean attacking = false;
protected int damage;
protected long startTime;
protected long delay;
protected long elapsed;
public void attack(double X, double Y, double angleShoot)
{
if(attacking) return;
startTime = System.nanoTime();
attacking = true;
useWeapon();
}
protected abstract void useWeapon();
public void update()
{
if(attacking)
{
elapsed = (System.nanoTime()-startTime) / 1000000;
if(elapsed >= delay)
attacking = false;
}
}
protected abstract void draw();}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.