Hi, Im new to these forums and i need help with this application.

Application Requirements
In this application you are to create a Three Shells Game. In this game there are three cups or shells
that are upturned. For each new game the pea is placed at random under one of the cups. The player
must select a cup. If the pea is under that cup then the player wins; if not, the player loses.
You are to design and build your version of this game. You will need to decide how you are going to
represent the cups and pea on your interface and how the player will select the cup with the pea. The
results of the selection (a win or loss) will also need to be displayed within the interface. Your
application will need to keep track of game statistics such as the number of games won, the number
of games lost, the longest winning streak (number of consecutive wins) and the longest losing streak
(number of consecutive losses). The logic associated with keeping track of streaks is provided in
Appendix A. These statistics only need to be kept for the current session, not for the lifetime of the
application. You are not permitted to program your game to cheat.
Although you can choose your own format and layout for your interface, there are a few compulsory
requirements.
1. You need to include buttons that provide access to “New Game”, “Instructions”, and “About
Me” (your details). You may include other buttons of your own choosing.
2. The player needs to be able to “see” where the pea was located if they selected the wrong
cup.
3. The interface needs to be well set out and usable.
4. You must create your application in Microsoft C# .Net 2005
5. You must use program documentation to explain your code (undocumented code will be sent
back to you for revision with penalties)
6. You must use good programming practices, i.e. meaningful names for controls and variables,
appropriate control structures, etc.
Optional extras you might like to consider are:
1. Different “shell” shapes or colours.
2. An extra guess if the first one was wrong.
3. For those who want to research on their own, sound or animation, menus, additional forms or
windows
Your application will need to generate random numbers to “position” the pea under one of the cups.
You will need to investigate how to use the random class to do this.

Appendix A:
Determining the logic behind the longest winning and losing streaks.
The following flowchart demonstrates one possible way of determining the longest winning and losing
streak. There are other possible methods and you are more than welcome to develop your own.
Alternatively you can convert this flowchart to C# code.
Assumptions
A number of assumptions need to be made about variables used in the flowchart. These are:
1. LongestWinStreak stores the number of games in the longest winning streak (initially zero).
2. LongestLossStreak stores the number of games in the longest losing streak (initially zero.
3. CurrentWinStreak stores the number of games in the current winning streak (initially zero.
4. CurrentLossStreak stores the number of games in the current losing streak (initially zero.
5. GameResult is a Boolean value indicating whether the player won (true) or lost (false).

START
CheckStreaks
GameResult
is true
CurrentLossStreak = 0
Increment
CurrentWinStreak
CurrentWinStreak
>
LongestWinStreak
LongestWinStreak =
CurrentWinStreak
STOP
CheckStreaks
CurrentWinStreak = 0
Increment
CurrentLossStreak
CurrentLossStreak
>
LongestLossStreak
LongestLossStreak =
CurrentLossStreak
No
No No
Yes
Yes Yes

This is my code so far... but it doesnt work

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace sit_102_assignment_2
{
    public partial class Form1 : Form
    {
        //Declaring a random object.
        Random RandomNumber = new Random();

        //Declaring an int which will hold the random number
        int x, counter = 0;

        public Form1()
        {
            InitializeComponent();
        }

        private void newGameButton_Click(object sender, EventArgs e)
        {
            shellOne.Visible = true;
            shellTwo.Visible = true;
            shellThree.Visible = true;

            x = RandomNumber.Next(1, 4);
        }

        private void shellThree_Click(object sender, EventArgs e)
        {
            if (x == 3)
            {
                textBox1.Text = "Good";
                counter++;
                x = RandomNumber.Next(1, 4);
            }
            else
            {
                textBox1.Text = "Bad";
            }
        }

        private void shellTwo_Click(object sender, EventArgs e)
        {
            if (x == 2)
            {
                textBox1.Text = "Good";
                counter++;
                x = RandomNumber.Next(1, 4);
            }
            else
            {
                textBox1.Text = "Bad";
            }

        }

        private void shellOne_Click(object sender, EventArgs e)
        {
            if (x == 1)
            {
                textBox1.Text = "Good";
                counter++;
                x = RandomNumber.Next(1, 4);
            }
            else
            {
                textBox1.Text = "Bad";
            }

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }
}

All i can see are the new game, instructions and about me buttons and the text box and they are so not useful.

Any help would be greatly appreciated.

Can you send your project to me. You can rar or zip it, and use the additional options under the reply message to attach the file.

I placed your code into a new project, and it works fine. I pressed the new buton to get the picture boxes to appear, and as each click would provide the answer, and reshuffle the pea.

I did make a small change to your code. I set the Tag property to 1,2 or 3 for each picturebox. Instead of having an event handler for each picturebox, I use one. here is the code:

public partial class Form1 : Form
    {

        private Random RandomNumber = new Random();
        private int x = 0;
        private int counter = 0;

        public Form1()
        {
            InitializeComponent();
        }

        private void btnNewGame_Click(object sender, EventArgs e)
        {
            shellOne.Visible = true;
            shellTwo.Visible = true;
            shellThree.Visible = true;
            x = RandomNumber.Next(1, 4);
        }

        private void onCupSelected(object sender, EventArgs e)
        {
            Button cup = (Button)sender;
            textBox1.Text = (x == (int)cup.Tag) ? "Good" : "Bad";
            counter++;
            if (x == (int)cup.Tag)
                x = RandomNumber.Next(1, 4);
        }
    }

// Jerry

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.