Constructor for subclasses
Added constructors to House, Apartment, TenancyContract and PurchaseContract to make a special instance from an instance of its superclass. Updatet cli.bat. Added Contract to Orm.getAll(Type)
This commit is contained in:
parent
7c4a6a7dbe
commit
e75ebc9337
|
@ -1 +1 @@
|
||||||
java -cp "out\production\DIS sheet 2:lib\db2jcc.jar:lib\db2jcc_license_cu.jar" de.dis2017.Main
|
java -cp "bin/;lib/*" de.dis2017.Main
|
|
@ -154,7 +154,7 @@ public class Main {
|
||||||
contract.setPlace(FormUtil.readString("Place"));
|
contract.setPlace(FormUtil.readString("Place"));
|
||||||
contract.setDate(FormUtil.readString("Date"));
|
contract.setDate(FormUtil.readString("Date"));
|
||||||
if(estate instanceof Apartment){
|
if(estate instanceof Apartment){
|
||||||
TenancyContract tenContract = (TenancyContract) contract;
|
TenancyContract tenContract = new TenancyContract(contract);
|
||||||
tenContract.setStartDate(FormUtil.readString("Start Date"));
|
tenContract.setStartDate(FormUtil.readString("Start Date"));
|
||||||
tenContract.setDuration(FormUtil.readInt("Duration"));
|
tenContract.setDuration(FormUtil.readInt("Duration"));
|
||||||
tenContract.setAdditionalCost(FormUtil.readInt("Additional Costs"));
|
tenContract.setAdditionalCost(FormUtil.readInt("Additional Costs"));
|
||||||
|
@ -162,7 +162,7 @@ public class Main {
|
||||||
//_orm.persist(tenContract);
|
//_orm.persist(tenContract);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
PurchaseContract purContract = (PurchaseContract) contract;
|
PurchaseContract purContract = new PurchaseContract(contract);
|
||||||
purContract.setNoOfInstallments(FormUtil.readInt("No of Installments"));
|
purContract.setNoOfInstallments(FormUtil.readInt("No of Installments"));
|
||||||
purContract.setInterestRate(FormUtil.readInt("Interest Rate"));
|
purContract.setInterestRate(FormUtil.readInt("Interest Rate"));
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ public class Main {
|
||||||
estate.setSquareArea(FormUtil.readInt("Square Area"));
|
estate.setSquareArea(FormUtil.readInt("Square Area"));
|
||||||
estate.setAgent(FormUtil.readInt("EstateAgent ID"));
|
estate.setAgent(FormUtil.readInt("EstateAgent ID"));
|
||||||
if(isApartment){
|
if(isApartment){
|
||||||
Apartment apartment = (Apartment) estate;
|
Apartment apartment = new Apartment(estate);
|
||||||
apartment.setFloor(FormUtil.readInt("Floor"));
|
apartment.setFloor(FormUtil.readInt("Floor"));
|
||||||
apartment.setRooms(FormUtil.readInt("Rooms"));
|
apartment.setRooms(FormUtil.readInt("Rooms"));
|
||||||
apartment.setRent(FormUtil.readInt("Rent"));
|
apartment.setRent(FormUtil.readInt("Rent"));
|
||||||
|
@ -261,7 +261,7 @@ public class Main {
|
||||||
apartment.setBuiltinKitchen(input.equals("Y") || input.equals("y"));
|
apartment.setBuiltinKitchen(input.equals("Y") || input.equals("y"));
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
House house = (House) estate;
|
House house = new House(estate);
|
||||||
house.setPrice(FormUtil.readInt("Price"));
|
house.setPrice(FormUtil.readInt("Price"));
|
||||||
house.setFloors(FormUtil.readInt("Floors"));
|
house.setFloors(FormUtil.readInt("Floors"));
|
||||||
input = FormUtil.readString("Garden(Y/N)");
|
input = FormUtil.readString("Garden(Y/N)");
|
||||||
|
|
|
@ -7,6 +7,20 @@ public class Apartment extends Estate{
|
||||||
private boolean balcony;
|
private boolean balcony;
|
||||||
private boolean builtinKitchen;
|
private boolean builtinKitchen;
|
||||||
|
|
||||||
|
public Apartment(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Apartment(Estate estate){
|
||||||
|
this.setId(estate.getId());
|
||||||
|
this.setCity(estate.getCity());
|
||||||
|
this.setPostalCode(estate.getPostalCode());
|
||||||
|
this.setStreet(estate.getStreet());
|
||||||
|
this.setStreetNumber(estate.getStreetNumber());
|
||||||
|
this.setSquareArea(estate.getSquareArea());
|
||||||
|
this.setAgent(estate.getAgent());
|
||||||
|
}
|
||||||
|
|
||||||
public int getFloor() {
|
public int getFloor() {
|
||||||
return floor;
|
return floor;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,20 @@ public class House extends Estate {
|
||||||
private int price;
|
private int price;
|
||||||
private boolean garden;
|
private boolean garden;
|
||||||
|
|
||||||
|
public House(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public House(Estate estate){
|
||||||
|
this.setId(estate.getId());
|
||||||
|
this.setCity(estate.getCity());
|
||||||
|
this.setPostalCode(estate.getPostalCode());
|
||||||
|
this.setStreet(estate.getStreet());
|
||||||
|
this.setStreetNumber(estate.getStreetNumber());
|
||||||
|
this.setSquareArea(estate.getSquareArea());
|
||||||
|
this.setAgent(estate.getAgent());
|
||||||
|
}
|
||||||
|
|
||||||
public int getFloors() {
|
public int getFloors() {
|
||||||
return floors;
|
return floors;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,16 @@ public class PurchaseContract extends Contract {
|
||||||
|
|
||||||
private int house;
|
private int house;
|
||||||
|
|
||||||
|
public PurchaseContract(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
public PurchaseContract(Contract contract){
|
||||||
|
this.setContractNo(contract.getContractNo());
|
||||||
|
this.setDate(contract.getDate());
|
||||||
|
this.setPlace(contract.getPlace());
|
||||||
|
this.setPerson(contract.getPerson());
|
||||||
|
}
|
||||||
|
|
||||||
public int getNoOfInstallments() {
|
public int getNoOfInstallments() {
|
||||||
return noOfInstallments;
|
return noOfInstallments;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,16 @@ public class TenancyContract extends Contract {
|
||||||
|
|
||||||
private int apartment;
|
private int apartment;
|
||||||
|
|
||||||
|
public TenancyContract(){
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
public TenancyContract(Contract contract){
|
||||||
|
this.setContractNo(contract.getContractNo());
|
||||||
|
this.setDate(contract.getDate());
|
||||||
|
this.setPlace(contract.getPlace());
|
||||||
|
this.setPerson(contract.getPerson());
|
||||||
|
}
|
||||||
|
|
||||||
public String getStartDate() {
|
public String getStartDate() {
|
||||||
return startDate;
|
return startDate;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,9 @@ public class ORM {
|
||||||
case ESTATE:
|
case ESTATE:
|
||||||
objects = processEstates(rs);
|
objects = processEstates(rs);
|
||||||
break;
|
break;
|
||||||
|
case CONTRACT:
|
||||||
|
objects = processEstates(rs);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
pstmt.close();
|
pstmt.close();
|
||||||
|
|
Loading…
Reference in New Issue