Monday, 27 August 2012

Magic 8 Ball Program


I learned how the program uses randomised answers for different questions. The program enables the user to enter a question, and recieve a random "yes" "no" or "maybe". When the "skake!" button is pressed, the program will produce a random answer. The interface has a textbox to enter a question, a "skake!" button, a label that will display the answer, as well as an "Exit" button.

Tuesday, 21 August 2012

Pseudo & Programming Code


Pseudo Code

On button “shake” click

Generate random number between 1-5

If the random number=1

Display “Not sure” in label answer



If random number=2

Display “Ok” in label “answer”



If random number=3

Display “Yes” in label “answer”



If random number=4

Display “No” in label “answer”



If random number=5

Display “Maybe” in label “answer”





Pseudo code is a description on the key aspects of the program. I have chosen to display the "Shake!" button properties (the "yes" "no" and "maybe" answers).





Program Code:

Public Class frmMagic

Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click

End

End Sub

Private Sub btnShake_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShake.Click

Dim intRandom As Integer

intRandom = Int(Rnd() * 3 + 1)

Select Case intRandom

Case "1"

lblAnswer.Text = "yea cunt"

Case "2"

lblAnswer.Text = "no"

Case "3"

lblAnswer.Text = "maybe"

Case Else

lblAnswer.Text = "ERROR"

End Select

End Sub

End Class

Monday, 20 August 2012

Magic 8 Ball layout Diagram and T.O.E Chart



My magic 8 ball layout diagram. The application enables the user to enter text and recieve a ramdomised answer. I chose this interface because it's easy to read.

The Magic 8 ball program has a very straight-forward approach in how it functions. The user clicks on the 'Shake!' button, and the program creates a randomised response.