USING JAVA Create a Plane class This class will represent a

USING JAVA: Create a Plane class. This class will represent a plane in our system. It should contain a constructor, two instance variables (an Airline enumeration, and a String) and three methods (getAirline, getModel, toString)

The constructor will take an Airline and String and use them to set up the instance variables.

getAirline(): will return the Airline of the plane (e.g., Airline.United).

getModel(): will return a String containing the model of the plane (e.g., \"Boring 747\").

toString(): will return the name of the plane\'s airline (e.g., \"Deltaway\"), followed by a star (\" * \"), and the model of the plane (e.g., \"Boring 747\").

Solution

Hi, Please find my code.

Please let me know in case of any issue.

########### Plane.java ###############

enum Airline {

UNITED,

AITINDIA,

INDIGO,

GETAIR,

Deltaway

}

public class Plane {

  

// instance variables

   private String model;

   private Airline airline;

  

// constructor

   public Plane(Airline airline, String model){

       this.airline = airline;

       this.model = model;

   }

  

   public Airline getAirline(){

       return airline;

   }

  

   public String getModel(){

       return model;

   }

  

@Override

   public String toString() {

       return \"Airline: \"+airline+\"* Model: \"+model;

   }

}

################ TestPlane.java ################

public class TestPlane {

  

   public static void main(String[] args) {

      

       // creating an object of Plane

       Plane plane = new Plane(Airline.UNITED , \"Boring 747\");

      

       System.out.println(plane.toString());

   }

}

/*

Sample Output:

Airline: UNITED* Model: Boring 747

*/

USING JAVA: Create a Plane class. This class will represent a plane in our system. It should contain a constructor, two instance variables (an Airline enumerati
USING JAVA: Create a Plane class. This class will represent a plane in our system. It should contain a constructor, two instance variables (an Airline enumerati

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site