38 lines
702 B
Java
38 lines
702 B
Java
package com.oop;
|
|
|
|
public class Vehicle {
|
|
protected String inheritedName;
|
|
static int counter;
|
|
public int maxSpeed;
|
|
public int wheels;
|
|
public String color;
|
|
public double fuelCapacity;
|
|
public Vehicle() {
|
|
this.setColor("Red");
|
|
}
|
|
Vehicle(String c) {
|
|
this.setColor(c);
|
|
}
|
|
|
|
public void horn() {
|
|
System.out.println("Beep!");
|
|
}
|
|
|
|
//Getter
|
|
public String getColor() {
|
|
return color;
|
|
}
|
|
|
|
// Setter
|
|
public void setColor(String c) {
|
|
this.color = c;
|
|
}
|
|
public void start(){
|
|
System.out.println("Starting");
|
|
}
|
|
|
|
public void resource(){
|
|
System.out.println("I use petrol");
|
|
}
|
|
}
|