Project 2 – Memory Match Game
Purpose
This Windows Classic Desktop application plays a simple matching
game. The game simulates a card game where the cards a placed face
down and the player flips over pairs of cards in an attempt to find
matching cards.
Program Procedure
Display a 4x4 grid of “face down” cards. Assign the letters A
through H randomly to the cards in pairs. Allow the user to click
on a card to “flip” it over and display the number. The player can
then “flip” a second card to see if they match. If the cards match,
they are removed from the grid (hidden) and the player scores some
points. If they do not match the player can click on them to flip
them back over and start another turn. Once all of the cards have
been matched the game is over.
Requirements
1. Start of game displays 4x4 grid and assigns hidden letters (in
pairs) to each of the cards and sets the initial score to 0. 2.
User clicks on a card to flip it over and reveal its letter. 3.
User then clicks on a second card to flip it over and reveal its
letter. 4. If the cards match clicking a second time on either of
the cards will earn the player some points and remove
(hide/disable) the matched cards from the grid 5. If they do not
match clicking on either of the flipped cards will turn both cards
back over to hide their letters. 6. Each card starts out with a
point value of 20 7. Each time a card is flipped and is not part of
a match its point value is reduced by 5 8. The points scored for a
match are based on the sum of the point values of the matching
cards 9. Display a list of matched cards and the points earned for
each match and the total points for the game.
Notes and Restrictions
1. Minimum points for any card is -5
Comments
The player can start a new game at any time. Current scores will be
discarded and a new face down grid displayed.
Deduct the 5 points from the cards when they are flipped back
(requirement 5)
I have tried it but I can only get the buttons to show the letters and nothing else can someone help me, my code is:
Dim strBoxContent(15) As String
Dim letters() As String = {"A", "B", "C", "D", "E", "F", "G", "H", "A", "B", "C", "D", "E", "F", "G", "H"}
Dim Button(15) As Button
Dim rnd = New System.Random
Dim intPrevious As Integer
Dim intCurrent As Integer
Dim btnIsDisplayed(15) As Boolean
Dim intTotal As Integer
Dim currentPoints As Integer
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Button(0) = Button0
Button(1) = Button1
Button(2) = Button2
Button(3) = Button3
Button(4) = Button4
Button(5) = Button5
Button(6) = Button6
Button(7) = Button7
Button(8) = Button8
Button(9) = Button9
Button(10) = Button10
Button(11) = Button11
Button(12) = Button12
Button(13) = Button13
Button(14) = Button14
Button(15) = Button15
PopulateButtons()
End Sub
Sub ButtonClicks(i As Integer, s As Button)
Dim holder As Integer = i
Dim btn1 As Button = New Button
Dim btn2 As Button = New Button
Dim c As Integer
If i.Equals(intPrevious) = True OrElse i.Equals(intCurrent) = True Then
If btn1.Text = btn2.Text Then
Button(intPrevious).Visible = False
Button(intCurrent).Visible = False
Button(intPrevious).Text = ""
Button(intCurrent).Text = ""
intPrevious = -1
intCurrent = 0
intTotal = intTotal + currentPoints
LabelTotal.Text = "Score: " & intTotal
Else
Button(intPrevious).Text = ""
Button(intCurrent).Text = ""
'(intCurrent) = False
'btnIsDisplayed(intPrevious) = False
If currentPoints <> -5 Then
currentPoints = currentPoints - 5
End If
intTotal = intTotal + currentPoints
LabelTotal.Text = "Score: " & intTotal
End If
ElseIf c = 1 Then
If intPrevious = holder Then
MsgBox("Fuck")
Exit Sub
Else
intCurrent = holder
'btnIsDisplayed(intCurrent) = True
s.Text = s.Tag
btn2 = s
End If
Else
intPrevious = holder
'btnIsDisplayed(intPrevious) = True
s.Text = s.Tag
c = 1
btn1 = s
End If
GameOver()
End Sub
Private Sub ButtonNG_Click(sender As Object, e As EventArgs) Handles ButtonNG.Click
PopulateButtons()
End Sub
Sub PopulateButtons()
Dim i As Integer
Dim c As Integer = 0
For i = 0 To 15
Button(i).Tag = ""
Button(i).Text = ""
btnIsDisplayed(i) = False
Next
While c < 16
i = rnd.Next(16)
If Button(i).Tag = "" Then
Button(i).Tag = letters(c)
c += 1
End If
End While
currentPoints = 20
intPrevious = -1
intCurrent = -1
intTotal = 0
LabelTotal.Text = "Score: " & intTotal
End Sub
Sub GameOver()
Dim i As Integer
Dim Check As Integer = 0
For i = 0 To 15
If Button(i).Visible = False Then
Check = Check + 1
End If
Next
If Check = 16 Then
MsgBox("Game Over!")
End If
End Sub
Private Sub Button0_Click(sender As Object, e As EventArgs) Handles Button0.Click
ButtonClicks(0, Button0)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ButtonClicks(1, Button1)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
ButtonClicks(2, Button2)
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
ButtonClicks(3, Button3)
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
ButtonClicks(4, Button4)
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
ButtonClicks(5, Button5)
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
ButtonClicks(6, Button6)
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
ButtonClicks(7, Button7)
End Sub
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
ButtonClicks(8, Button8)
End Sub
Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
ButtonClicks(9, Button9)
End Sub
Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
ButtonClicks(10, Button10)
End Sub
Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
ButtonClicks(11, Button11)
End Sub
Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
ButtonClicks(12, Button12)
End Sub
Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
ButtonClicks(13, Button13)
End Sub
Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
ButtonClicks(14, Button14)
End Sub
Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
ButtonClicks(15, Button15)
End Sub
End Class
Dim strBoxContent(15) As String
Dim letters() As String = {"A", "B", "C", "D", "E", "F", "G", "H", "A", "B", "C", "D", "E", "F", "G", "H"}
Dim Button(15) As Button
Dim rnd = New System.Random
Dim intPrevious As Integer
Dim intCurrent As Integer
Dim btnIsDisplayed(15) As Boolean
Dim intTotal As Integer
Dim currentPoints As Integer
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Button(0) = Button0
Button(1) = Button1
Button(2) = Button2
Button(3) = Button3
Button(4) = Button4
Button(5) = Button5
Button(6) = Button6
Button(7) = Button7
Button(8) = Button8
Button(9) = Button9
Button(10) = Button10
Button(11) = Button11
Button(12) = Button12
Button(13) = Button13
Button(14) = Button14
Button(15) = Button15
PopulateButtons()
End Sub
Sub ButtonClicks(i As Integer, s As Button)
Dim holder As Integer = i
Dim btn1 As Button = New Button
Dim btn2 As Button = New Button
Dim c As Integer
If i.Equals(intPrevious) = True OrElse i.Equals(intCurrent) = True Then
If btn1.Text = btn2.Text Then
Button(intPrevious).Visible = False
Button(intCurrent).Visible = False
Button(intPrevious).Text = ""
Button(intCurrent).Text = ""
intPrevious = -1
intCurrent = 0
intTotal = intTotal + currentPoints
LabelTotal.Text = "Score: " & intTotal
Else
Button(intPrevious).Text = ""
Button(intCurrent).Text = ""
'(intCurrent) = False
'btnIsDisplayed(intPrevious) = False
If currentPoints <> -5 Then
currentPoints = currentPoints - 5
End If
intTotal = intTotal + currentPoints
LabelTotal.Text = "Score: " & intTotal
End If
ElseIf c = 1 Then
If intPrevious = holder Then
MsgBox("Fuck")
Exit Sub
Else
intCurrent = holder
'btnIsDisplayed(intCurrent) = True
s.Text = s.Tag
btn2 = s
End If
Else
intPrevious = holder
'btnIsDisplayed(intPrevious) = True
s.Text = s.Tag
c = 1
btn1 = s
End If
GameOver()
End Sub
Private Sub ButtonNG_Click(sender As Object, e As EventArgs) Handles ButtonNG.Click
PopulateButtons()
End Sub
Sub PopulateButtons()
Dim i As Integer
Dim c As Integer = 0
For i = 0 To 15
Button(i).Tag = ""
Button(i).Text = ""
btnIsDisplayed(i) = False
Next
While c < 16
i = rnd.Next(16)
If Button(i).Tag = "" Then
Button(i).Tag = letters(c)
c += 1
End If
End While
currentPoints = 20
intPrevious = -1
intCurrent = -1
intTotal = 0
LabelTotal.Text = "Score: " & intTotal
End Sub
Sub GameOver()
Dim i As Integer
Dim Check As Integer = 0
For i = 0 To 15
If Button(i).Visible = False Then
Check = Check + 1
End If
Next
If Check = 16 Then
MsgBox("Game Over!")
End If
End Sub
Private Sub Button0_Click(sender As Object, e As EventArgs) Handles Button0.Click
ButtonClicks(0, Button0)
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
ButtonClicks(1, Button1)
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
ButtonClicks(2, Button2)
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
ButtonClicks(3, Button3)
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
ButtonClicks(4, Button4)
End Sub
Private Sub Button5_Click(sender As Object, e As EventArgs) Handles Button5.Click
ButtonClicks(5, Button5)
End Sub
Private Sub Button6_Click(sender As Object, e As EventArgs) Handles Button6.Click
ButtonClicks(6, Button6)
End Sub
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
ButtonClicks(7, Button7)
End Sub
Private Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click
ButtonClicks(8, Button8)
End Sub
Private Sub Button9_Click(sender As Object, e As EventArgs) Handles Button9.Click
ButtonClicks(9, Button9)
End Sub
Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
ButtonClicks(10, Button10)
End Sub
Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
ButtonClicks(11, Button11)
End Sub
Private Sub Button12_Click(sender As Object, e As EventArgs) Handles Button12.Click
ButtonClicks(12, Button12)
End Sub
Private Sub Button13_Click(sender As Object, e As EventArgs) Handles Button13.Click
ButtonClicks(13, Button13)
End Sub
Private Sub Button14_Click(sender As Object, e As EventArgs) Handles Button14.Click
ButtonClicks(14, Button14)
End Sub
Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
ButtonClicks(15, Button15)
End Sub
End Class
We need at least 10 more requests to produce the answer.
0 / 10 have requested this problem solution
The more requests, the faster the answer.
Project 2 – Memory Match Game Purpose This Windows Classic Desktop application plays a simple matching game. The game si...
I am new to programming (2 weeks of playing with it) I have written code for a timer in Visual Studio 2013. I am wondering if someone can show me how to write code/what the code would look like in a MODULE1.vb. I was thinking that for this timer I could create MsgBox using a DO UNTIL LOOP that would pop up every 20 seconds that says "hurry up!" until 1 minute has passed. As I said I am just...
I’m attempting to create the functioning GUI (bottom photo) from the coding in the first photo. I’m unclear as to what I’m missing to complete the code. Thank you a Homework 8 similar to Exercise 16 8.pdf (page 1 of 2) Public Class Formi Dim answer As Integer Sub Random() Dim random As New Random() answer randon.Next (1, 1ee) End Sub Private Sub Formi Load(ByVal sender As System.Object, Byval e As System. EventArgs) Handles MyBase. Load Random() End Sub Private...
I need help with this problem in Visual Basic 2012: Write a program that allows the user to specify two numbers and then adds, subtracts, multiplies, or divides them when the user clicks on the appropriate button. The output should give the type of arithmetic performed and the result. Whenever one of the numbers in an input text box is changed, the output text box should be cleared. Also, if the number 0 is entered into the second text box,...
Any way to add a counter?, to count the elements/ # of prime factors outputted to TextBox2.Text. VB Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.click Dim n As Long Dim i As Long Dim k As Long Dim Prime As Boolean n = TextBox1.Text For i = 2 To n If n Mod i = 0 Then k = 2 Prime = False While k <i / 2 If i Mod k = 0...
WITH THIS CODE, ADD TO THE EXIT BUTTON THAT ALLOWS THE USER TO SEE UPON EXITING, HOW MANY QUESTIONS THEY GOT RIGHT AND WRONG. Public Class Form1 Dim r As Random = New Random Dim no1, no2 As Integer Private Sub rdbAdd_CheckedChanged(sender As Object, e As EventArgs) Handles rdbAdd.CheckedChanged txtAnswer.Clear() txtAnswer.BackColor = Color.White no1 = randomInt() no2 = randomInt() lblOperation.Text = "+" txtNumber1.Text = no1.ToString() txtNumber2.Text = no2.ToString() End Sub Public Function randomInt() As Integer Return r.Next(20, 120) End Function...
Program using visual basic.net You will create a very simple two numbers calculator with save options; here is the specifications for the application. Create a form divided vertically in two halves with right and left panels 1- In the left panel you will create the following control, the label or the value of the control will be in "" and the type of the control will in [] a- "First Number" [textbox] b- "Second number" [texbox] c- "Result" [textbox] -...
Visual Basic: Create an application that simulates a tic tac toe game. The form uses 9 large labels to display the x's and o's. The application should use a two dimensional integer array to simulate the game board in memory. When the user clicks the "New Game" button the application should step throguh the array storing a random number of 0 to 1 in each element. The numer 0 represent the letter o and the number 1 reprsents the letter...
so im trying to make a grade program and idk what im doing wrong actually if someone can help? (heres the lines of code i have so far if its wrong let me know how to fix them Option Strict On Option Explicit On Public Class Form1 Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click Dim lblscore1 As Double Dim lblscore2 As Double Dim lblscore3 As Double lblscore1 = CDbl(Txtscore1.Text) lblscore2 = CDbl(Txtscore2.Text) lblscore3 = CDbl(Txtscore3.Text) lblaverage =...
Public Class Form1 Private Sub CompleteReport_Click(sender As Object, e As EventArgs) Handles CompleteReport.Click Dim room As Double 'Assigns room as double Dim rate As Double 'Assigns rate as double Dim room2 As Double 'Assigns room as double Dim overallRate As Double 'Assigns overall as double Dim a As Integer 'Assign a as an integer For a = 1 To 8 'Assign a as an 1 to 8 for all 8 floors With...
C# Windows Form Application (CALCULATOR): (This is the instruction below): Windows Calculator that will going to create a Windows Form Application that will mimics a calculator. This is the screenshot how it shouldl look like. Calculator It should have a textbox and the following buttons: + Addition - Subtraction * Multiplication / Division = Equals (Will perform the final calculation) C Clear (Will clear the text box) There will be no maximize or minimize buttons. The rules are these: 2...