update - write reservation
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -48,6 +48,7 @@ public class Account {
|
|||||||
return reservation_list.add(rsrv);
|
return reservation_list.add(rsrv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// @TODO Write Account out in JSON
|
// @TODO Write Account out in JSON
|
||||||
public static void Write(Account acct) throws IOException {
|
public static void Write(Account acct) throws IOException {
|
||||||
String dataRoot = DataRepository.getPath();
|
String dataRoot = DataRepository.getPath();
|
||||||
@@ -58,6 +59,10 @@ public class Account {
|
|||||||
writer.write(acct.toString());
|
writer.write(acct.toString());
|
||||||
writer.flush();
|
writer.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (Reservation r: acct.reservation_list){
|
||||||
|
r.Write(r);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String account_number() {
|
public String account_number() {
|
||||||
|
|||||||
@@ -175,7 +175,7 @@ public abstract class Reservation{
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
sb.append("{ \"Reservation\":{");
|
sb.append(String.format("{ \"%s\":{", ReservationType()));
|
||||||
sb.append("\"reservation_type\": \"" + ReservationType() + "\",");
|
sb.append("\"reservation_type\": \"" + ReservationType() + "\",");
|
||||||
sb.append("\"reservation_number\": \"" + reservation_number + "\",");
|
sb.append("\"reservation_number\": \"" + reservation_number + "\",");
|
||||||
sb.append("\"reservation_status\": \"" + reservation_status + "\",");
|
sb.append("\"reservation_status\": \"" + reservation_status + "\",");
|
||||||
@@ -200,7 +200,7 @@ public abstract class Reservation{
|
|||||||
Path path = Paths.get(dataRoot);
|
Path path = Paths.get(dataRoot);
|
||||||
|
|
||||||
try (BufferedWriter writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8)) {
|
try (BufferedWriter writer = Files.newBufferedWriter(path, StandardCharsets.UTF_8)) {
|
||||||
writer.write(super.toString());
|
writer.write(toString());
|
||||||
writer.flush();
|
writer.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
src/resources/rsv-R0000000062.json
Normal file
1
src/resources/rsv-R0000000062.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{ "HotelReservation":{"reservation_type": "HotelReservation","reservation_number": "R0000000062","reservation_status": "Canceled","reservation_start_date": "null","reservation_start_date": "null","physical_address": "{ "Address":{"street": "30 cabin ave","city": "Carnelian","state": "CA","zip": "96140"}}","mailing_address": "{ "Address":{"street": "40 cabin ave","city": "Carnelian Bay","state": "CA","zip": "96140"}}","numberOfBeds": "4","numberOfBedRooms": "3","numberOfBathRooms": "1","numberOfFloors": "2","squareFeet": "806","price": "120.0"}}
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
{"CabinReservation": {
|
|
||||||
|
|
||||||
"reservation_number":"R000000062"
|
|
||||||
|
|
||||||
}}
|
|
||||||
Reference in New Issue
Block a user