Inheritance
This commit is contained in:
31
MoreOnClasses/src/main/java/com/oop/Vehicle.java
Normal file
31
MoreOnClasses/src/main/java/com/oop/Vehicle.java
Normal file
@ -0,0 +1,31 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user