Assignment - [03/02/11]
I used VISUAL BASIC 6.0 for the program.
1) Programming Readiability
--> Identifiers are used to name variables.
The identifiers that I used are: inNum1,intNum2,intNum3,txtBet,txtReset so that they are easy to determine.
--> Logic Structure
The logic structure that I used for coding this program is simple.
--> Coding Practice It should be written in the code that will do what is needed.
Sometimes it takes some errors when you code your program and it will debug when you run it. That's why you must understand your program well when you are coding.
--> Notes & Comments used to embed programmer-readable annotations in the source code of a computer program. Comments are usually added with the purpose of making the source code easier to understand.
2) Program Documentation
--> Program Listing a literal listing of all or part of a program. Used keyword and proper naming convention.
lblBet,lblWin,lblMessage
--> Program Specification the keyword is the requirements. You may type numbers on the text box and click the bet for the result.
--> File Layout & Record Description it should written the kinds of files used and explains details with they contains.
That program is an slotmachine, that contain numbers and you may get your bet when you play it.
--> Operating Instruction contains the actual instructions of the program. The list of possible errors and tells the user what to do.
There are some possible errors, it can be on the identifiers that you used. You must look or check carefully the identifiers that you used so that it may not cause of debugging your program.
Here is the Code of the Program
Private Sub cmdPlay_Click()
Dim intNum1 As Integer, intNum2 As Integer, intNum3 As Integer
Dim dblBet As Double, dblWin As Double
intNum1 = Rnd * 9
intNum2 = Rnd * 9
intNum3 = Rnd * 9
lblNumber.Caption = intNum1
lblNumber1.Caption = intNum2
lblNumber2.Caption = intNum3
If intNum1 = intNum2 And intNum1 = intNum3 Then
dblBet = txtBet.Text
dblWin = dblBet * 3
lblMessage.Caption = "You Won" & "P" & Format(dblWin, "standard")
Else
lblMessage.Caption = "Sorry, try your luck next time!!"
End If
End Sub
Private Sub cmdReset_Click()
lblNumber.Caption = ""
lblNumber1.Caption = ""
lblNumber2.Caption = ""
txtBet.Text = ""
End Sub
No comments:
Post a Comment