Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Lab 7 This lab makes use of the GraphicsFrame class and the Drawable interface.

ID: 3557570 • Letter: L

Question

Lab 7

This lab makes use of the GraphicsFrame class and the Drawable interface. Your missions is to create the class Airplane. Each Airplane object should store the following information (fields):

manufacturer
modelNumber
maximumSpeed // in knots
maximumFuel // in gallons
grossWeight // in lbs
emptyWeight

Each airplane object should have the following behaviors (methods):

public float usefulLoad() // this is the grossWeight - emptyWeight
public float usefulLoadWithFuel( in gallons ) // this is the useful load - gallons x 6. The programmer user will pass in the number of gallons on board.

public void draw( Graphics g ) // this method will make a line drawing of an airplane. You don't have to get fancy. Do use drawString() to display the Airplanes information.

You will also need a constructor to initialize the fields.

Make sure you look at the example of GraphicsFrame. You will need to put the GraphicsFrame, Drawable, Airplane, and the test driver all in one folder. The files need to 'see' each other. You can just add on the the test driver for the example.

Some starter code for the Airplane class:

public class Airplane implements Drawable

{

// fields

// constructor or constructors

// general methods

}

Explanation / Answer

public class Airplane implements Drawable
{
   //fields
   pulbic String manufacturer;
   public String modelNumber;
   public float maximumSpeed ; // in knots
   public float maximumFuel ; // in gallons
   public float grossWeight ; // in lbs
   public float emptyWeight;

   //constructors
   public Airplane( String x, String y, float z, float a, float b, float c )
   {
       manufacturer = x;
       modelNumber = y;
       maximumSpeed = z;
       maximumFuel = a;
       grossWeight = b;
       emptyWeight = c;
   }
  
  
   //general methods
   public float usefulLoad() { return grossWeight - emptyWeight; }
   public float usefulLoadWithFuel( float gallons ) { return usefulLoad - (6*gallons); }
   public void draw( Graphics g ) { // your drawing here
   }
   public void drawstring(){
   System.out.println("manufacturer: " + manufacturer);
   System.out.println("modelNumber: " + modelNumber);
   System.out.println("maximumSpeed: " + maximumSpeed);
   System.out.println("maximumFuel: " + maximumFuel);
   System.out.println("grossWeight: " + grossWeight);
   System.out.println("emptyWeight: " + emptyWeight);
   }
  
}