write account
This commit is contained in:
80
src/java/lodge/TestReservations.java
Normal file
80
src/java/lodge/TestReservations.java
Normal file
@@ -0,0 +1,80 @@
|
||||
package lodge;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import lodge.reservationsystem.AccomodationManager;
|
||||
import lodge.reservationsystem.Account;
|
||||
import lodge.reservationsystem.Address;
|
||||
import lodge.reservationsystem.DataRepository;
|
||||
import lodge.reservationsystem.EmailAddress;
|
||||
|
||||
public final class TestReservations {
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
AccomodationManager mgr = new AccomodationManager();
|
||||
String home = System.getenv("HOMEDRIVE")+System.getenv("HOMEPATH");
|
||||
home= home.replace("\\", "/") + "/data";
|
||||
DataRepository.setDataStoreRoot(home);
|
||||
|
||||
// 1. Get the list of loaded accounts from Manager
|
||||
|
||||
mgr.loadAll();
|
||||
|
||||
// 2. Retrieve a loaded account object that matches a specific account number
|
||||
|
||||
mgr.retrieveAccount("A######");
|
||||
|
||||
// 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)
|
||||
|
||||
Account acct = mgr.newAccount("767-456-7890",
|
||||
new Address("10 wilco ave", "wilco", "WY", "82801"),
|
||||
new EmailAddress("wilco@wyommin.net"));
|
||||
|
||||
// 4. Request that Manager updates specific account’s files with data stored in
|
||||
// memory
|
||||
mgr.AddAccount(acct);
|
||||
// 5. Add draft lodging reservation to an account (if reservation object already
|
||||
// exists with the same reservation number, it is considered an error)
|
||||
|
||||
mgr.UpdateAccount(mgr.retrieveAccount(acct.account_number()));
|
||||
|
||||
/*
|
||||
* if (acct != null)
|
||||
* acct.addReservation(new HotelReservation());
|
||||
*
|
||||
* // 6. Complete reservation that is associated with an account
|
||||
* Reservation rsrv = null;
|
||||
* acct = null;
|
||||
* acct = mgr.retrieveAccount("A######");
|
||||
* if (acct != null) {
|
||||
* rsrv = acct.retrieve("?######");
|
||||
* rsrv.Complete();
|
||||
* }
|
||||
*
|
||||
* // 7. Cancel reservation that is associated with an account
|
||||
* if (acct != null) {
|
||||
* rsrv = acct.retrieve("?######");
|
||||
* if (rsrv != null)
|
||||
* rsrv.Cancel();
|
||||
* }
|
||||
*
|
||||
* if (rsrv != null) {
|
||||
* // 8. Change reservation values that can be changed (if reservation is
|
||||
* // cancelled, completed, or for past date, it is considered an error)
|
||||
* rsrv = Reservation.update(rsrv);
|
||||
*
|
||||
* // 9. Request for price per night to be calculated and returned for a
|
||||
* specific
|
||||
* // reservation
|
||||
*
|
||||
* rsrv = Reservation.calculatePricePerNight(rsrv);
|
||||
* // 10. Request for total reservation price to be calculated and returned for
|
||||
* a
|
||||
* // specific reservation
|
||||
* }
|
||||
*/
|
||||
System.out.println("Program Completed.");
|
||||
}
|
||||
}
|
||||
60
src/java/lodge/reservationsystem/AccomodationManager.java
Normal file
60
src/java/lodge/reservationsystem/AccomodationManager.java
Normal file
@@ -0,0 +1,60 @@
|
||||
package lodge.reservationsystem;
|
||||
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class AccomodationManager {
|
||||
|
||||
private AccountList account_list = new AccountList();
|
||||
|
||||
public void loadAll() throws Exception {
|
||||
account_list.clear();
|
||||
// walk directories
|
||||
Path rootDir = Paths.get(DataRepository.getPath());
|
||||
Files.walkFileTree(rootDir, new SimpleFileVisitor<Path>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
|
||||
System.out.println("File: " + file.toAbsolutePath());
|
||||
// load account number, and content
|
||||
// load reservation files
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) {
|
||||
System.out.println("Directory: " + dir.toAbsolutePath());
|
||||
// prepare to load account number
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Account retrieveAccount(String acct_id) {
|
||||
return AccountList.retrieveAccount(account_list, acct_id);
|
||||
}
|
||||
|
||||
public void AddAccount(Account acct) throws Exception{
|
||||
AccountList.addAccount(account_list, acct);
|
||||
}
|
||||
|
||||
public void UpdateAccount(Account acct) throws Exception {
|
||||
|
||||
AccountList.save(account_list, acct);
|
||||
}
|
||||
|
||||
public final Account newAccount(String phone_number, Address mailing_address, EmailAddress email_address) throws Exception {
|
||||
Account acct = null;
|
||||
try {
|
||||
acct = AccountList.newAccount(phone_number, mailing_address, email_address);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
AccountList.save(account_list, acct);
|
||||
return acct;
|
||||
}
|
||||
}
|
||||
108
src/java/lodge/reservationsystem/Account.java
Normal file
108
src/java/lodge/reservationsystem/Account.java
Normal file
@@ -0,0 +1,108 @@
|
||||
package lodge.reservationsystem;
|
||||
|
||||
import java.io.BufferedOutputStream;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class Account {
|
||||
String account_number;
|
||||
String phone_number;
|
||||
Address mailing_address;
|
||||
EmailAddress email_address;
|
||||
|
||||
public Account(
|
||||
String account_number,
|
||||
String phone_number,
|
||||
Address mailing_address,
|
||||
EmailAddress email_address) {
|
||||
this.account_number = account_number;
|
||||
this.phone_number = phone_number;
|
||||
this.mailing_address = mailing_address;
|
||||
this.email_address = email_address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Account [account_number=" + account_number + ", phone_number=" + phone_number
|
||||
+ ", mailing_address=" + mailing_address + ", email_address=" + email_address
|
||||
+ ", account_number()=" + account_number() + ", phone_number()=" + phone_number()
|
||||
+ ", mailing_address()=" + mailing_address() + ", email_address()=" + email_address()
|
||||
+ "]";
|
||||
}
|
||||
|
||||
//@TODO Write Account out in JSON
|
||||
public static void Write(Account acct) throws IOException {
|
||||
String dataRoot = DataRepository.getPath();
|
||||
dataRoot = dataRoot + "/" + acct.account_number + ".txt";
|
||||
Path path = Paths.get(dataRoot);
|
||||
|
||||
try(BufferedWriter writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8)){
|
||||
writer.write(acct.toString());
|
||||
writer.flush();
|
||||
}
|
||||
}
|
||||
|
||||
public String account_number() {
|
||||
return account_number;
|
||||
}
|
||||
|
||||
public void setAccount_number(String account_number) {
|
||||
this.account_number = account_number;
|
||||
}
|
||||
|
||||
public String phone_number() {
|
||||
return phone_number;
|
||||
}
|
||||
|
||||
public void setPhone_number(String phone_number) {
|
||||
this.phone_number = phone_number;
|
||||
}
|
||||
|
||||
public Address mailing_address() {
|
||||
return mailing_address;
|
||||
}
|
||||
|
||||
public void setMailing_address(Address mailing_address) {
|
||||
this.mailing_address = mailing_address;
|
||||
}
|
||||
|
||||
public EmailAddress email_address() {
|
||||
return email_address;
|
||||
}
|
||||
|
||||
public void setEmail_address(EmailAddress email_address) {
|
||||
this.email_address = email_address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((account_number == null) ? 0 : account_number.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Account other = (Account) obj;
|
||||
if (account_number == null) {
|
||||
if (other.account_number != null)
|
||||
return false;
|
||||
} else if (!account_number.equals(other.account_number))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
12
src/java/lodge/reservationsystem/AccountException.java
Normal file
12
src/java/lodge/reservationsystem/AccountException.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package lodge.reservationsystem;
|
||||
|
||||
class AccountException extends Exception {
|
||||
public AccountException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public AccountException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
57
src/java/lodge/reservationsystem/AccountList.java
Normal file
57
src/java/lodge/reservationsystem/AccountList.java
Normal file
@@ -0,0 +1,57 @@
|
||||
package lodge.reservationsystem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class AccountList extends ArrayList<Account> {
|
||||
|
||||
public static String accountSerial(String phone_number, Address mailing_address, EmailAddress email_address) {
|
||||
return "A" + java.util.Objects.hash(phone_number, mailing_address, email_address);
|
||||
}
|
||||
|
||||
public static Account newAccount(String phone_number, Address mailing_address, EmailAddress email_address) throws Exception {
|
||||
Account A = new Account(AccountList.accountSerial(phone_number, mailing_address, email_address),
|
||||
phone_number,
|
||||
mailing_address,
|
||||
email_address);
|
||||
|
||||
return A;
|
||||
}
|
||||
// ** Add account throw error if account number is pre-existing. */
|
||||
public static Account addAccount(AccountList account_list, Account account) throws NullPointerException, AccountException {
|
||||
String acctNumber = "";
|
||||
for(Account acct: account_list){
|
||||
if( acct.account_number() == account.account_number() ){
|
||||
acctNumber = acct.account_number();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!acctNumber.isEmpty()) {
|
||||
throw new AccountException("Account exists, duplicates not allowed.");
|
||||
} else {
|
||||
account_list.add(account);
|
||||
}
|
||||
return account;
|
||||
}
|
||||
|
||||
// save account in edit status
|
||||
public void save(Account acct) {
|
||||
|
||||
}
|
||||
|
||||
// save accounts in edit status
|
||||
public static void save(AccountList account_list, Account acct) throws Exception {
|
||||
for (Account account : account_list) {
|
||||
Account.Write(account);
|
||||
}
|
||||
}
|
||||
|
||||
// ** Find account return null not-existing. */
|
||||
public static Account retrieveAccount(AccountList account_list, String account_number) {
|
||||
for(Account acct: account_list){
|
||||
if( acct.account_number() == account_number ){
|
||||
return acct;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
12
src/java/lodge/reservationsystem/AccountReservationList.java
Normal file
12
src/java/lodge/reservationsystem/AccountReservationList.java
Normal file
@@ -0,0 +1,12 @@
|
||||
package lodge.reservationsystem;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class AccountReservationList {
|
||||
|
||||
ArrayList<Reservation> reservation_list = new ArrayList<Reservation>();
|
||||
|
||||
public void addReservation(Reservation reservation) {
|
||||
reservation_list.add(reservation);
|
||||
}
|
||||
}
|
||||
85
src/java/lodge/reservationsystem/Address.java
Normal file
85
src/java/lodge/reservationsystem/Address.java
Normal file
@@ -0,0 +1,85 @@
|
||||
package lodge.reservationsystem;
|
||||
|
||||
public final class Address {
|
||||
|
||||
String street;
|
||||
String city;
|
||||
String state;
|
||||
String zip;
|
||||
public Address(String street, String city, String state, String zip) {
|
||||
this.street = street;
|
||||
this.city = city;
|
||||
this.state = state;
|
||||
this.zip = zip;
|
||||
}
|
||||
public String getStreet() {
|
||||
return street;
|
||||
}
|
||||
public void setStreet(String street) {
|
||||
this.street = street;
|
||||
}
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
public String getState() {
|
||||
return state;
|
||||
}
|
||||
public void setState(String state) {
|
||||
this.state = state;
|
||||
}
|
||||
public String getZip() {
|
||||
return zip;
|
||||
}
|
||||
public void setZip(String zip) {
|
||||
this.zip = zip;
|
||||
}
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((street == null) ? 0 : street.hashCode());
|
||||
result = prime * result + ((city == null) ? 0 : city.hashCode());
|
||||
result = prime * result + ((state == null) ? 0 : state.hashCode());
|
||||
result = prime * result + ((zip == null) ? 0 : zip.hashCode());
|
||||
return result;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Address other = (Address) obj;
|
||||
if (street == null) {
|
||||
if (other.street != null)
|
||||
return false;
|
||||
} else if (!street.equals(other.street))
|
||||
return false;
|
||||
if (city == null) {
|
||||
if (other.city != null)
|
||||
return false;
|
||||
} else if (!city.equals(other.city))
|
||||
return false;
|
||||
if (state == null) {
|
||||
if (other.state != null)
|
||||
return false;
|
||||
} else if (!state.equals(other.state))
|
||||
return false;
|
||||
if (zip == null) {
|
||||
if (other.zip != null)
|
||||
return false;
|
||||
} else if (!zip.equals(other.zip))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Address [street=" + street + ", city=" + city + ", state=" + state + ", zip=" + zip + "]";
|
||||
}
|
||||
|
||||
}
|
||||
10
src/java/lodge/reservationsystem/CabinReservation.java
Normal file
10
src/java/lodge/reservationsystem/CabinReservation.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package lodge.reservationsystem;
|
||||
|
||||
public final class CabinReservation extends Reservation {
|
||||
|
||||
//calculate and return the reservation's price
|
||||
public float calculatePrice() {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
}
|
||||
19
src/java/lodge/reservationsystem/DataRepository.java
Normal file
19
src/java/lodge/reservationsystem/DataRepository.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package lodge.reservationsystem;
|
||||
|
||||
public final class DataRepository {
|
||||
// hard code data store location for storage of
|
||||
// account data files on filesystem
|
||||
private String directoryPath;
|
||||
private static final DataRepository instance = new DataRepository();
|
||||
public static DataRepository getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static void setDataStoreRoot(String direcoryPath){
|
||||
getInstance().directoryPath = direcoryPath;
|
||||
}
|
||||
|
||||
public static String getPath() {
|
||||
return getInstance().directoryPath;
|
||||
}
|
||||
}
|
||||
48
src/java/lodge/reservationsystem/EmailAddress.java
Normal file
48
src/java/lodge/reservationsystem/EmailAddress.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package lodge.reservationsystem;
|
||||
|
||||
public class EmailAddress{
|
||||
String email_address;
|
||||
|
||||
public EmailAddress(String email_address) {
|
||||
this.email_address = email_address;
|
||||
}
|
||||
|
||||
public String getEmail_address() {
|
||||
return email_address;
|
||||
}
|
||||
|
||||
public void setEmail_address(String email_address) {
|
||||
this.email_address = email_address;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((email_address == null) ? 0 : email_address.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
EmailAddress other = (EmailAddress) obj;
|
||||
if (email_address == null) {
|
||||
if (other.email_address != null)
|
||||
return false;
|
||||
} else if (!email_address.equals(other.email_address))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EmailAddress [email_address=" + email_address + "]";
|
||||
}
|
||||
|
||||
}
|
||||
9
src/java/lodge/reservationsystem/HotelReservation.java
Normal file
9
src/java/lodge/reservationsystem/HotelReservation.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package lodge.reservationsystem;
|
||||
|
||||
public final class HotelReservation extends Reservation {
|
||||
|
||||
//calculate and return the reservation's price
|
||||
public float calculatePrice() {
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
9
src/java/lodge/reservationsystem/HouseReservation.java
Normal file
9
src/java/lodge/reservationsystem/HouseReservation.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package lodge.reservationsystem;
|
||||
|
||||
public final class HouseReservation extends Reservation {
|
||||
//calculate and return the reservation's price
|
||||
public float calculatePrice() {
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
}
|
||||
179
src/java/lodge/reservationsystem/Reservation.java
Normal file
179
src/java/lodge/reservationsystem/Reservation.java
Normal file
@@ -0,0 +1,179 @@
|
||||
package lodge.reservationsystem;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
public abstract class Reservation {
|
||||
String reservation_number;
|
||||
String physical_address;
|
||||
String mailing_address;
|
||||
|
||||
ZonedDateTime reservation_start_date;
|
||||
ZonedDateTime reservation_end_date;
|
||||
ReservationStatus reservation_status;
|
||||
|
||||
Integer numberOfBeds;
|
||||
Integer numberOfBedRooms;
|
||||
Integer numberOfBathRooms;
|
||||
Integer numberOfFloors;
|
||||
Integer squareFeet;
|
||||
|
||||
Float price;
|
||||
|
||||
public String reservation_number() {
|
||||
return reservation_number;
|
||||
}
|
||||
|
||||
public void setReservation_number(String reservation_number) {
|
||||
this.reservation_number = reservation_number;
|
||||
}
|
||||
|
||||
public String physical_address() {
|
||||
return physical_address;
|
||||
}
|
||||
|
||||
public void setPhysical_address(String physical_address) {
|
||||
this.physical_address = physical_address;
|
||||
}
|
||||
|
||||
public String mailing_address() {
|
||||
return mailing_address;
|
||||
}
|
||||
|
||||
public void setMailing_address(String mailing_address) {
|
||||
this.mailing_address = mailing_address;
|
||||
}
|
||||
|
||||
public ZonedDateTime reservation_start_date() {
|
||||
return reservation_start_date;
|
||||
}
|
||||
|
||||
public void setReservation_start_date(ZonedDateTime reservation_start_date) {
|
||||
this.reservation_start_date = reservation_start_date;
|
||||
}
|
||||
|
||||
public ZonedDateTime reservation_end_date() {
|
||||
return reservation_end_date;
|
||||
}
|
||||
|
||||
public void setReservation_end_date(ZonedDateTime reservation_end_date) {
|
||||
this.reservation_end_date = reservation_end_date;
|
||||
}
|
||||
|
||||
public ReservationStatus reservation_status() {
|
||||
return reservation_status;
|
||||
}
|
||||
|
||||
public void setReservation_status(ReservationStatus reservation_status) {
|
||||
this.reservation_status = reservation_status;
|
||||
}
|
||||
|
||||
public Integer numberOfBeds() {
|
||||
return numberOfBeds;
|
||||
}
|
||||
|
||||
public void setNumberOfBeds(Integer numberOfBeds) {
|
||||
this.numberOfBeds = numberOfBeds;
|
||||
}
|
||||
|
||||
public Integer numberOfBedRooms() {
|
||||
return numberOfBedRooms;
|
||||
}
|
||||
|
||||
public void setNumberOfBedRooms(Integer numberOfBedRooms) {
|
||||
this.numberOfBedRooms = numberOfBedRooms;
|
||||
}
|
||||
|
||||
public Integer numberOfBathRooms() {
|
||||
return numberOfBathRooms;
|
||||
}
|
||||
|
||||
public void setNumberOfBathRooms(Integer numberOfBathRooms) {
|
||||
this.numberOfBathRooms = numberOfBathRooms;
|
||||
}
|
||||
|
||||
public Integer numberOfFloors() {
|
||||
return numberOfFloors;
|
||||
}
|
||||
|
||||
public void setNumberOfFloors(Integer numberOfFloors) {
|
||||
this.numberOfFloors = numberOfFloors;
|
||||
}
|
||||
|
||||
public Integer squareFeet() {
|
||||
return squareFeet;
|
||||
}
|
||||
|
||||
public void setSquareFeet(Integer squareFeet) {
|
||||
this.squareFeet = squareFeet;
|
||||
}
|
||||
|
||||
public Float price() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public void setPrice(Float price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public Reservation() {
|
||||
numberOfBeds = 0;
|
||||
numberOfBedRooms = 0;
|
||||
numberOfBathRooms = 0;
|
||||
numberOfFloors = 0;
|
||||
price = 0.0f;
|
||||
reservation_status = ReservationStatus.Draft;
|
||||
}
|
||||
|
||||
public void Draft(){
|
||||
this.reservation_status=ReservationStatus.Draft;
|
||||
}
|
||||
|
||||
public void Cancel() {
|
||||
this.reservation_status=ReservationStatus.Canceled;
|
||||
}
|
||||
|
||||
public void Complete() {
|
||||
this.reservation_status=ReservationStatus.Completed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((reservation_number == null) ? 0 : reservation_number.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
Reservation other = (Reservation) obj;
|
||||
if (reservation_number == null) {
|
||||
if (other.reservation_number != null)
|
||||
return false;
|
||||
} else if (!reservation_number.equals(other.reservation_number))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Reservation [reservation_number=" + reservation_number + ", physical_address=" + physical_address
|
||||
+ ", mailing_address=" + mailing_address + ", reservation_start_date=" + reservation_start_date
|
||||
+ ", reservation_end_date=" + reservation_end_date + ", reservation_status=" + reservation_status
|
||||
+ ", numberOfBeds=" + numberOfBeds + ", numberOfBedRooms=" + numberOfBedRooms + ", numberOfBathRooms="
|
||||
+ numberOfBathRooms + ", numberOfFloors=" + numberOfFloors + ", squareFeet=" + squareFeet + ", price="
|
||||
+ price + "]";
|
||||
}
|
||||
|
||||
public float calculatePricePerNight(){
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
public abstract float calculatePrice();
|
||||
}
|
||||
8
src/java/lodge/reservationsystem/ReservationStatus.java
Normal file
8
src/java/lodge/reservationsystem/ReservationStatus.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package lodge.reservationsystem;
|
||||
|
||||
public enum ReservationStatus {
|
||||
Draft,
|
||||
Canceled,
|
||||
Completed
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user