(Solved) : Exercises 05 Battlefield Class Bonus Battlefieldjava Task Create Class Battlefield Object Q44040944 . . .
Exercises 05 (BattleField class) [BONUS]: BattleField.java Inthis task, create a class for a BattleField object, that is used todisplay a grid of Alien objects, and one Hero3 object. Your mainmethod should instantiate the BattleField object (you may rely on adefault constructor only), which creates a fixed 2D array of Alienobjects, and displays them), and creates a Hero3 object anddisplays it (roughly arranged according to the standard “SpaceInvaders” paradigm). Battlefield should be an AGGREGATION of Alienobjects and the Hero3 object. BattleField should be able to alsodisplay itself using a “draw” method (i.e. your class should definea draw method). // class variables // must have a Point2D.Doubleobject for position // constructors // relevant accessor/mutatormethods // must have draw method // (this defines the look andshape of your Alien) Alien You have freedom over the look of Alienand the BattleField objects, as long as there is only one Hero3,and multiple Alien objects in the BattleField scene.
import imagePackage.RasterImage;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Shape;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.io.PrintStream;
public class BattleField {
// BattleField class creates the layout of a gridof Aliens, and the Hero3 object,
// it then has a display method to create theseelements in a Graphics2D object
// basic constructor for BattleField (positions andcreates Hero3 and Alien objects
// Hint: store Aliens in a 2D array (as a field ofBattleField
public BattleField() {
// default constructor – you canassume a BattleField is always constructed as default
}
public void displayBattleField(Graphics2D g) {
// method to display aBattleField
// If you have trouble with a 2Darray of Aliens, try to make a single 1D array instead…
}
public static void main(String[] args) {
// create a RasterImage object, getits Graphics2D object
// create the BattleField objectand display it using the Graphics2D object from the
// RasterImage
}
}
Expert Answer
Answer to Exercises 05 (BattleField class) [BONUS]: BattleField.java In this task, create a class for a BattleField object, that i…
OR