Exam Fall 2012 Proposed Solution Jan Pettersen Nytun

  • Slides: 18
Download presentation
Exam Fall 2012 Proposed Solution Jan Pettersen Nytun

Exam Fall 2012 Proposed Solution Jan Pettersen Nytun

1 a Employee Dispensed. Soda. Can name : String employee. Id : Integer time:

1 a Employee Dispensed. Soda. Can name : String employee. Id : Integer time: Integer * 1 * * works. In Building name : String 1 dispensed. At 1 positioned. In * Vending. Machine name : String 1 type Soda. Can. Type name : String

1 b : Employee name = ‘Harald’ employee. Id = 1 name = ‘Sonja’

1 b : Employee name = ‘Harald’ employee. Id = 1 name = ‘Sonja’ employee. Id = 2 : Building name = ‘The Castle’ : Vending. Machine name = ‘Lobby’ : Vending. Machine name = ‘treasure chamber’ : Dispensed. Soda. Can Time = 1111111 Time = 1111222 Time = 1111333 : Soda. Can. Type name = ‘Royal Crown Cola’ : Soda. Can. Type name = ‘Solo’

1 c Employee Dispensed. Soda. Can name : String employee. Id : Integer time:

1 c Employee Dispensed. Soda. Can name : String employee. Id : Integer time: Integer * 1 * * works. In Building name : String 1 1 dispensed. At * Vending. Machine positioned. In 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 = “ 1111111” vendingmachine =“Lobby” sodacantype = “Royal Crown Cola”/> <Dispensedsodacan time = “ 1111222” vendingmachine =“Lobby” sodacantype = “Royal Crown Cola”/> <Dispensedsodacan time = “ 1111333” vendingmachine =“treasure chamber” sodacantype = “Solo”/> 1 type Soda. Can. Type name : String

1 d Introducing navigation – which in this case is used to decide where

1 d Introducing navigation – which in this case is used to decide where to insert foreigner keys Employee Dispensed. Soda. Can name : String employee. Id : Integer time: Integer * 1 * * works. In Building name : String 1 1 positioned. In * dispensed. At Vending. Machine name : String 1 type Soda. Can. Type name : String

Vending. Machine Building Name Positioned. In Name “Lobby” “The Castle” “treasure chamber” “The Castle”

Vending. Machine Building Name Positioned. In Name “Lobby” “The Castle” “treasure chamber” “The Castle” Employee Soda. Can. Type Name Employee. Id Works. In Name “Harald” 1 “The Castle” “Royal Crown Cola” “Sonja” 2 “The Castle” “Solo” Dispensed. Soda. Can time Dispensed. At Type “ 1111111” “Lobby” “Royal Crown Cola” “ 1111222” “Lobby” “Royal Crown Cola” “ 1111333” “treasure chamber” “Sola” Assuming time together with name of vending machine is unique

1 e) Make a use case diagram that captures the information given above and,

1 e) 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.

1 e) Continues. . . Reconfigure vending machine due to introduction of new soda

1 e) 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 produces a report summing up the consumption of the different soda can types for the specified period.

1 f) Make a “high level” activity diagram that describes the functioning of the

1 f) 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 soda. DBServer maintenance employee [soda can available] operate vending machine to get soda can dispense soda can [else] [5 or more soda cans left] send message: recharge Diagram relates to dispensing of a soda can of the type chosen by the employee. prompt: recharge vending machine Activity diagrams have special notation for sending and receiving messages, but I have not been lecturing this.

1 g) Make a sequence diagram together with a class diagram that describes the

1 g) 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 1 Vending. Machine name : String dispence. Soda(soda. Type : String) * 1 User. Interface Soda. DBServer 1 soda. DBServer recharge. VM(v. MName : String, soda. Type : String) prompt. Maintenance. Employee. To. Recharge( v. MName : String, soda. Type : String)

: User. Interface v 1: Vending. Machine : Soda. DBServer maintenance employee <user selects

: User. Interface v 1: Vending. Machine : Soda. DBServer maintenance employee <user selects soda> dispence. Soda(soda. Type) <soda dispensed> recharge. VM(v. MName, soda. Type) prompt. Maintenance. Employee. To. Recharge( v. MName, soda. Type) <recharge V. M. > A rather “high level” diagram – suppressing many details.

1 h Temp. Source - min. Temp: Real - max. Temp: Real + get.

1 h Temp. Source - min. Temp: Real - max. Temp: Real + get. Temp(): Real + add. Temp. Listener(l : Temp. Listener): void + set. Temp. Interval(min : Real, max : real) : void + get. Min. Temp() : Real + get. Max. Temp() : Real * «interface» Temp. Listener + temp. Outside. Interval(): void + temp. Inside. Interval() : void Temp. Controller + temp. Outside. Interval(): void + temp. Inside. Interval() : void + turn. Of(): void Cooling. Element + on(): void + off(): void

2 a Gender Male 0. . 1 public abstract class Gender{ * } public

2 a Gender Male 0. . 1 public abstract class Gender{ * } public Male extends Gender { Unidentified. Person unidentified. Person[]; } public Gender. Not. Decided extends Gender { Unidentified. Person unidentified. Person[]; } public Female extends Gender { Unidentified. Person unidentified. Person[]; } public Unidentified. Person { Female female; Male male; Gender. Not. Decided gender. Not. Decided ; } Gender. Not. Decided 0. . 1 Unidentified. Person Female 0. . 1 *

2 b Gender Male Gender. Not. Decided 0. . 1 * Unidentified. Person Female

2 b Gender Male Gender. Not. Decided 0. . 1 * Unidentified. Person Female 0. . 1 * An unidentified person (an object of class Unidentified. Person) can not be male, female or have the gender not decided (see classes Male, Female, Gender. Not. Decided) at the same time, i. e. , only one of these options are possible at a time. Write an OCL constraint that ensures this. Context Unidentified. Person inv: (male->size() + gender. Not. Decided->size() + female->size()) = 1

model Crime. Scene class Crime attributes start. Time : Integer end class Stay attributes

model Crime. Scene class Crime attributes start. Time : Integer end class Stay attributes start. Time : Integer end class Location attributes id : Integer end class Location attributes been. On. Crime. Scene : Boolean end association crime. Location between Crime[0. . *] role crime Location[1] role crime. Scene end association stay. Location between Stay[0. . *] role stay Location[1] role stayed. At end association stay. Suspect between Stay[0. . *] role stay Suspect[1] role suspect end association crime. Suspect between Crime[] role crime Suspect[0. . *] role suspect end constraints context Stay inv : start. Time < end. Time 2 c * Crime start. Time : Integer end. Time : Integer 1 * Stay start. Time : Integer end. Time : Integer 1 * 1 Suspect been. On. Crime. Scene: Boolean * 1 stayed. At Location crimeid : Integer Scene Make an OCL constraint that ensures that the value of start. Time is less than the value of end. Time for objects of class Stay.

2 d * Crime start. Time : Integer end. Time : Integer Stay start.

2 d * Crime start. Time : Integer end. Time : Integer Stay start. Time : Integer end. Time : Integer 1 crime. Scene 1 * Suspect been. On. Crime. Scene : Boolean * 1 stayed. At Location id : Integer Make an OCL constraint that declares been. On. Crime. Scene 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.

context Suspect inv : been. On. Crime. Scene = stayed. At->includes(crime. Scene) Been on

context Suspect inv : been. On. Crime. Scene = stayed. At->includes(crime. Scene) Been on crime scene at time of crime (assuming on. Crime. Scene. When. Crime is attribute of class Suspect) – NOT ASKED FOR ON EXAM: context Suspect inv : on. Crime. Scene. When. Crime = stay->select(e | e. start. Time >= self. crime. start. Time and e. end. Time <= self. crime. end. Time). stayed. At->includes(crime. Scene)