AssignmentS2
This commit is contained in:
parent
c6f3123b73
commit
ebe1144e25
BIN
assignments/AssigmentS2/exercise3/Car.class
Normal file
BIN
assignments/AssigmentS2/exercise3/Car.class
Normal file
Binary file not shown.
19
assignments/AssigmentS2/exercise3/Car.java
Normal file
19
assignments/AssigmentS2/exercise3/Car.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
public class Car extends Vehicle {
|
||||||
|
|
||||||
|
protected int numDoors = 4;
|
||||||
|
|
||||||
|
public Car () {
|
||||||
|
super(2007,"Kia");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNumDoors(int numDoors) {
|
||||||
|
this.numDoors = numDoors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumDoors() {
|
||||||
|
return numDoors;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
BIN
assignments/AssigmentS2/exercise3/Vehicle.class
Normal file
BIN
assignments/AssigmentS2/exercise3/Vehicle.class
Normal file
Binary file not shown.
30
assignments/AssigmentS2/exercise3/Vehicle.java
Normal file
30
assignments/AssigmentS2/exercise3/Vehicle.java
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
public class Vehicle {
|
||||||
|
|
||||||
|
protected int year;
|
||||||
|
protected String make;
|
||||||
|
|
||||||
|
|
||||||
|
public Vehicle (int year, String make) {
|
||||||
|
this.year = year;
|
||||||
|
this.make = make;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setMake(String make) {
|
||||||
|
this.make = make;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setYear(int year) {
|
||||||
|
this.year = year;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMake() {
|
||||||
|
return make;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getYear() {
|
||||||
|
return year;
|
||||||
|
}
|
||||||
|
}
|
11
assignments/AssigmentS2/exercise3/demo.java
Normal file
11
assignments/AssigmentS2/exercise3/demo.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
public class demo {
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Car car1 = new Car();
|
||||||
|
|
||||||
|
car1.setYear(2012);
|
||||||
|
System.out.println(car1.getYear());
|
||||||
|
System.out.println(car1.getNumDoors());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user