create a class called ground Vehicle description wheelspasse

create a class called ground Vehicle (description, wheels,passenger capacity, weight ) . Create two sub classes car ( door, cylinder, color, make), cycle (engine size length height) that use vehicle.
write a method to accept an array of car and display each object

slove this in java language

Solution

Vehicle Class:


public class Vehicle
{
  


public Vehicle() {
  
       this.Wheels=0;
       this.PassengerCapacity=0;
       this.Weight=0.0;
      
   }
public String Description ;
public int Wheels;
public int PassengerCapacity;
public double Weight;
public String getDescription() {
   return Description;
}
public void setDescription(String description) {
   Description = description;
}
public int getWheels() {
   return Wheels;
}
public void setWheels(int wheels) {
   Wheels = wheels;
}
public int getPassengerCapacity() {
   return PassengerCapacity;
}
public void setPassengerCapacity(int passengerCapacity) {
   PassengerCapacity = passengerCapacity;
}
public double getWeight() {
   return Weight;
}
public void setWeight(double weight) {
   Weight = weight;
}
}

Car Class:


public class Car extends Vehicle {

  

   public Car() {
       super.Wheels=4;
       this.Door=0;
       this.Cylinder=0;
   }
   public int Door;
public int Cylinder;
public String Color;
public String Make;
public int getDoor() {
   return Door;
}
public void setDoor(int door) {
   Door = door;
}
public int getCylinder() {
   return Cylinder;
}
public void setCylinder(int cylinder) {
   Cylinder = cylinder;
}
public String getColor() {
   return Color;
}
public void setColor(String color) {
   Color = color;
}
public String getMake() {
   return Make;
}
public void setMake(String make) {
   Make = make;
}

}

Cycle Class:


public class Cycle extends Vehicle {

  
  
   public double EngineSize;
public double Length;
public double Height;
public double getEngineSize() {
   return EngineSize;
}
public void setEngineSize(double engineSize) {
   EngineSize = engineSize;
}
public double getLength() {
   return Length;
}
public void setLength(double length) {
   Length = length;
}
public double getHeight() {
   return Height;
}
public void setHeight(double height) {
   Height = height;
}

}

Main Class:

public class TestMain {

   public static void main(String[] args) {
       // TODO Auto-generated method stub

      
       Car [] CarArray=new Car[2];
       for(int i=0;i<CarArray.length;i++)
           CarArray[i]=new Car();
       {
          
       }
       CarArray[0].Description=\"Sedan\";
       CarArray[0].Wheels=4;
       CarArray[0].PassengerCapacity=5;
       CarArray[0].Weight=800;
       CarArray[0].Door=5;
       CarArray[0].Color=\"Red\";
       CarArray[0].Cylinder=2;
       CarArray[0].Make=\"2009\";
      
       CarArray[1].Description=\"SUV\";
       CarArray[1].Wheels=4;
       CarArray[1].PassengerCapacity=7;
       CarArray[1].Weight=1000;
       CarArray[1].Door=5;
       CarArray[1].Color=\"Black\";
       CarArray[1].Cylinder=2;
       CarArray[1].Make=\"2014\";
       System.out.println(\"Car 1 is: \"+CarArray[0].getDescription()+\" has \"+CarArray[0].getWheels()+\" Wheels \"+\"Passenger Capacity is : \"+CarArray[0].getPassengerCapacity()+\" Passenger \"+\" and Weight is: \"+CarArray[0].getWeight()
               +\" and it has \"+CarArray[0].getDoor()+\" doors \"+\" and color is \"+CarArray[0].getColor()+\" and no of Cylinders are \"+CarArray[0].getCylinder()+\" and make year is \"+CarArray[0].getMake());
      
      
       System.out.println(\"Car 2 is: \"+CarArray[1].getDescription()+\" has \"+CarArray[1].getWheels()+\" Wheels \"+\"Passenger Capacity is : \"+CarArray[1].getPassengerCapacity()+\" Passenger \"+\" and Weight is: \"+CarArray[1].getWeight()
               +\" and it has \"+CarArray[1].getDoor()+\" doors \"+\" and color is \"+CarArray[1].getColor()+\" and no of Cylinders are \"+CarArray[1].getCylinder()+\" and make year is \"+CarArray[1].getMake());
      
      
   }

}

create a class called ground Vehicle (description, wheels,passenger capacity, weight ) . Create two sub classes car ( door, cylinder, color, make), cycle (engin
create a class called ground Vehicle (description, wheels,passenger capacity, weight ) . Create two sub classes car ( door, cylinder, color, make), cycle (engin
create a class called ground Vehicle (description, wheels,passenger capacity, weight ) . Create two sub classes car ( door, cylinder, color, make), cycle (engin

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site