AssigmentS2
This commit is contained in:
parent
ebe1144e25
commit
d3ac74eb64
BIN
assignments/AssigmentS2/exercise3/Motorcycle.class
Normal file
BIN
assignments/AssigmentS2/exercise3/Motorcycle.class
Normal file
Binary file not shown.
19
assignments/AssigmentS2/exercise3/Motorcycle.java
Normal file
19
assignments/AssigmentS2/exercise3/Motorcycle.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
public class Motorcycle extends Vehicle {
|
||||||
|
|
||||||
|
protected String engineType;
|
||||||
|
|
||||||
|
public Motorcycle () {
|
||||||
|
super(2012,"Yamaha");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEngineType(String engineType) {
|
||||||
|
this.engineType = engineType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEngineType() {
|
||||||
|
return engineType;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -1,11 +1,16 @@
|
|||||||
public class demo {
|
public class demo {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Car car1 = new Car();
|
Car car1 = new Car();
|
||||||
|
Motorcycle motor1 = new Motorcycle();
|
||||||
|
|
||||||
car1.setYear(2012);
|
car1.setYear(2012);
|
||||||
System.out.println(car1.getYear());
|
System.out.println(car1.getYear());
|
||||||
System.out.println(car1.getNumDoors());
|
System.out.println(car1.getNumDoors());
|
||||||
|
|
||||||
|
motor1.setEngineType("Gasoline");
|
||||||
|
System.out.println(motor1.getEngineType());
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user