6. Car Rental Case Study In UML - Uni-bremen.de

Transcription

6. Car Rental Case Study inUML

6. Car Rental Case Study in UML6.1 Getting Started To follow: A medium sized case study for a car rentaladministration system Explanation of central UML diagrams and languagefeatures therein Used here: Use case, class, object, statechart,sequence, collaboration, and activity diagrams Development of the case study also demonstrates atypical development process Diagram order in this document does not reflect theorder occurring in the development218

6.1 Getting Started219Overview on the Used Development Process(1) Start with a use case diagram giving an overview onthe system, its boundaries and its main functionality(2) Develop object diagrams and sequence diagrams asdesired scenarios for the system structure and behavior(3) Develop a class diagram and a statechart diagram foreach class; start with a textual description of thestatechart diagrams; continue with a more formaldescription for the statecharts

6.2 Getting Started220Overview on the Used Development Process(4) Check whether the existing object diagrams andsequence diagrams are consistent with the classdiagram and the statechart diagrams; if neccessary,modify them(5) Develop more object and sequence diagrams(6) If an operations seems to become stable (no changesin the diagrams for the parts with that operation), start todevelop activity diagrams for that operation; begin witha textual description and advance to a more formal one(7) Repeat steps (4)-(6) until an acceptable model isfound

6.2 Getting Started2216.2 Use Cases

6.2 Use Cases222Use Case DiagramCar Rental SystemA real world customeris outside the Car Rental System,a customer within that system.create customercreate carbookrequestcanceluserpickUpreal world customerbillingreturn extend extend actor PersistentStoreearly returnbilling clerklate return

6.2 Use CasesDetails for Use Case create customerUse case name: create customerGoal: to create a new customerPrecondition: the real world customer to be recorded iscurrently not representedPostcondition: a new customer existsActors: userTriggering event: a real world customer must be recordedDescription: Extensions: Alternatives: -223

6.2 Use Cases224Details for Use Case create carUse case name: create carGoal: to create a new carPrecondition: the real world car to be recorded iscurrently not representedPostcondition: a new car existsActors: userTriggering event: a real world car must be recordedDescription: Extensions: Alternatives: -

6.2 Use Cases225Details for Use Case bookUse case name: bookGoal: to enter a car rental bookingPrecondition: the booking details are plausiblePostcondition: a new booking exists; the booking isnow an open bookingActors: userTriggering event: a real world customer requests a bookingDescription: the real world customer wants to rent a realworld car of a certain category; start day of the rental isthe current day or a day after the current day; end day ofthe rental lies after the start dayExtensions: Alternatives: -

6.2 Use Cases226Details for Use Case cancelUse case name: cancelGoal: to prevent that a car must be picked up for a bookingPrecondition: the booking to be canceled is presentPostcondition: the booking is marked as closed; no car willbe picked up for this bookingActors: userTriggering event: a real world customer requests acancelation of a bookingDescription: Extensions: Alternatives: triggering event - the start day of a bookingis passed and no car has been picked up by the customer forthat booking

6.2 Use Cases227Details for Use Case pickUpUse case name: pickUpGoal: to deliver a car for a car rentalPrecondition: a booking is presentPostcondition: a suitable car is marked as unavailable (areal world car is given to a real world customer); thebooking becomes a current bookingActors: userTriggering event: a real world customer requests a pick upDescription: a suitable car must be found among thecurrently available cars; if none is present, a new car maybe added (a new real world car is purchased)Extensions: Alternatives: -

6.3 Use Cases228Details for Use Case returnUse case name: returnGoal: to return a car for a car rentalPrecondition: a current booking exists and a car has beendeliveredPostcondition: the booking becomes closed; the car becomesavailable (real world customer has returned real world car)Actors: userTriggering event: a real world customer requests a return onthe end day of the bookingDescription: Extensions:early return: a rented car is returned before the end dateof the bookinglate return: a rented car is returned after the end date ofthe bookingAlternatives: -

6.3 Use Cases2296.3 Static Structure Diagrams

6.3 Static Structure Diagrams230Class DiagramCustomerName : eturn(cr:Car) structure DateT enumeration CatETDay : Integer 1.31 Month : Integer 1.12 Year : Integer 1900.2100 E / economyS / standardL / luxusCarLicenceNo : StringCat : CatETcreate(l:String,ct:CatET):Car0.1 car1 customerAssignmentRegistration"only correct dates"0.* bookingsearchAvailCar():Carpost Cat result.Cat and result.availableBookingAttention! many dateTBooking::returnCar()Start : DateTEnd : DateTCat : CatETPickedUp : BooleanReturn : DateT0.1 rnCar()car : Carcar : Set(Car)Start Endcar.notEmpty implies Cat car.Cat

6.3 Static Structure Diagrams231Allowed Object Diagram: 3 Classes, 3 ObjectsToday "11/22"vw:Carada:CustomerLicenceNo "ABC123"Cat SName kingStart "11/20"End "11/23"Cat EPickedUp trueReturn undefbooking

6.3 Static Structure Diagrams232Allowed Object Diagram: 3 Classes, 6 Objectsb1:BookingToday "11/22"Start "11/20"End "11/23"Cat EPickedUp truebooking Return rada:CustomerLicenceNo "ABC123"Cat SName "Ada"customerRegistrationbookingbob:CustomerName "Bob"b2:BookingStart "11/16"End "11/18"Cat LPickedUp trueReturn "11/17"ford:CarLicenceNo "DEF456"Cat E

6.4 Static Structure Diagrams233Disallowed Object Diagramb1:BookingToday "11/23"Start "11/20"End "11/23"Cat EPickedUp falseReturn undefbookingAssignmentcar1. Booking b1 without customer2. Car vw has 2 bookings3. Booking b2 has 2 cars4. b2’s Cat is S, ford’s Cat is Eada:CustomerName "Ada"customervw:CarLicenceNo "ABC123"Cat ScarRegistrationbookingAssignmentb2:BookingStart "11/22"End "11/30"Cat SPickedUp trueReturn undefbookingbookingAssignmentcarford:CarLicenceNo "DEF456"Cat E

6.4 Static Structure Diagrams6.4 Statechart Diagrams234

6.4 Statechart Diagrams235Main Idea of Customer kUp()return()mustReturn

6.4 Statechart Diagrams236Customer Statechart with Textual DetailsBOOK :book(s,e,ct) [paramsOk] / createNewBookingcancel(b) [bookingBelongsToCustomer andbookingOpenOrDue andmoreThanOneBookingForCustomer] /recordCancelationBOOKPICKUP :pickUp(b) [bookingBelongsToCustomerAndIsDue] Kcreate(n) /createNewCustomernoReturnscancel(b) [bookingBelongsToCustomerand bookingOpenOrDue andonlyOneBookingForCustomer] /recordCancelationPICKUPreturn(cr) [onlyOneCurrentBookingForCustomerand noOpenDueBookingForCustomerand carBelongsToCustomer andcarUnavailableOrDue] ustomerand existsOpenDueBookingForCustomerand carBelongsToCustomer andcarUnavailableOrDue] /handleBookingmustReturnreturn(cr) [moreThanOneCurrentBookingForCustomerand carBelongsToCustomer andcarUnavailableOrDue] /handleBookingBOOKcancel(b) [bookingBelongsToCustomerPICKUPand bookingOpenOrDue] /recordCancelation

6.4 Statechart Diagrams237Booking Statechart with Textual Detailscreate(cs,s,e,ct) /createNewBookingcustomerCancels Day)when(todayIsAfterTheBookingStartDay) /recordCancelationdueclosedassignCar(cr) /linkBookingAndCarAndRecordPickUpreturnCar() /unlinkBookingAndCarAndRecordReturnDaycurrent

6.4 Statechart Diagrams238Car Statechart with Textual Detailscreate(l,ct) / ablecarReturnedduewhen(todayIsTheBookingsEndDay)

6.4 Statechart Diagrams239Customer Statechart with Formal Detailscancel(b)[ CANOK and CAN2booked ]BOOK( booking- select(open)- size 0 orbooking- select(due)- size 0 ) andbooking- select(current)- size 0BOOK: book(s,e,ct) [ Today s and s e ] /booking.create(self,s,e,ct)PICKUP: pickUp(b) [ booking- includes(b) and b.due ] /result b.searchAvailCar(); b.assignCar(result)bookedCANOK: booking- includes(b) and (b.open or b.due)BOOKCAN2noReturns: booking- select(open or due)- size 1create(n) /Name ncancel(b)[ CANOK and CAN2noReturns ]CAN2booked: booking- select(open or due)- size 1PICKUPnoReturnsbooking- select(current)- size 0RETOK: booking.car- includes(cr) and(cr.unAvailable or cr.due)return(cr)[ RETOK and RET2booked ] /RETACTBOOKRET2noReturns: ( booking- select(open)- size 0 andbooking- select(due)- size 0 ) andbooking- select(current)- size 1RET2booked: ( booking- select(open)- size 0 orbooking- select(due)- size 0 ) andbooking- select(current)- size 1return(cr)[ RETOK and RET2noReturns ] /RETACTRET2mustReturn: booking- select(current)- size 1mustReturnRETACT: cr.booking.returnCar()booking- select(open)- size 0 andbooking- select(due)- size 0 andbooking- select(current)- size 0return(cr)[ RETOK and RET2mustReturn ] /RETACTcancel(b)[ CANOK ]PICKUP

6.4 Statechart Diagrams240Customer Statechart with Formal Details Using Junction PointsBOOK( booking- select(open)- size 0 orbooking- select(due)- size 0 ) andbooking- select(current)- size 0BOOK: book(s,e,ct) [ Today s and s e ] /booking.create(self,s,e,ct)PICKUP: pickUp(b) [ booking- includes(b) and b.due ] /result b.searchAvailCar(); b.assignCar(result)bookedBOOK[ CAN2booked ]CANOK: booking- includes(b) and (b.open or b.due)cancel(b)[ CANOK ]create(n) /Name nCAN2noReturns: booking- select(open or due)- size 1CAN2booked: booking- select(open or due)- size 1[ CAN2noReturns ]RETOK: booking.car- includes(cr) and(cr.unAvailable or cr.due)[ RET2booked ]noReturnsPICKUPBOOK[ RET2noReturns ]RET2noReturns: ( booking- select(open)- size 0 andbooking- select(due)- size 0 ) andbooking- select(current)- size 1RET2booked: ( booking- select(open)- size 0 orbooking- select(due)- size 0 ) andbooking- select(current)- size 1return(cr)[ RETOK ] /RETACTRET2mustReturn: booking- select(current)- size 1[ RET2mustReturn ]mustReturnRETACT: cr.booking.returnCar()booking- select(open)- size 0 andbooking- select(due)- size 0 andbooking- select(current)- size 0cancel(b)[ CANOK ]booking- select(current)- size 0PICKUP

6.4 Statechart Diagrams241Booking Statechart With Formal Detailscreate(cs,s,e,ct) / Start s; End e;Cat ct; link(Registration,[cs,self])openwhen(Today Start)customer.cancel(self) /PickedUp falsewhen(Today Start) /PickedUp false;customer.cancel(self)dueassignCar(cr) /link(Assignment,[self,cr]);PickedUp trueclosedreturnCar() / unlink(Assignment,[self,car]);Return Todaycurrent

6.4 Statechart Diagrams242Car Statechart with Formal Detailscreate(l,ct) / LicenceNo l; Cat r()booking.returnCar()unAvailableduewhen(Today booking.End)

6.4 Statechart Diagrams243Sequence Diagram for Booking: Car.create; kedopenToday unAvailablecurrentvwmustReturnToday sed

6.5 Statechart Diagrams244Sequence Diagram for Booking:Car.create; Booking.create (with ngvw:CaropenToday unAvailablecurrentvwmustReturnToday sed

6.5 Statechart Diagrams6.5 Collaboration Diagrams245

6.5 Collaboration Diagrams246Collaboration Diagram for Booking: Car.create; Booking.create:User1. create("Ada")3. book("11/20","11/23",E)2. create("ABC123",S)4. pickUp(b)5. return(vw)customercarbooking {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()car {transient}vw:Car {new}

6.5 Collaboration Diagrams247Sequence Diagram for Booking: Booking.create; )bookedb:BookingopenToday tvwmustReturnToday sed

6.5 Collaboration Diagrams248Sequence Diagram for Booking:Booking.create; Car.create (with rada:Customerb:Bookingvw:CaropenToday tvwmustReturnToday sed

6.5 Collaboration Diagrams249Collaboration Diagram for Booking: Booking.create; Car.create:User1. create("Ada")2. book("11/20","11/23",E)3.2 create("ABC123",S)3. pickUp(b)4. return(vw)customerbooking {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()carvw:C

Car Rental Case Study in UML 218 6.1 Getting Started To follow: A medium sized case study for a car rental administration system Explanation of central UML diagrams and language features therein Used here: Use case, class, object, statechart, sequence, collaboration, and activity diagrams Development of the case study also demonstrates a typical development process Diagram .File Size: 1009KBPage Count: 44