Slide 27
Slide 27 text
Examples of Reserved Objects(2/2)
予約の実装例(2/2)
abstract class RoomReservation(
id: RoomReservationId,
customerId: CustomerId,
roomPlanId: RoomPlanId,
borrowDate: LocalDate,
numOfNights: NumOfNights,
createAt: Instant
) { ... }
class RoomPlanReservation(...)
exntends RoomReservation(
id, customerId, roomPlanId,
roomId, borrowDate, numOfNights,
createAt) {
// borrow room
def borrowRoom(borrowRoom: BorrowRoom)
: (RoomReservation, RoomBorrowed) = {
require(roomPlan.id == roomPlanId)
require(roomPlan.isSatisfiedBy(room))
(new RoomReservation(this, room.id),
new RoomBorrowed(RoomBorrowedId(),
id, room.id, borrowedDate,
Instant.now()))
}
class RoomReservation(
id: RoomReservationId,
customerId: CustomerId,
roomPlanId: RoomPlanId,
roomId: RoomId,
borrowDate: LocalDate,
numOfNights: NumOfNights,
createAt: Instant)
exntends RoomReservation(
id, customerId, roomPlanId,
roomId, borrowDate, numOfNights,
createAt) { ... }
27