create a class in Java for a Plane
the class will include
String Data Fields for the make, model, and year. (as well as mutators and accessors)
Defined constructor and copy constructor.
there must be a toString method as well as a copy method.
runner program
the program will create an array for Plane class. The size of the array will be set to user input. then the user will input the information into each plane object in the array. Asking the user to enter the make, model, and year. then it will output all the planes using the tostring method
1.Plane Class
public class Plane {
String make, model,year;
public String getMake() {
return make;
}
public void setMake(String make) {
this.make = make;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public String getYear() {
return year;
}
public void setYear(String year) {
this.year = year;
}
// Constructor
public Plane(String make, String model,
String year)
{
this.make = make;
this.model = model;
this.year = year;
}
// Used to print Plane details in main()
public String toString()
{
return "Make of Plane:"+ this.make + "Model:" +
this.model + " Year:" + this.year;
}
}
2.Main Plane Class
import java.util.Scanner;
public class PlaneMain {
public static void main(String[] args)
{
// asking the user how many they would like to
add
int choice;
Plane[] StArray;
Plane p = new Plane(null, null,
null);
System.out.print("How many new Planes are you going to
add: ");
Scanner in = new Scanner(System.in);
choice = Integer.parseInt(in.nextLine());
//creating Plane array of chosen
amount
StArray = new Plane[choice];
//asking user for the variables and
trying to display them?
for (int x = 1; x <
StArray.length; x++)
{
System.out.print("Enter the Make of plane " + ":
");
p.make = in.next();
System.out.print("Enter the Model of plane " +":
");
p.model = in.next();
System.out.print("Enter the Year of plane " +":
");
p.year = in.next();
System.out.println(p.toString());
}
}
create a class in Java for a Plane the class will include String Data Fields for...
Programming Language is Java 1. Create a class to describe a car. Include fields like: make, model, year and color. Add all the accessors and mutators for these fields. Add a constructor that can initialize the fields. 2. Create a class that will enable you to handle standard mail communication with a customer. Add all accessors and mutators, as well as a constructor. Add a method named fullAddress that will return the address formatted for a standard mail. Add a...
Create a class House with the private fields: numberOfUnits of the type int, yearBuilt of the type int, assessedPrice of the type double. A constructor for this class should have three arguments for initializing these fields. Add accessors and mutators for all fields except a mutator for yearBuilt, and the method toString. Create a class StreetHouse which extends House and has additional fields: streetNumber of the type int, homeowner of the type String, and two neighbors: leftNeighbor and rightNeighbor, both...
[JAVA] Program: Design a Ship class that the following members: A field for the name of the ship (a string) o A field for the year the the ship was built (a string) o A constructor and appropriate accessors and mutators A toString method that displays the ship's name and the year it was built Design a CruiseShip class that extends the Ship class. The CruiseShip class should have the following members: A field for the maximum number of passengers...
Write a java program that creates a class Car. Class Car contains the following private member fields: make, model, year, and miles. The class Car has a constructor that takes as arguments the car make, model, and year. In addition, the constructor sets miles to 100 as default. Class Car has accessors and mutators to get and set the make, model, year and miles on the car. The program should complete the following tasks: Ask the user to enter make,...
create a Person class with two fields (name(String), age(int)) create all the required methods such as the accessors, mutators, toString(),constructors etc. Use the comparable interface and implement the compareTo method such that the person objects can be compared and sorted according to their age.
The object class should be a Student with the following attributes: id: integer first name: String last name: String write the accessors, mutators, constructor, and toString(). In your main test class you will write your main method and do the following things: Create an array of Student objects with at least 5 students in your array. Write a sort method that must be your original work and included in the main class. The sort method will sort based on student...
In java How to get started; Create a class called Card. The card has three fields; a value , a suit and a face. The card class has a constructor that takes three values for the three fields. Create a no-args constructor. The Card class has three get methods to return the values of each of the fields. The Card class has a toString( ) method. The Card class has a compareTo( ) method that uses the value of the...
Create a simple Java class for a Password with the following requirements: This program will have a header block comment with your name, the course and section, as well as a brief description of what the class does. One String property: password (protected to only allow secure passwords) o A secure password must be at least 8 characters in length o A secure password must have three of the following four requirements: A lower case letter ...
Create the following program in java please Write a class Store which includes the attributes: store name and sales tax rate. Write another class encapsulating a Book Store, which inherits from Store. A Book Store has the following additional attributes: how many books are sold every year and the average price per book. Code the constructor, accessors, mutators, toString and equals method of the super class Store and the subclass Book Store; In the Book Store class, also code a...
I need this in java please Create an automobile class that will be used by a dealership as a vehicle inventory program. The following attributes should be present in your automobile class: private string make private string model private string color private int year private int mileage. Your program should have appropriate methods such as: default constructor parameterized constructor add a new vehicle method list vehicle information (return string array) remove a vehicle method update vehicle attributes method. All methods...