UML教材2Car Case Design.docx
《UML教材2Car Case Design.docx》由会员分享,可在线阅读,更多相关《UML教材2Car Case Design.docx(30页珍藏版)》请在冰豆网上搜索。
UML教材2CarCaseDesign
APACHERENTACARCASE–DESIGN
ThissectioncontainsthedesignmodelsfortheApacheRentACarcase.Themodelsappearinchaptersequence.
ApacheRentACar–Chapter7
Introduction
Thischapterdiscussesthedesignoftheoverallsystemstructure.Thequestionsillustratehowto:
1.AllocateEssentialUseCasestoProcessors
2.AllocateStoredDatatoStorageDevices
Notethatthesestepsarenotpartofthesevenstepsforprogramdesign.
ApacheRentACarAssignments–Chapter7
1.DefinethreealternativesystemstructuresfortheApacheRentACarsystem.(SeeFigures7.13,7.14,and7.15fortheuniversityregistrationsystem.)
Alternative“A”allocatestheusecasestotwoprocessors.
Alternative“B”allocatestheusecasestoasingleprocessor,butaddsasecondprocessorforthedatastorage.
Alternative“C”sameasAlternative“A”butalsoallocatesthedatastoragetoaseparateprocessor.
2.Discussqualitativelytheadvantagesanddisadvantagesofeachalternative.
a.Alternative“A”allocatestheusecasestwoprocessors
∙Advantage:
Thiskeepsthecarmaintenancesystemusedbyemployeesseparatefromthereservationandrentalsystemusedbythecustomers.
∙Disadvantage:
Thetwoprocessorswillhavetocommunicatefrequentlywitheachother.
b.Alternative“B”allocatestheusecasestosameprocessor,butaddsasecondprocessorforthedatastorage.
∙Advantage:
Thiswillensurethatthedataissecure.Itwillbeeasiertobackupandmaintainaswell.
∙Disadvantage:
Thetwoprocessorswillhavetocommunicatefrequentlywitheachother.
c.Alternative“C”sameasAlternative“A”butallocatesalldatastoragetoaseparatestorageprocessor.
∙Advantage:
Thisallowstheprocessorstobesinglefunctionandthuscanbeoptimized.Italsomakesiteasytobackupthedatastorage,asitisseparate.
∙Disadvantage:
Thethreeprocessorswillhavetocommunicatefrequentlywitheachother.
ApacheRentACar–Chapter8
Introduction
Thischapterdiscussesthefirststepoftheseven-stepprocessforobject-orientedprogramdesign.Thisstepis:
Step1.Produceaninteractiondiagramforeachsystemoperationidentifiedduringanalysis
ApacheRentACarAssignments–Chapter8
ApacheRentACarInteractionDiagram
Thetextbookshowsalltheintermediatestepsnecessarytoobtainacollaborationdiagram.Attheendofthechapter,theyareconvertedtoasequencediagram.Oncetheindividualeventshavebeenconvertedtoacollaborationdiagram,itiscommontoconvertthemtoasequencediagram.Manypeoplefeelitiseasiertoreadsequencediagramsbecauseoftheirsequentialnature.Theanswerstothesequestionsarepresentedinthisformat.Alsoallsystemoperationsforeachusecasearegroupedtogetherinasinglesequencediagraminthesystem.
Developaseparatesetofinteractiondiagrams(eithercollaborationorsequencediagrams)foreachoftheusecasesintheRentACarsystem.
BesurethattheinteractiondiagramforeachusecasedemonstrateshowyouverifythepreconditionsandsatisfythepostconditionsforeachofthesystemoperationcontractspreparedfortheChapter5assignments.Showanexplicitcreateoperationforeachnewobject.Alsoshowanexplicitassociateoperationforeachnewlyestablishedlink.Alsobesurethateachobjectknowsalltheargumentsforanymessagethatitsends.
Suggestion:
SketchtheinteractiondiagramsfollowingthemethoddescribedinChapter8beforeyouuseanysoftwaretooltopreparethediagrams.
ApacheRentACar–Chapter9
Introduction
Thischapterdiscussessteps2and3oftheseven-stepprocessforobject-orientedprogramdesign.Thesestepsare:
Step2.Produceadesignclassdiagramshowingtheoperationsfromtheinteractiondiagrams.
Step3.Specifythesignatureandthealgorithmforeachoperation.
ApacheRentACarAssignments–Chapter9
ApacheRentACarClassDiagram
Chapter9showsthedevelopmentoftheclassdiagramwithaspecialemphasisonqualifiedassociations.
1.DevelopadesignclassdiagramfortheApacheRentACarsystem.
Payparticularattentiontoappropriateuseoftheaggregationandcompositionsymbols,whichareusedwhenanassociationbetweenclassesrelatespartstowholes,memberstogroups,orcontentstocontainers.Showclasshierarchies.Alsobesuretoindicateonthediagramnavigabilityfromoneclasstoanother.
2.ReviseandrefinetheinteractiondiagramsdevelopedfortheChapter8assignment.CorrectanyviolationsoftheLawofDemeter,reducethecoupling,andincreasethecohesion.Modifythedesignclassdiagramtobeconsistentwiththeseimprovements.
Wetookgreatcaretobesurenoneoftheseviolationswerepresentedearlier.Moststudentsunderstandcouplingandcohesion.TheLawofDemeterisprobablythemostdifficultonetoavoid.NotethatoperationslikemakeReturn,makeDriver,makeExtraCharge,andmakePaymentoccurinCarandRental.Thisispreferabletohavingthefaçadeobjectinvokeagetoperationineachoftheaboveclassestoobtaintherentalobjectandthensendamessagetoit.Thishabitiscommonamongbeginners,especiallyinprogrammingclasses.
ApacheRentACarSignatures
Althoughnotaskedfor,signaturesforalloperationswillbeprovided.Thismakesitpossiblefortheinstructortoeasilyaddanassignmenttodevelopthem.
3.Developsignaturesforalloperations.Youmayomitthe“creates”becausetheyareofastandardformat.(optionalquestion)
ThisanswerisprovidedwithsignaturesinaUMLformatasinFigure9.22.ThedatatypesarecompatiblewithJava.
CompleteSpecificationofAttributesandOperations–ApacheRentACar
Car
Attributes
-color:
String
-licenseNumber:
String
-make:
String
-model:
String
-modelYear:
int
Operations
+associateExtraChargeSpecification
(extraChargeSpecification,ExtraChargeSpecification)
+associateRental(rental:
Rental)
+associateInspection(inspection:
Inspection)
+associateThirdPartyPayer(thirdPartyPayer,ThirdPartyPayer)
+authorize(amount:
double,merchantNumber:
int):
boolean
+makeCreditCard(creditCardNumber:
String,
expirationMonth:
int,expirationYear:
int)
+makeDriver(name:
String,birthDate:
Date,
driversLicenseNumber:
String,stateOfIssue:
String)
+makeExtraCharge(amountCharged:
double)
+makeInspection(damage:
double,gasLevel:
double,mileageIn:
int,
time:
Date)
+makePayment(amount:
double)
+makeRental(timeOut:
Date,mileageOut:
int)
+makeReturn(timeIn:
Date)
CreditCard
Attributes
-creditCardNumber:
String
-expirationMonth:
int
-expirationYear:
int
Operations
+authorize(amount:
double,merchantNumber:
int):
int
Customer
Attributes
-address:
String
-name:
String
-phoneNumber:
String
Operations
None
CompleteSpecificationofAttributesandOperations–ApacheRentACar(Continued)
Driver
Attributes
-birthDate:
Date
-driversLicenseNumber:
String
-name:
String
-stateOfIssue:
String
Operations
None
ExtraCharge
Attributes
-amountCharged:
double
Operations
+associateExtraChargeSpecification
(extraChargeSpecification,ExtraChargeSpecification)
ExtraChargeSpecification
Attributes
-extraChargeCode:
String
-description:
String
-price:
double
Operations
None
Inspection
Attributes
-damage:
double
-gasLevel:
double
-mileageIn:
int
-time:
Date
Operations
None
Payment
Attributes
-amount:
double
-authorizationNumber:
int
-date:
Date
Operations
+associateCreditCard(creditCard:
CreditCard)
+authorize(amount:
double,
merchantNumber:
int):
boolean
+makeCreditCard(creditCardNumber:
String,
expirationMonth:
int,expirationYear:
int)
RentalSystem
Attributes
None
Operations
+assignCar()
+enterCarRequest(carType:
String,pickUpDate:
Date,
returnDate:
Date)
+enterConfirmation(confirmationNumber:
int,timeOut:
Date)
+enterCreditCard(creditCardNumber:
String,
expirationMonth:
int,expirationYear:
int)
+enterCustomer(phoneNumber:
String,name:
String,address:
String)
+enterDriver(name:
String,birthDate:
Date,
driversLicenseNumber:
String,stateOfIssue:
String)
+enterExtraCharge(extraChargeCode:
String,amountCharged:
double)
+enterInspection(licenseNumber:
String,damage:
double,
gasLevel:
double,mileageIn:
int)
+enterMileageOut(mileageOut:
int)
+enterReturn(licenseNumber:
String,timeIn:
Date)
+enterThirdPartyCustomer(accountNumber:
int)
+enterPayment(licenseNumber:
String,amount:
double)
+verifyCarLicense(licenseNumber:
String):
boolean
+verifyConfirmationNumber(confirmationNumber:
int):
boolean
+verifyExtraChargeCode(extraChargeCode:
String):
boolean
+verifyRateCode(carType:
String):
boolean
+verifyThirdPartyCustomer(accountNumber:
int):
boolean
CompleteSpecificationofAttributesandOperations–ApacheRentACar(Continued)
RateClass
Attributes
-carType:
String
-dailyRate:
double
-mileageRate:
double
-numberOfFreeMiles:
int
-weekEndRate:
double
-weeklyRate:
double
Operations
None
Rental
Attributes
-agreementNumber:
int
-mileageOut:
int
-timeOut:
Date
Operations
+associateDriver(checkOut:
CheckOut)
+associateExtraCharge(extraCharge,ExtraCharge)
+associateExtraChargeSpecification
(extraChargeSpecification,ExtraChargeSpecification)
+associateInspection(inspection,Inspection)
+associatePayment(payment,Payment)
+associateReservation(reservation,Reservation)
+associateReturn(return,Return)
+associateThirdPartyPayer
(thirdPartyCustomer,ThirdPartyCustomer)
+authorize(amount:
double,merchantNumber:
int):
boolean
+makeCreditCard(creditCardNumber:
String,
expirationMonth:
int,expiration