test updates

This commit is contained in:
2025-09-26 23:38:25 -04:00
parent 0aacd84054
commit 558ee54443
16 changed files with 169 additions and 3 deletions

View 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 accounts files with data stored in
static void Test_AddAccount(AccomodationManager mgr, Account acct) throws Exception {
mgr.AddAccount(acct);
// 4. Request that Manager updates specific accounts 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";
}
}
}

View File

@@ -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
View 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
View File

View File

@@ -104,4 +104,8 @@ public final class AccomodationManager {
accounts.showReservationList();
}
public void showAccountList() {
accounts.showAccountList();
}
}

View File

@@ -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;

View File

@@ -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

View File

@@ -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;
}

2
src/resources/acc-A1450981765.json Normal file → Executable file
View File

@@ -1 +1 @@
{ "Account":{"account_number": "A1450981765","phone_number": "701-456-7890","mailing_address": { "Address":{"street": "10 wilco ave","city": "wilco","state": "WY","zip": "82801"}},"email_address": { "EmailAddress":{"email": "wilco@wyommin.net"}},"reservations":[{"CabinReservation":{"reservation_number":"R0535276622"}},{"HouseReservation":{"reservation_number":"R0499811708"}}]}}
{ "Account":{"account_number": "A1450981765","phone_number": "701-456-7890","mailing_address": { "Address":{"street": "10 wilco ave","city": "wilco","state": "WY","zip": "82801"}},"email_address": { "EmailAddress":{"email": "wilco@wyommin.net"}},"reservations":[]}}

0
src/resources/acc-A2074212339.json Normal file → Executable file
View File

0
src/resources/rsv-R0123087344.json Normal file → Executable file
View File

0
src/resources/rsv-R0499811708.json Normal file → Executable file
View File

0
src/resources/rsv-R0535276622.json Normal file → Executable file
View File

0
src/resources/rsv-R2042828431.json Normal file → Executable file
View File