KARTHIK RAJ A/L SELVARAJ

U0844409

d. VDM for Lift, Room, Building and Stairway
i. User
User
+ Name: String - Weight: Integer + getName(): String + getWeight(): Integer

State User of Name  Alphanumeric Weight  Natural end

Function getName () a: Alphanumeric ext rd a  Alphanumeric pre TRUE post name = a end getWeight () b: Natural ext rd b  Natural pre TRUE post Weight = b end

FORMAL METHODS IN SOFTWARE ENGINEERING

Page 7

Control Panel Control Panel + + + + + + Level: Integer Weighing: Double Alarm: Boolean getLevel(): Integer getWeighing(): Double setAlarm(Boolean): void State Control Panel of Level  Natural Weighing  Double Alarm  Boolean end Function getLevel() c: Natural ext rd c  Natural pre TRUE post Level = c end getWeighing() d: Real ext rd d  Real pre TRUE post Weighing = d end setAlarm() e: Boolean ext wr e  Boolean pre Weighing >= 600 post alarm = TRUE end FORMAL METHODS IN SOFTWARE ENGINEERING Page 8 .KARTHIK RAJ A/L SELVARAJ U0844409 ii.

Load: Double + Level: Integer .Timer: Double + moveUp(): Boolean + moveDown(): Boolean + stop(): Boolean + getLoad(): Integer + getLevel(): Integer + openDoor(): Boolean + closeDoor(): Boolean State Lift of Load  Real Level  Natural Timer  Real end Function moveUp() ext rd Level: Real pre Level >= 1  Level <=5 post Level = Level + 1 end moveDown() ext rd Level: Real pre Level >= 1  Level <= 5 post Level = Level – 1 end stop() actualLevel: Natural ext rd Level: Natural pre Level >= 1  Level <= 5 post actualLevel = Level end FORMAL METHODS IN SOFTWARE ENGINEERING Page 9 .KARTHIK RAJ A/L SELVARAJ U0844409 iii. Lift Lift .

KARTHIK RAJ A/L SELVARAJ U0844409 getLoad() currentLoad: Real ext rd  Real pre TRUE post currentLoad = Load end getLevel() f: Real ext rd Real pre TRUE post Level = f end openDoor() currentLevel: Real ext rd  Real pre currentLevel = Level post currentLevel = TRUE end closeDoor() currentTimer: Real ext rd  Real pre Timer > 0  Timer <15 post currentTimer = TRUE end FORMAL METHODS IN SOFTWARE ENGINEERING Page 10 .

Stairway Stairway .Step: Integer + getHeight(): Double + getWidth(): Double + getNo.Width: Double .Steps  Natural end Function getHeight g: Real ext rd g  Real pre TRUE post g = Height end getWidth h: Real ext rd h  Real pre TRUE post h = Width end getNo.Height: Double .Step k: Natural ext rd k  Natural pre TRUE post k = No.No.Step(): Integer State Stairway of Height  Real Width  Real No.Step end FORMAL METHODS IN SOFTWARE ENGINEERING Page 11 .KARTHIK RAJ A/L SELVARAJ U0844409 iv.

Level5 end countRoom() ext rd Room: Natural pre Room > 1  Room < 37 post totalRoom = Room1 +…+…Room37 end FORMAL METHODS IN SOFTWARE ENGINEERING Page 12 . Floor Floor + Level: Integer + Room: Integer #countLevel() #countRoom() State Floor of Level  Natural Room  Natural End Function countLevel() ext rd Level: Natural pre Level > 1  Level <5 post totalLevel = Level1 +…+….KARTHIK RAJ A/L SELVARAJ U0844409 v.

Table: Integer . Chairs  Natural Name  Alphanumeric end Function countUser() m: Natural ext rd m  Natural pre TRUE post m = User1 +…+…Usern end countRoom() n: Natural ext rd n  Natural pre Room > 1  Room < 37 post n = Room1 +…+…Room37 end FORMAL METHODS IN SOFTWARE ENGINEERING Page 13 .User: Integer .No.No. Room Room . Table  Natural No.KARTHIK RAJ A/L SELVARAJ U0844409 vi. Chairs: Integer .Name: String # countUser() # countRoom() State Room of User  Natural No.

FTMS Building Building + + + + User: Integer Lift: Integer Room: String Stairway: Integer # countUser() # countLift() # countRoom() # countStairway() State FTMS Building of User  Natural Lift  Natural Room  Alphanumeric Stairway  Natural end Function countUser() o: Real ext rd o  Real pre TRUE post o = User1 +…+…Usern end countLift() p: Real ext rd p  Real pre TRUE post p = Lift1 + Lift2 end FORMAL METHODS IN SOFTWARE ENGINEERING Page 14 .KARTHIK RAJ A/L SELVARAJ U0844409 vii.

KARTHIK RAJ A/L SELVARAJ U0844409 countRoom() q: Real ext rd q  Real pre Room > 1  Room < 37 post q = Room1 +…+…Room37 end countStairway() r: Real ext rd r  Real pre TRUE post r = Stairway1 +…+…Stairwayn end FORMAL METHODS IN SOFTWARE ENGINEERING Page 15 .

Sign up to vote on this title
UsefulNot useful