test updates
This commit is contained in:
60
src/java/lodge/TestAccountLoad.java
Executable file
60
src/java/lodge/TestAccountLoad.java
Executable file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* license: GPLv3
|
||||
* lodge.reservationsystem
|
||||
*/
|
||||
|
||||
package lodge;
|
||||
|
||||
import lodge.data.Account;
|
||||
import lodge.data.Address;
|
||||
import lodge.data.EmailAddress;
|
||||
import lodge.reservationsystem.AccomodationManager;
|
||||
|
||||
/**
|
||||
* The Tests for the ReservationSystem Module
|
||||
*
|
||||
* <p>
|
||||
* This class main function acts as a driver function to run the test functions.
|
||||
* </p>
|
||||
*
|
||||
* @author Sherwin Price
|
||||
* @version 1.0
|
||||
* @since 2025
|
||||
*/
|
||||
public final class TestAccountLoad {
|
||||
// Request that Manager updates specific account’s files with data stored in
|
||||
static void Test_AddAccount(AccomodationManager mgr, Account acct) throws Exception {
|
||||
mgr.AddAccount(acct);
|
||||
|
||||
// 4. Request that Manager updates specific account’s files with data stored in
|
||||
// memory
|
||||
mgr.UpdateAccount(acct);
|
||||
}
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
// Configure data repository
|
||||
AccomodationManager mgr = new AccomodationManager(getRepositoryConfig.getPath());
|
||||
|
||||
// 3. Add new account object to the list managed by Manager (if account object
|
||||
// already exists on add action with the same account number, it is considered
|
||||
// an error)
|
||||
Test_AddAccount(mgr, mgr.newAccount("701-456-7890",
|
||||
new Address("10 wilco ave", "wilco", "WY", "82801"),
|
||||
new EmailAddress("wilco@wyommin.net")));
|
||||
|
||||
Test_AddAccount(mgr, mgr.newAccount("701-456-7890",
|
||||
new Address("10 wilco ave", "wilco", "WY", "82801"),
|
||||
new EmailAddress("wilco@wyommin.net")));
|
||||
|
||||
mgr.showAccountList();
|
||||
System.out.println("Program Completed.");
|
||||
}
|
||||
|
||||
public final static class getRepositoryConfig {
|
||||
public final static String getPath() {
|
||||
String home = System.getenv("HOME") != null ? System.getenv("HOME")
|
||||
: System.getenv("HOMEDRIVE") + System.getenv("HOMEPATH");
|
||||
return home.replace('\\', '/') + "/workspace/reservationsystem/src/resources";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -139,6 +139,8 @@ public final class TestReservations {
|
||||
// 9. Request for price per night to be calculated and returned for a
|
||||
// per night
|
||||
// reservation
|
||||
System.out.println(String.format("%s Per Night Rate: %f",
|
||||
rsrv.ReservationType().replace("Reservation", ""), rsrv.getPricePerNight()));
|
||||
|
||||
// 10. Request for total reservation price to be calculated and returned for
|
||||
// specific reservation
|
||||
|
||||
8
src/java/lodge/data/AccountList.java
Normal file → Executable file
8
src/java/lodge/data/AccountList.java
Normal file → Executable file
@@ -65,10 +65,18 @@ public class AccountList extends ArrayList<Account> {
|
||||
return Collections.unmodifiableList(readList);
|
||||
}
|
||||
|
||||
// Show the different accounts lists of resverations
|
||||
public void showReservationList() {
|
||||
for (IReservation irsrv : this.getListOfReservations()) {
|
||||
System.out.println(String.format("Account %s: %s, %s", irsrv.getAccountNumber(),
|
||||
irsrv.getReservation_number(), irsrv.getPhysical_address().getStreet()));
|
||||
}
|
||||
}
|
||||
|
||||
// show the accounts
|
||||
public void showAccountList() {
|
||||
for (Account acct : this) {
|
||||
System.out.println(String.format("Account %s", acct.getAccount_number()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
0
src/java/lodge/data/AccountReservationList.java
Normal file → Executable file
0
src/java/lodge/data/AccountReservationList.java
Normal file → Executable file
@@ -104,4 +104,8 @@ public final class AccomodationManager {
|
||||
accounts.showReservationList();
|
||||
}
|
||||
|
||||
public void showAccountList() {
|
||||
accounts.showAccountList();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -51,7 +51,14 @@ public final class CabinReservation extends Reservation {
|
||||
|
||||
@Override
|
||||
public float getPricePerNight() {
|
||||
return 0.0f;
|
||||
float calcprice = (getSquareFeet() > 900.0f) ? 120.0f + 15.0f : 120.0f;
|
||||
if (getKitchen() == KitchenTypeEnum.FullKitchen) {
|
||||
calcprice = calcprice + 20.0f;
|
||||
}
|
||||
if (getNumberOfBathRooms() > 1) {
|
||||
setPrice(getPrice() + (getNumberOfBathRooms() * 5.0f));
|
||||
}
|
||||
return calcprice;
|
||||
}
|
||||
|
||||
// calculate and return the reservation's price
|
||||
@@ -62,7 +69,9 @@ public final class CabinReservation extends Reservation {
|
||||
ZonedDateTime enddt = getReservation_end_date().truncatedTo(ChronoUnit.DAYS);
|
||||
ZonedDateTime startdt = getReservation_start_date().truncatedTo(ChronoUnit.DAYS);
|
||||
long days = ChronoUnit.DAYS.between(startdt, enddt);
|
||||
|
||||
days = (days < 2) ? 1 : days - 1;
|
||||
|
||||
float calcprice = (getSquareFeet() > 900.0f) ? 120.0f + 15.0f : 120.0f;
|
||||
if (getKitchen() == KitchenTypeEnum.FullKitchen) {
|
||||
calcprice = calcprice + 20.0f;
|
||||
|
||||
@@ -73,7 +73,11 @@ public final class HotelReservation extends Reservation {
|
||||
|
||||
@Override
|
||||
public float getPricePerNight() {
|
||||
return 0.0f;
|
||||
float calcprice = (getSquareFeet() > 900.0f) ? 120.0f + 15.0f : 120.0f;
|
||||
if (getKitchen() == KitchenTypeEnum.FullKitchen) {
|
||||
calcprice = calcprice + 10.0f;
|
||||
}
|
||||
return calcprice;
|
||||
}
|
||||
|
||||
// calculate and return the reservation's price
|
||||
|
||||
@@ -71,7 +71,9 @@ public final class HouseReservation extends Reservation {
|
||||
ZonedDateTime enddt = getReservation_end_date().truncatedTo(ChronoUnit.DAYS);
|
||||
ZonedDateTime startdt = getReservation_start_date().truncatedTo(ChronoUnit.DAYS);
|
||||
long days = ChronoUnit.DAYS.between(startdt, enddt);
|
||||
|
||||
days = (days < 2) ? 1 : days - 1;
|
||||
|
||||
float calcprice = getPricePerNight() * days;
|
||||
return calcprice;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user