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

Programming assignment: Classes and Inheritance You are to pick your own theme f

ID: 3802694 • Letter: P

Question

Programming assignment: Classes and Inheritance

You are to pick your own theme for a new Parent class. You can pick from one of the following:

Person

Automobile

Animal

If you choose Person, you will create a subclass of Person called Student.

If you choose Automobile, you will create a subclass of Automobile called RaceCar

If you choose Animal, you will create a subclass of Animal called Horse

Once you pick your theme, you must use the “HAS A” question to determine the fields that you are going to include in your classes.

For example, an Alarm Clock HAS A:

Set Hours Button Time

Set Minutes Button Time

Set Hours Button Alarm

Set Minutes Button Alarm

Alarm On-Off Button

Snooze Button

You will create UMLs for all classes.

You will WRITE JAVA code to create the class from above. In the classes you are creating you will include at least three fields or attributes (See sample alarm clock above)

You will have overloaded methods, and overridden methods. You will label each. You will have a Testclass that creates at least 3 objects of each class.

Your parent and child classes need to have all necessary and required methods.

Explanation / Answer

class Automobile {
// Methods implementation and class/Instance members
private String automobilecolor;
private int automobileSpeed;   
public void carInfo(){
System.out.println("Automobile Car Color= "+automobilecolor + " Automobile Max Speed= " + automobileSpeed);
}
  
   public void setAutomobilecolor(String automobilecolor) {
       this.automobilecolor = automobilecolor;
   }
  
   public void setAutomobileSpeed(int automobileSpeed) {
       this.automobileSpeed = automobileSpeed;
   }

  
  
  
  
}

package com.sql.acadgild;

public class RaceCar extends Automobile {

   public RaceCar() {
       // TODO Auto-generated constructor stub
   }

   public void MarutiStartDemo(){
   Engine MarutiEngine = new Engine();
   MarutiEngine.start();
   }
  
}

package com.sql.acadgild;

public class Engine {

   public Engine() {
       // TODO Auto-generated constructor stub
   }

   public void start(){
   System.out.println("Engine Started:");
   }
   public void stop(){
   System.out.println("Engine Stopped:");
   }

  
  
  
}

package com.sql.acadgild;

public class RelationsDemo {

   public RelationsDemo() {
       // TODO Auto-generated constructor stub
   }
  
   public static void main(String[] args) {
      
       Automobile myMaruti = new Automobile();
   myMaruti.setAutomobilecolor("yellow");
   myMaruti.setAutomobileSpeed(20);
   myMaruti.carInfo();
   }
      
      
   }