@ -552,7 +552,12 @@ public class Main {
|
|||||||
String input = FormUtil.readString("Purchase Contract(P) / Tenancy Contract(T)");
|
String input = FormUtil.readString("Purchase Contract(P) / Tenancy Contract(T)");
|
||||||
boolean isTenancy = input.equals("T") || input.equals("t");
|
boolean isTenancy = input.equals("T") || input.equals("t");
|
||||||
if (isTenancy) {
|
if (isTenancy) {
|
||||||
printListOfApartments();
|
boolean apartmentsAvailable = printListOfApartments();
|
||||||
|
if (!apartmentsAvailable) {
|
||||||
|
System.out.println("No apartments available to rent.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
TenancyContract tenancyContract = new TenancyContract();
|
TenancyContract tenancyContract = new TenancyContract();
|
||||||
contract = tenancyContract;
|
contract = tenancyContract;
|
||||||
tenancyContract.setApartment(FormUtil.readInt("Apartment ID"));
|
tenancyContract.setApartment(FormUtil.readInt("Apartment ID"));
|
||||||
@ -566,7 +571,12 @@ public class Main {
|
|||||||
tenancyContract.setAdditionalCost(FormUtil.readInt("Additional Costs"));
|
tenancyContract.setAdditionalCost(FormUtil.readInt("Additional Costs"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
printListOfHouses();
|
boolean housesAvailable = printListOfHouses();
|
||||||
|
if (!housesAvailable) {
|
||||||
|
System.out.println("No houses available to sell.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
PurchaseContract purchaseContract = new PurchaseContract();
|
PurchaseContract purchaseContract = new PurchaseContract();
|
||||||
contract = purchaseContract;
|
contract = purchaseContract;
|
||||||
purchaseContract.setPlace(place);
|
purchaseContract.setPlace(place);
|
||||||
@ -596,10 +606,17 @@ public class Main {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Print a list of houses.
|
* Print a list of houses.
|
||||||
|
*
|
||||||
|
* @return true if houses are available, false otherwise
|
||||||
*/
|
*/
|
||||||
private static void printListOfHouses() {
|
private static boolean printListOfHouses() {
|
||||||
List<?> houses = _orm.getAll(Type.HOUSE);
|
List<?> houses = _orm.getAll(Type.HOUSE);
|
||||||
List<Integer> soldHouses = _orm.getSoldHouses();
|
List<Integer> soldHouses = _orm.getSoldHouses();
|
||||||
|
|
||||||
|
if (houses.size() <= soldHouses.size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
System.out.println("List of available Houses");
|
System.out.println("List of available Houses");
|
||||||
System.out.println("------------------");
|
System.out.println("------------------");
|
||||||
|
|
||||||
@ -612,14 +629,22 @@ public class Main {
|
|||||||
+ house.getStreetNumber() + ", " + house.getPostalCode() + " " + house.getCity());
|
+ house.getStreetNumber() + ", " + house.getPostalCode() + " " + house.getCity());
|
||||||
}
|
}
|
||||||
System.out.println("------------------");
|
System.out.println("------------------");
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print a list of houses.
|
* Print a list of houses.
|
||||||
|
*
|
||||||
|
* @return true if apartments are available, false otherwise
|
||||||
*/
|
*/
|
||||||
private static void printListOfApartments() {
|
private static boolean printListOfApartments() {
|
||||||
List<?> apartments = _orm.getAll(Type.APARTMENT);
|
List<?> apartments = _orm.getAll(Type.APARTMENT);
|
||||||
List<Integer> rentedApartments = _orm.getRentedApartments();
|
List<Integer> rentedApartments = _orm.getRentedApartments();
|
||||||
|
if (apartments.size() <= rentedApartments.size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
System.out.println("List of available Apartments");
|
System.out.println("List of available Apartments");
|
||||||
System.out.println("------------------");
|
System.out.println("------------------");
|
||||||
|
|
||||||
@ -632,6 +657,8 @@ public class Main {
|
|||||||
+ apartment.getStreetNumber() + ", " + apartment.getPostalCode() + " " + apartment.getCity());
|
+ apartment.getStreetNumber() + ", " + apartment.getPostalCode() + " " + apartment.getCity());
|
||||||
}
|
}
|
||||||
System.out.println("------------------");
|
System.out.println("------------------");
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user