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

IN JAVA PLEASE: Suppose you have created a program that creates instances of dif

ID: 3781339 • Letter: I

Question

IN JAVA PLEASE: Suppose you have created a program that creates instances of different types of cars. Now you are creating a program that keeps track of different types of cars. Choose the abstract classes and concrete classes that you would like to use within the program in question. Provide at least one (1) example of each type of class and a description of each class’s function to support your choices. Using the scenario from Part I of this discussion, determine at least one (1) abstract method and at least one (1) non-abstract method that you would like to use in the program that you are creating. Include one (1) example of the application of each method to support your response.

Explanation / Answer

abstract class Car
{
  
    protected String color;
    protected String fuelType;


    // concrete method
    public void start() {
      
        System.out.println("Lock doors, Ignition! Ready to go.... ");
      
    }
  
    // abstract method
    abstract void defineMe();

  
}

class PrivateCar extends Car {
  
  
    PrivateCar(String c, String f)
    {
      fuelType=f;
      color = c;
    }
  
  
    //overide abstract method of class Car
    void defineMe()
    {
      System.out.println(" I am a private car running on "+fuelType+" and color "+color);

    }
  
}
class Taxi extends Car {
    int passengers;
  
    Taxi(String c, String f, int p)
    {
      fuelType=f;
      color = c;
      passengers=p;
    }
    public void loadPassengers() {
       
         System.out.println("Load Passengers, and move ");
         start();
    }

// Overiding abstract method of Car
    void defineMe()
    {
      System.out.println(" I am a Taxi car running on "+fuelType+", color "+color+" and I have capacity of "+passengers+" passengers");

    }

}

// Main Class or Driver class containg main method

public class AbstractDemoCar
{

   public static void main(String a[]) {
    PrivateCar c= new PrivateCar("White","Petrol");
    Taxi t = new Taxi("Black","Diesel ", 10);
  
    c.defineMe();
    c.start();
    t.defineMe();
    t.loadPassengers();
  
  
  

   }
}