Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercises 05 (BattleField class) [BONUS]: BattleField.java In this task, create a class for a BattleField object, that is used to display a grid of Alien

Exercises 05 (BattleField class) [BONUS]: BattleField.java In this task, create a class for a BattleField object, that is used to display a grid of Alien objects, and one Hero3 object. Your main method should instantiate the BattleField object (you may rely on a default constructor only), which creates a fixed 2D array of Alien objects, and displays them), and creates a Hero3 object and displays it (roughly arranged according to the standard Space Invaders paradigm). Battlefield should be an AGGREGATION of Alien objects and the Hero3 object. BattleField should be able to also display itself using a draw method (i.e. your class should define a draw method). // class variables // must have a Point2D.Double object for position // constructors // relevant accessor/mutator methods // must have draw method // (this defines the look and shape of your Alien) Alien You have freedom over the look of Alien and 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 grid of Aliens, and the Hero3 object, // it then has a display method to create these elements in a Graphics2D object // basic constructor for BattleField (positions and creates Hero3 and Alien objects // Hint: store Aliens in a 2D array (as a field of BattleField public BattleField() { // default constructor - you can assume a BattleField is always constructed as default } public void displayBattleField(Graphics2D g) { // method to display a BattleField // If you have trouble with a 2D array of Aliens, try to make a single 1D array instead... } public static void main(String[] args) { // create a RasterImage object, get its Graphics2D object // create the BattleField object and display it using the Graphics2D object from the // RasterImage

} }

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