Presentation is loading. Please wait.

Presentation is loading. Please wait.

Mark Dixon, SoCCE SOFT 131Page 1 03 – Debugging & Graphics.

Similar presentations


Presentation on theme: "Mark Dixon, SoCCE SOFT 131Page 1 03 – Debugging & Graphics."— Presentation transcript:

1 Mark Dixon, SoCCE SOFT 131Page 1 03 – Debugging & Graphics

2 Mark Dixon, SoCCE SOFT 131Page 2 Session Aims & Objectives Aims –tidy up from last session –introduce you to testing and debugging process –introduce you to graphics Objectives, by end of this week’s sessions, you should be able to: –Test program –Identify and correct simple logical and syntax errors –put bitmap (raster) graphics into you applications –draw simple vector graphics

3 Mark Dixon, SoCCE SOFT 131Page 3 Example 2-6: Address Book

4 Mark Dixon, SoCCE SOFT 131Page 4 Testing & Debugging: Errors 3 error types : –syntax: computer unable to understand your instructions (program does not execute), e.g. variable not defined (probably most common) –run-time: program can't execute instruction and exits (future lecture) device not available –logical: program executes but does not not match specification (do what was intended), e.g. clicking on button does nothing, when you thought you attached code to it clicking on blue button changes colour to red (when it should change to blue) Music Player

5 Mark Dixon, SoCCE SOFT 131Page 5 Computer –just symbol matching –No intelligence Example 1: Hello Errors Sub Command1_Cluck LabelL.Caption = "Hello" End Sub L instead of 1: causes syntax error (variable not defined) u instead of i: causes logical error (Command1 button does nothing)

6 Mark Dixon, SoCCE SOFT 131Page 6 Exercise 1: Errors The following is from exercise 1 (v1), –Spot the errors (you should find 6), and –decide whether they are syntax or logical Private Sub btnBlue_Cluck() lblResult.BackColor = vbRed End Sub Private Sub btnRed_lick() lblResult.BackColor vbRed End Sub Private Sub lb1Result_DblClick() lblResult.BackColour = vbWhite End Sub

7 Mark Dixon, SoCCE SOFT 131Page 7 Verification & Validation Verification: –'Are we building the product right?' –Does software match software requirements specification? Validation: –'Are we building the right product?' –Does the software requirements specification meet the user requirements?

8 Mark Dixon, SoCCE SOFT 131Page 8 Debugging: Testing Functional Decomposition –break it into logical chunks Incremental Development –type a bit –test it Testing –test all/most combinations Regression Testing –repeat all previous tests

9 Mark Dixon, SoCCE SOFT 131Page 9 Types of Graphics: Raster Raster graphics – made of dots (pixels – picture elements) –suitable for complex, static pictures (e.g. photos) –difficult to change programmatically –loses quality when enlarged

10 Mark Dixon, SoCCE SOFT 131Page 10 Types of Graphics: Vector Vector graphics – made of objects (lines, circles, etc.) –suitable for simple, dynamic pictures (diagrams) –No loss of quality when enlarged

11 Mark Dixon, SoCCE SOFT 131Page 11 Picture Control Methods (vector graphics) –Line: draws a straight line between 2 points –Circle: draws a circle –PSet: draws a dot (point) –Cls: clears (screen) drawing area Properties –Picture: allows display of bitmap (raster graphic) as background

12 Mark Dixon, SoCCE SOFT 131Page 12 Graphics: Grid System the origin (position 0,0) is at top left –in mathematics it is always bottom left

13 Mark Dixon, SoCCE SOFT 131Page 13 Example 2: Shapes Form and Picture Box control support graphics methods: 0 20001000 0 picDisplayArea.Line (500, 200)-(1900, 800) picDisplayArea.Line -(2600, 600) picDisplayArea.Line -Step(-600, -400) picDisplayArea.PSet (1500, 1000) picDisplayArea.Circle (700, 900), 300 Shapes

14 Mark Dixon, SoCCE SOFT 131Page 14 Example 3: StickMan Enabled property (true or false) StickMan

15 Mark Dixon, SoCCE SOFT 131Page 15 Example 4: Face Face

16 Mark Dixon, SoCCE SOFT 131Page 16 Example 5: Picture Viewer –LoadPicture function: picDisplay.Picture = LoadPicture("C:\Cat.jpg") –Pattern property (of file list)

17 Mark Dixon, SoCCE SOFT 131Page 17 Example 6: Music Player v3 V3 Option Explicit Private Sub drvMain_Change() dirMain.Path = drvMain.Drive End Sub Private Sub dirMain_Change() filMain.Path = dirMain.Path End Sub Private Sub filMain_Click() mmcMain.Command = "Close" mmcMain.FileName = filMain.Path & "\" & filMain.FileName mmcMain.Command = "Open" pgbMain.Max = mmcMain.Length pgbMain.Value = 0 End Sub Private Sub mmcMain_StatusUpdate() pgbMain.Value = mmcMain.Position End Sub Private Sub mmcMain_Done(NotifyCode As Integer) filMain.ListIndex = filMain.ListIndex + 1 mmcMain.Command = "Play" End Sub


Download ppt "Mark Dixon, SoCCE SOFT 131Page 1 03 – Debugging & Graphics."

Similar presentations


Ads by Google