Download presentation
Presentation is loading. Please wait.
1
Exam Fall 2012 Proposed Solution
Jan Pettersen Nytun
2
1a * * * * Employee DispensedSodaCan 1 SodaCanType type name : String
employeeId : Integer time: Integer name : String * * 1 worksIn dispensedAt 1 Building 1 * VendingMachine positionedIn name : String name : String
3
1b :Employee :Employee name = ‘Harald’ employeeId = 1 name = ‘Sonja’
:Building name = ‘The Castle’ :VendingMachine :VendingMachine name = ‘Lobby’ name = ‘treasure chamber’ :DispensedSodaCan :DispensedSodaCan :DispensedSodaCan Time = Time = Time = :SodaCanType :SodaCanType name = ‘Royal Crown Cola’ name = ‘Solo’
4
1c * * * * Employee DispensedSodaCan 1 SodaCanType type name : String
employeeId : Integer time: Integer name : String * * 1 worksIn dispensedAt 1 1 Building * VendingMachine positionedIn name : String name : String <building name=“The Castle”> <employee name=“Harald“ employeeid=“1”/> <employee name=“Sonja" employeeid=“2”/> <vendingmachine name=“Lobby"/> <vendingmachine name=“treasure chamber"/> </building> <Dispensedsodacan time = “ ” vendingmachine =“Lobby” sodacantype = “Royal Crown Cola”/> <Dispensedsodacan time = “ ” vendingmachine =“Lobby” <Dispensedsodacan time = “ ” vendingmachine =“treasure chamber” sodacantype = “Solo”/>
5
1d Introducing navigation – which in this case is used to decide where to insert foreigner keys Employee DispensedSodaCan 1 SodaCanType * type name : String employeeId : Integer time: Integer name : String * * 1 worksIn 1 dispensedAt Building 1 * VendingMachine positionedIn name : String name : String
6
VendingMachine Building Employee SodaCanType DispensedSodaCan
Name PositionedIn Name “Lobby” “The Castle” “The Castle” “treasure chamber” “The Castle” Employee SodaCanType Name EmployeeId WorksIn Name “Harald” 1 “The Castle” “Royal Crown Cola” “Sonja” 2 “The Castle” “Solo” DispensedSodaCan time DispensedAt Type “ ” “Lobby” “Royal Crown Cola” Assuming time together with name of vending machine is unique “ ” “Lobby” “Royal Crown Cola” “ ” “treasure chamber” “Sola”
7
1e) Make a use case diagram that captures the information given above and, if necessary, add some use case texts describing the use cases. Operate the vending machine to get a soda can employee «include» Receiving recharge message maintenance employee Use case “Operate the vending machine to get a soda can” – describing text: Employee wants a soda can and presses the right soda can type button on the vending machine. If more soda cans of right type, then Vending machine dispenses one soda can; otherwise, vending machine displays “Sorry - no more soda of this type available on this machine”. Vending machine check to see if less than 5 soda cans left of the selected type; if this is the case then include use case “Receive refill message”. Use case “Receive recharge message” – describing text: Vending machine sends message about less than 5 soda cans left of a specific soda can type; a maintenance employee is prompted with this information maintenance employee recharge the vending machine with right type of soda cans.
8
database administrator
1e) Continues... Reconfigure vending machine due to introduction of new soda can type or termination of soda can type maintenance employee Produce soda dispense report database administrator Use case “Produce soda dispense report” – describing text: Database administrator input start time and end time to the soda DB system. DB system produces a report summing up the consumption of the different soda can types for the specified period.
9
but I have not been lecturing this.
1f) Make a “high level” activity diagram that describes the functioning of the system (including the action(s) of the ) when the number of soda cans of a certain type gets under 5. vending machine employee sodaDBServer maintenance employee [soda can available] operate vending machine to get soda can dispense soda can [else] [else] [5 or more soda cans left] send message message: recharge Diagram relates to dispensing of a soda can of the type chosen by the employee. prompt prompt: recharge recharge vending machine Activity diagrams have special notation for sending and receiving messages, but I have not been lecturing this.
10
1g) Make a sequence diagram together with a class diagram that describes the call sequence when (make your own assumptions as you see necessary): a user selects a soda can type on a vending machine which contains only 5 cans of this type the selected type of soda can is being dispensed etc. (add calls as you see natural) and finally, the maintenance employee is being prompted because the number of soda cans is less than 5 VendingMachine 1 name : String dispenceSoda(sodaType : String) SodaDBServer * rechargeVM(vMName : String, sodaType : String) promptMaintenanceEmployeeToRecharge( vMName : String, sodaType : String) 1 1 sodaDBServer UserInterface
11
maintenance employee employee A rather “high level”
:UserInterface v1:VendingMachine :SodaDBServer employee maintenance employee <user selects soda> dispenceSoda(sodaType) <soda dispensed> rechargeVM(vMName, sodaType) promptMaintenance- EmployeeToRecharge( vMName, sodaType) <recharge V.M.> A rather “high level” diagram – suppressing many details.
12
1h TempSource - minTemp: Real - maxTemp: Real + getTemp(): Real
+ addTempListener(l : TempListener): void + setTempInterval(min : Real, max : real) : void + getMinTemp() : Real + getMaxTemp() : Real * «interface» TempListener + tempOutsideInterval(): void + tempInsideInterval() : void TempController + tempOutsideInterval(): void + tempInsideInterval() : void + turnOf(): void CoolingElement + on(): void + off(): void
13
2a Gender Male GenderNotDecided Female 0..1 0..1 0..1 UnidentifiedPerson public abstract class Gender{ } public Male extends Gender { UnidentifiedPerson unidentifiedPerson[]; public GenderNotDecided extends Gender { public Female extends Gender { public UnidentifiedPerson { Female female; Male male; GenderNotDecided genderNotDecided ; * *
14
2b Context UnidentifiedPerson inv:
Gender Male GenderNotDecided Female 0..1 0..1 0..1 UnidentifiedPerson * * An unidentified person (an object of class UnidentifiedPerson) can not be male, female or have the gender not decided (see classes Male, Female, GenderNotDecided) at the same time, i.e., only one of these options are possible at a time. Write an OCL constraint that ensures this. Context UnidentifiedPerson inv: (male->size() + genderNotDecided->size() + female->size()) = 1
15
2c stayedAt crime- Scene
model CrimeScene class Crime attributes startTime : Integer endTime : Integer end class Stay class Location id : Integer beenOnCrimeScene : Boolean association crimeLocation between Crime[0..*] role crime Location[1] role crimeScene association stayLocation between Stay[0..*] role stay Location[1] role stayedAt association staySuspect between Suspect[1] role suspect association crimeSuspect between Crime[] role crime Suspect[0..*] role suspect constraints context Stay inv : startTime < endTime 2c Crime * 1 startTime : Integer endTime : Integer * Stay Suspect * 1 startTime : Integer endTime : Integer beenOnCrimeScene: Boolean * 1 stayedAt 1 Location crime- Scene id : Integer Make an OCL constraint that ensures that the value of startTime is less than the value of endTime for objects of class Stay.
17
2d Crime * 1 startTime : Integer endTime : Integer * Stay Suspect * 1 startTime : Integer endTime : Integer beenOnCrimeScene : Boolean * 1 stayedAt 1 Location crimeScene id : Integer Make an OCL constraint that declares beenOnCrimeScene to be true if the suspect has been located at the crime scene (not necessarily at the time of the crime) otherwise false. (This means that for an object of type Suspect there should be a linked Stay object which is linked to the same Location object as the Crime object (that is, the Crime object which is linked to the Suspect object). You may assume that the id property of Location is unique.
18
context Suspect inv : beenOnCrimeScene = stay
context Suspect inv : beenOnCrimeScene = stay.stayedAt->includes(crime.crimeScene) Been on crime scene at time of crime (assuming onCrimeSceneWhenCrime is attribute of class Suspect) – NOT ASKED FOR ON EXAM: context Suspect inv : onCrimeSceneWhenCrime = stay->select(e | e. startTime >= self.crime.startTime and e.endTime <= self.crime.endTime).stayedAt->includes(crime.crimeScene)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.