Car Rental
Car Rental
Car Rental
create customer
create car
book
request
cancel
user
pickUp
real world customer
billing
return
<<extend>>
<<extend>>
<<actor>>
PersistentStore
early return
billing clerk
late return
<<structure>>
DateT
<<enumeration>>
CatET
E / economy
S / standard
L / luxus
Car
LicenceNo : String
Cat : CatET
create(l:String,ct:CatET):Car
0..1 car
1 customer
Assignment
Registration
0..* booking
searchAvailCar():Car
post Cat<=result.Cat and result.available
Booking
Start : DateT
End : DateT
Cat : CatET
PickedUp : Boolean
Return : DateT
0..1 booking
create(cs:Customer,s:DateT,e:DateT,ct:CatET):Booking
searchAvailCar():Car
assignCar(cr:Car)
returnCar()
10
car : Car
car : Set(Car)
Start<=End
car.notEmpty implies Cat<=car.Cat
ada:Customer
LicenceNo="ABC123"
Cat=S
Name="Ada"
customer
car
Registration
booking
Assignment
b:Booking
Start="11/20"
End="11/23"
Cat=E
PickedUp=true
Return=undef
11
booking
Today="11/22"
Start="11/20"
End="11/23"
Cat=E
PickedUp=true
booking Return=undef
Registration
booking
Assignment
car
customer
vw:Car
ada:Customer
LicenceNo="ABC123"
Cat=S
Name="Ada"
customer
Registration
booking
bob:Customer
b2:Booking
Start="11/16"
End="11/18"
Cat=L
PickedUp=true
Return="11/17"
Name="Bob"
12
ford:Car
LicenceNo="DEF456"
Cat=E
Today="11/23"
Start="11/20"
End="11/23"
Cat=E
PickedUp=false
Return=undef
booking
Assignment
car
ada:Customer
Name="Ada"
customer
vw:Car
LicenceNo="ABC123"
Cat=S
car
Registration
booking
Assignment
b2:Booking
Start="11/22"
End="11/30"
Cat=S
PickedUp=true
Return=undef
booking
booking
Assignment
car
ford:Car
LicenceNo="DEF456"
Cat=E
13
pickUp()
return()
mustReturn
14
BOOK
PICKUP :
pickUp(b) [bookingBelongsToCustomerAndIsDue] /
findAvailableCarAndLinkBookingToFoundCar
booked
BOOK
create(n) /
createNewCustomer
noReturns
cancel(b) [bookingBelongsToCustomer
and bookingOpenOrDue and
onlyOneBookingForCustomer] /
recordCancelation
PICKUP
return(cr) [onlyOneCurrentBookingForCustomer
and noOpenDueBookingForCustomer
and carBelongsToCustomer and
carUnavailableOrDue] /
handleBooking
return(cr)
[onlyOneCurrentBookingForCustomer
and existsOpenDueBookingForCustomer
and carBelongsToCustomer and
carUnavailableOrDue] /
handleBooking
mustReturn
return(cr) [moreThanOneCurrentBookingForCustomer
and carBelongsToCustomer and
carUnavailableOrDue] /
handleBooking
BOOK
cancel(b) [bookingBelongsToCustomer
PICKUP
and bookingOpenOrDue] /
recordCancelation
15
open
when(todayIsTheBookingsStartDay)
when(todayIsAfterTheBookingStartDay) /
recordCancelation
due
closed
assignCar(cr) /
linkBookingAndCarAndRecordPickUp
returnCar() /
unlinkBookingAndCarAndRecordReturnDay
current
16
create(l,ct) / createNewCar
available
carAssigned
carReturned
unAvailable
carReturned
due
when(todayIsTheBookingsEndDay)
17
BOOK
( booking->select(open)->size>0 or
booking->select(due)->size>0 ) and
booking->select(current)->size=0
booked
cancel(b)
[ CANOK and CAN2noReturns ]
noReturns
booking->select(current)->size>0
return(cr)
[ RETOK and RET2booked ] /
RETACT
BOOK
return(cr)
[ RETOK and RET2noReturns ] /
RETACT
RET2mustReturn: booking->select(current)->size>1
mustReturn
RETACT: cr.booking.returnCar()
booking->select(open)->size=0 and
booking->select(due)->size=0 and
booking->select(current)->size=0
cancel(b)
[ CANOK ]
return(cr)
[ RETOK and RET2mustReturn ] /
RETACT
PICKUP
18
6. Car Rental - Customer Statechart with Fomal Details Using Junction Points
BOOK
( booking->select(open)->size>0 or
booking->select(due)->size>0 ) and
booking->select(current)->size=0
booked
BOOK
[ CAN2booked ]
cancel(b)
[ CANOK ]
create(n) /
Name=n
[ CAN2noReturns ]
RETOK: booking.car->includes(cr) and
(cr.unAvailable or cr.due)
[ RET2booked ]
noReturns
PICKUP
BOOK
[ RET2noReturns ]
return(cr)
[ RETOK ] /
RETACT
RET2mustReturn: booking->select(current)->size>1
[ RET2mustReturn ]
mustReturn
RETACT: cr.booking.returnCar()
booking->select(open)->size=0 and
booking->select(due)->size=0 and
booking->select(current)->size=0
cancel(b)
[ CANOK ]
booking->select(current)->size>0
PICKUP
19
open
when(Today=Start)
customer.cancel(self) /
PickedUp=false
when(Today>Start) /
PickedUp=false;
customer.cancel(self)
due
closed
assignCar(cr) /
link(Assignment,[self,cr]);
PickedUp=true
returnCar() / unlink(Assignment,[self,car]);
Return=Today
current
20
booking.returnCar()
unAvailable
due
when(Today=booking.End)
21
create("Ada")
ada:Customer
noReturns
create("ABC123",S)
vw:Car
available
book("11/20","11/23",E)
create(ada,"11/20","11/23",E)
b:Booking
booked
open
Today=b.Start
due
pickUp(b)
searchAvailCar()
vw
assignCar(vw)
unAvailable
current
vw
mustReturn
Today=b.End
due
return(vw)
returnCar()
noReturns
available
22
closed
create("Ada")
ada:Customer
ada:Customer
noReturns
create("ABC123",S)
ada:Customer
vw:Car
vw:Car
available
book("11/20","11/23",E)
create(ada,"11/20","11/23",E)
b:Booking
booked
ada:Customer
b:Booking
vw:Car
ada:Customer
b:Booking
vw:Car
ada:Customer
b:Booking
vw:Car
open
Today=b.Start
due
pickUp(b)
searchAvailCar()
vw
assignCar(vw)
unAvailable
current
vw
mustReturn
Today=b.End
due
return(vw)
returnCar()
noReturns
available
closed
23
4. pickUp(b)
5. return(vw)
customer
car
booking {new}
ada:Customer {new}
b:Booking {new}
3.1 create(ada,"11/20","11/23",E)
4.1 searchAvailCar()
4.2 assignCar(vw)
5.1 returnCar()
24
car {transient}
vw:Car {new}
create("Ada")
ada:Customer
noReturns
book("11/20","11/23",E)
create(ada,"11/20","11/23",E)
booked
b:Booking
open
Today=b.Start
due
pickUp(b)
searchAvailCar()
create("ABC123",S)
vw:Car
available
vw
assignCar(vw)
unAvailable
current
vw
mustReturn
Today=b.End
due
return(vw)
returnCar()
noReturns
available
25
closed
create("Ada")
ada:Customer
ada:Customer
noReturns
book("11/20","11/23",E)
create(ada,"11/20","11/23",E)
b:Booking
booked
ada:Customer
b:Booking
ada:Customer
b:Booking
vw:Car
ada:Customer
b:Booking
vw:Car
ada:Customer
b:Booking
vw:Car
open
Today=b.Start
due
pickUp(b)
searchAvailCar()
create("ABC123",S)
vw:Car
available
vw
assignCar(vw)
unAvailable
current
vw
mustReturn
Today=b.End
due
return(vw)
returnCar()
noReturns
available
closed
26
1. create("Ada")
2. book("11/20","11/23",E)
3.2 create("ABC123",S)
3. pickUp(b)
4. return(vw)
customer
booking {new}
ada:Customer {new}
car {transient}
b:Booking {new}
2.1 create(ada,"11/20","11/23",E)
3.1 searchAvailCar()
3.3 assignCar(vw)
4.1 returnCar()
27
car
vw:Car {new}
create("Ada")
ada:Customer
noReturns
book("11/20","11/23",E)
create(ada,"11/20","11/23",E)
booked
b:Booking
open
Today=b.Start
due
Today>b.Start
cancel(b)
noReturns
28
closed
create("Ada")
ada:Customer
noReturns
book("11/20","11/23",E)
create(ada,"11/20","11/23",E)
b:Booking
booked
open
noReturns
closed
cancel(b)
Today<b.Start
29
create("Ada")
ada:Customer
noReturns
create("ABC123",S)
vw:Car
available
book("11/20","11/23",E)
create(ada,"11/20","11/23",E)
booked
b:Booking
open
Today=b.Start
due
pickUp(b)
searchAvailCar()
vw
assignCar(vw)
vw
unAvailable
current
available
closed
mustReturn
return(vw)
returnCar()
noReturns
Today=b.End
30
create("Ada")
ada:Customer
noReturns
create("ABC123",S)
vw:Car
available
book("11/20","11/23",E)
create(ada,"11/20","11/23",E)
b:Booking
booked
open
Today=b.Start
due
pickUp(b)
searchAvailCar()
vw
assignCar(vw)
vw
unAvailable
current
mustReturn
Today>b.End
due
return(vw)
returnCar()
noReturns
available
31
closed
Today=b1.Start
vw:Car
b1:Booking
ada:Customer
b2:Booking
ford:Car
available
due
booked
open
available
assignCar(vw)
unAvailable
Today=b1.End
Today=b2.Start
current
mustReturn
due
due
return(vw)
available
closed
assignCar(ford)
current
32
unAvailable
Today=b1.Start
vw:Car
b1:Booking
ada:Customer
b2:Booking
ford:Car
available
due
booked
open
available
assignCar(vw)
unAvailable
Today=b1.End
Today=b2.Start
current
mustReturn
due
due
assignCar(ford)
current
return(vw)
available
closed
33
unAvailable
6. Car Rental - Activity Diagrams for pickUp: Textual Level and Operation Level
Customer::pickUp(b):Car
Customer::pickUp(b):Car
testAvailableCars
[noCarAvailable]
[carAvailable]
result=b.searchAvailCar()
chooseAnAvailableCar
purchaseANewCar
connectTheBookingToTheCar
b.assignCar(result)
indicateThatACarHasBeenPickedUp
returnTheCar
return(result)
34
6. Car Rental - Activity Diagrams for pickUp: Statement Level and Formal Level
Customer::pickUp(b):Car
Customer::pickUp(b):Car
Car.allInstances->exists(cr|
cr.available and cr.Cat>=b.Cat)
testAvailableCars
[true]
[else]
[carAvailable]
result=someAvailableCar
result=someNewCar
[false]
result:=Car.allInstances->
select(cr|cr.available and
cr.Cat>=b.Cat)->any
result:=Car.create(newLicNo,b.Cat)
link(Assignment,[b,result])
b.car:=b.car->including(result)
b.pickedUp=true
b.pickedUp:=true
return(result)
return(result)
35
[diagrams ok]
modify object
diagram
modify class
diagram
modify statechart
diagram
modify sequence
diagram
36
OD
CD
SC
37
SeqD