Inheritance

This commit is contained in:
2024-09-18 20:28:26 +02:00
parent 9534ee8156
commit 4908d26105
10 changed files with 73 additions and 0 deletions

View 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;
}
}