update
This commit is contained in:
@@ -128,6 +128,8 @@ public final class TestReservations {
|
||||
rsrv = account.findReservation(house.getReservation_number());
|
||||
rsrv.calculatePrice();
|
||||
|
||||
mgr.showReservationList();
|
||||
|
||||
System.out.println("Program Completed.");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package lodge.reservationsystem;
|
||||
|
||||
import java.util.List;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
@@ -83,4 +84,14 @@ public final class AccomodationManager {
|
||||
return rsrv;
|
||||
}
|
||||
|
||||
public List<? extends Reservation> getReservationList() {
|
||||
return account_list.getListOfReservations();
|
||||
}
|
||||
|
||||
public void showReservationList() {
|
||||
for (Reservation rsrv : this.getReservationList()) {
|
||||
System.out.println(String.format("Account %s:, %s", rsrv.getAccountNumber(), rsrv.getReservation_number()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,8 +6,7 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.ListIterator;
|
||||
|
||||
public class Account {
|
||||
private String account_number = "-99";
|
||||
@@ -146,9 +145,8 @@ public class Account {
|
||||
this.setMailing_address(acct.mailing_address);
|
||||
}
|
||||
|
||||
public Reservation[] getAllReservations() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException("Unimplemented method 'getAllReservations'");
|
||||
public ListIterator<Reservation> getAllReservations() {
|
||||
return this.reservation_list.listIterator();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
package lodge.reservationsystem;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.classfile.Superclass;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
|
||||
public class AccountList extends ArrayList<Account> {
|
||||
|
||||
@@ -68,8 +68,9 @@ public class AccountList extends ArrayList<Account> {
|
||||
public List<? extends Reservation> getListOfReservations() {
|
||||
ArrayList<Reservation> readList = new ArrayList<Reservation>();
|
||||
for (Account acct: this){
|
||||
for (Reservation rsrv: acct.getAllReservations()){
|
||||
readList.add(rsrv);
|
||||
ListIterator<Reservation> itr = acct.getAllReservations();
|
||||
while( itr.hasNext() ){
|
||||
readList.add(itr.next());
|
||||
}
|
||||
}
|
||||
return Collections.unmodifiableList(readList);
|
||||
|
||||
Reference in New Issue
Block a user