0% found this document useful (0 votes)
18 views6 pages

Oop Removal

Uploaded by

anamae.amorin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views6 pages

Oop Removal

Uploaded by

anamae.amorin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

MAIN

/*

* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license

* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template

*/

package removal;

/**

* @author amorin

*/

public class Removal {

/**

* @param args the command line arguments

*/

public static void main(String[] args) {

// TODO code application logic here

Vehicle Car = new Car("Toyota", 2020, 4);

Vehicle myMotorcycle = new Motor("Harley-Davidson", 2018, false);

myCar.startEngine();

myMotor.startEngine;

myCar.stopEngine();

myMotorcycle.stopEngine;
System.out.println("Car brand: " + myCar.getBrand));

System.out.println("Motorcycle brand: " + myMotorcycle.getBrand);

SUPER CLASS

/*

* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license

* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template

*/

package removal;

/**

* @author anamae

*/

public abstract class Vehicle {

private brand;

private int year;

public Vehicle(brand, year) {

this.brand = brand;

this.year = year;

}
public String getBrand {

return brand;

public void setBrand(String brand) {

this.brand = brand;

public int getYear {

return year;

public void setYear(int year) {

this.year = year;

public abstract void startEngine;

public abstract void stopEngine;

}
SUBCLASS

/*

* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license

* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template

*/

package removal;

/**

* @author anamae

*/

public class Car extends Vehicle {

private int numberDoors;

public Car(String brand, int year, int numberOfDoors) {

super(brand, year);

numberOfDoors = numberOfDoors;

public int getNumberOfDoors() {

return numberOfDoors;

public void setNumberOfDoors(int numberOfDoors) {

.numberOfDoors = numberOfDoors;

@Override
public void startEngine {

System.out.println("The car engine is starting.");

@Override

public void stopEngine{

System.out.println("The car engine is stopping.");

SUBCLASS

/*

* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license

* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template

*/

package removal;

/**

* @author anamae

*/

public class Motorcycle extends Vehicle {

private boolean car;

public Motorcycle(String brand, String year, boolean hasSidecar) {


super(brand, year);

this.hasSidecar = hasSidecar;

public boolean isHasSidecar() {

hasSidecar;

public void setHasSidecar(boolean hasSidecar) {

this.hasSidecar = hasSidecar;

public void startEngine() {

System.out.println("The motorcycle engine is starting.");

public void stopEngine() {

System.out.println("The motorcycle engine is stopping.");

You might also like