1
Vehicle Class
package week3;
public class Vehicle {
private String noReg;
private String owner;
/**
* @param noReg
* @param owner
*/
public Vehicle(String noReg, String owner) {
setNoReg(noReg);
setOwner(owner);
public Vehicle() {
this("not set","not set");
/**
* @return the noReg
*/
public String getNoReg() {
return noReg;
/**
* @param noReg the noReg to set
*/
public void setNoReg(String noReg) {
this.noReg = noReg;
}
/**
* @return the owner
*/
public String getOwner() {
return owner;
/**
* @param owner the owner to set
*/
public void setOwner(String owner) {
this.owner = owner;
@Override
public String toString() {
return "("+getNoReg() + ") owned by " + getOwner();
Car Class
package week3;
public class Car extends Vehicle {
private int seatCapacity;
/**
* @param noReg
* @param owner
* @param seatCapacity
*/
public Car(String noReg, String owner, int seatCapacity
) {
super(noReg, owner);
setSeatCapacity(seatCapacity);
/**
* @return the seatCapacity
*/
public int getSeatCapacity() {
return seatCapacity;
/**
* @param seatCapacity the seatCapacity to set
*/
public void setSeatCapacity(int seatCapacity) {
this.seatCapacity = seatCapacity;
@Override
public String toString() {
return "Car ("+ super.toString() +" with seat capa"
+ "city " + getSeatCapacity() ;
Bus Class
package week3;
public class Bus extends Vehicle{
private int sittingCap;
private int standCap;
/**
* @param noReg
* @param owner
* @param sittingCap
* @param standCap
*/
public Bus(String noReg, String owner, int sittingCap,
int standCap) {
super(noReg, owner);
setSittingCap(sittingCap);
setStandCap(standCap);
/**
* @return the sittingCap
*/
public int getSittingCap() {
return sittingCap;
/**
* @param sittingCap the sittingCap to set
*/
public void setSittingCap(int sittingCap) {
this.sittingCap = sittingCap;
/**
* @return the standCap
*/
public int getStandCap() {
return standCap;
}
/**
* @param standCap the standCap to set
*/
public void setStandCap(int standCap) {
this.standCap = standCap;
@Override
public String toString() {
return "Bus ("+ super.toString() +" with sitting c"
+ "apacity: " + getSittingCap() + " and st"
+ "anding capacity: " + getStandCap
();
VehicleDriver class
Payment Class