Okay, here's what the game is all about
:
Long before personal computers, there was a company called E.S.R., Inc. that satisfied my desire to possess a computing device. They had three offerings: DR. NIM, DIGI-COMP I, and THINK-A-DOT. I owned them all, but my personal favorite was THINK-A-DOT. At the time it cost a mere $2.95, which was well within my monthly allowance. I recently saw one selling on eBay for $120. Since I no longer own my original machine, and cannot afford to replace it, I would like you to build me a virtual THINK-A-DOT in Visual Basic.
As originally constructed, a marble could be dropped into one of three holes in the top of the machine. It would then percolate through the machine and come out a hole on the bottom left or right. This was to allow for two-person competition, and really was of no interest to me. As the marble percolated through the machine it caused any dot it passed to change color from yellow to blue, and from blue to yellow. The color of the dot also controlled whether the marble would fall to the left (yellow) or to the right (blue). This meant there were ten possible paths through the machine from top to bottom, flipping either two or three dots to their alternate colors along the way. The initial pattern could be reset at any time by tilting the machine to the left or right.
ThinkaDot.exe provides a working example, if the following explanation is hard to understand. For your virtual machine, you will need some way to reset all the dots to yellow, some way to indicate the initial starting point of a virtual marble (left, middle, or right), and some way to represent the eight dots and change their color from yellow to blue or from blue to yellow. The logic is such that after changing a dot from yellow to blue, the next dot to be reversed is down and to the left. For a blue dot changing to yellow, the next dot to be reversed is down and to the right. A virtual marble dropping down the far left or far right side will only reverse two dots and not three. The folder, ThinkaDot, contains the start of a solution. It provides a picture of the machine, and a flipper control that can be dragged onto the picture just like any other control. The flipper control has a Boolean property, droppedLeft, that tells you the direction the ball fell; and two methods: flip that reverses the control, and reset.
A useful property of Think-a-Dot that can be used for testing, is that a marble dropped into any one of the three holes at the top, eight times in a row, will return the machine to the original pattern. Also, dropping a marble into each of the holes twice will return the machine to the original pattern.
(I can't upload the .exe file, it's not one of the acceptable uploads...)
There are two window forms... one called Flipper.vb and one called ThinkADot.vb
Here's the code from the ThinkADot.vb form
Code:
'Program: ThinkaDot 3
'Programmer: Glenn Cummings
'Date: 15 May 2006
'Description: This project creates a virtual Think-a-Dot machine. In the original
' machine, eight windows would alternately display a yellow dot or a
' blue dot each time a marble passed through its underlying flipper.
' The placement of these flippers looked like this:
'
' flipper1 flipper2 flipper3
'
'
' flipper4 flipper5
'
'
' flipper6 flipper7 flipper8
'
' If the dot had been yellow, the marble would drop down and to the left;
' if the dot had been blue, the marble would drop down and to the right.
' Each time a marble dropped, two or three flippers would change color.
'
Public Class ThinkADot
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(ThinkADot))
Me.SuspendLayout()
'
'ThinkADot
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackgroundImage = CType(resources.GetObject("$this.BackgroundImage"), System.Drawing.Image)
Me.ClientSize = New System.Drawing.Size(544, 438)
Me.MaximizeBox = False
Me.Name = "ThinkADot"
Me.Text = "ThinkADot"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub ThinkADot_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
End Class
Here's the code for the Flipper.vb form.
Code:
Public Class Flipper
Inherits System.Windows.Forms.UserControl
Private droppedLeftBoolean As Boolean = True
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'UserControl overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents ImageList1 As System.Windows.Forms.ImageList
Friend WithEvents Dot As System.Windows.Forms.Label
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Flipper))
Me.ImageList1 = New System.Windows.Forms.ImageList(Me.components)
Me.Dot = New System.Windows.Forms.Label
Me.SuspendLayout()
'
'ImageList1
'
Me.ImageList1.ImageStream = CType(resources.GetObject("ImageList1.ImageStream"), System.Windows.Forms.ImageListStreamer)
Me.ImageList1.TransparentColor = System.Drawing.Color.Transparent
Me.ImageList1.Images.SetKeyName(0, "")
Me.ImageList1.Images.SetKeyName(1, "")
'
'Dot
'
Me.Dot.BackColor = System.Drawing.Color.White
Me.Dot.ImageIndex = 0
Me.Dot.ImageList = Me.ImageList1
Me.Dot.Location = New System.Drawing.Point(0, 0)
Me.Dot.Name = "Dot"
Me.Dot.Size = New System.Drawing.Size(34, 34)
Me.Dot.TabIndex = 0
'
'Flipper
'
Me.Controls.Add(Me.Dot)
Me.Name = "Flipper"
Me.Size = New System.Drawing.Size(34, 34)
Me.ResumeLayout(False)
End Sub
#End Region
ReadOnly Property droppedLeft() As Boolean
Get
Return droppedLeftBoolean 'do flip before reading
End Get
End Property
Public Sub flip()
droppedLeftBoolean = Not droppedLeftBoolean
Dot.ImageIndex = 1 - Dot.ImageIndex 'alternate dot color
End Sub
Public Sub reset()
Dot.ImageIndex = 0 'reset image to yellow dot
droppedLeftBoolean = True 'default direction
End Sub
Private Sub Dot_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Dot.Click
End Sub
End Class
Now what I'm supposed to do is finish the coding for this, but I don't even know how to do that!!!! I'm so confused with this game or with the coding, and I've told this to the teacher numerous times and he doesn't seem to care!! *sighs*
Dudeking, ANY suggestions on this would be HIGHLY appreciated!!!!
Also I attached what the finish results should look like from the ThinkADot.exe file that the teacher had provided.