C# Programming. I need to add more features as described in this document. In th
ID: 3831843 • Letter: C
Question
C# Programming.
I need to add more features as described in this document. In the menu, you need to add two new entries. One is called “Game”, which includes four items: Log in, Log out, Register, Stop game, and Exit. The other is called “Scores”, including two items: Your scores, and High scores.
1. When “Log in” is selected, a new Login form should pop up. The user can enter a username and password to log in. Otherwise, the game will not start.
2. When “Log out” is selected, the user’s session will end. The game should be disabled.
3. When “Register” is selected, a new Register form should pop up. The user can provide username and password to register. The user information should be saved into a SQL database.
4. After the user logs in, a new game can be started by clicking on pokemon. When the pokemon is clicked on, it will stop. Then, a quiz form will show up. A math question will be shown on the form. For this project, you can simply use addition. The two numbers are randomly generated. You need to answer the question and submit it. If the answer is correct, you earn 10 points. Otherwise, you lose 10 points. You need a class level variable to save the total score.
5. After the question is answered, the form should disappear. Then pokemon start running again. Every time you catch the pokemon, a new question will be shown. The goal is to answer as many questions as possible and get a high score.
6. When “Stop game” is selected, the game ends and your score will show in a messagebox. It should also be saved into the database. Then the score variable needs to be reset to 0 for the next game.
7. When “Your score” is selected, your history scores should be displayed along with the date of playing.
8. When “High scores” is selected, the top 3 highest scores in history of playing this game should be displayed.
9. When “Exit” is clicked, the program is shut down.
The original code is provided below:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Media;
namespace WindowsFormsApplication4
{
public partial class HW5 : Form
{
private string hDirection = "right";
private string vDirection = "down";
private Random rand = new Random();
public HW5()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.pictureBox1.BackgroundImage = Properties.Resources._5Pikachu;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (pictureBox1.Left + pictureBox1.Width >= this.Width)
hDirection = "left";
if (pictureBox1.Left <= 0)
hDirection = "right";
if (pictureBox1.Top + pictureBox1.Height >= this.Height)
vDirection = "up";
else if (pictureBox1.Top <= 0)
vDirection = "down";
if (hDirection == "left")
pictureBox1.Left -= 10+rand.Next(1,10);
if(hDirection == "right")
pictureBox1.Left += 10+rand.Next(1, 10);
if (vDirection == "down")
pictureBox1.Top += 10;
if (vDirection == "up")
pictureBox1.Top -= 10;
//pictureBox1.Top += 10;
}
private void pictureBox1_Click(object sender, EventArgs e)
{
if (!timer1.Enabled)
{
timer1.Interval -= 20;
timer1.Start();
}
else
{
timer1.Stop();
SoundPlayer sp = new SoundPlayer(Properties.Resources.pikachuaudio);
sp.PlaySync();
}
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show ("Instructions 1. Click the pikachu to begin. 2. When pikachu runs, try to catch it by clicking on it. 3. After you catch it, it'll stop. 4. Click pikachu again to release it, it'll run faster. 5. Repeat steps 1 through 4.");
}
}
}
Explanation / Answer
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Media;
namespace WindowsFormsApplication4
{
public partial class HW5 : Form
{
private string hDirection = "right";
private string vDirection = "down";
private Random rand = new Random();
public HW5()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
this.pictureBox1.BackgroundImage = Properties.Resources._5Pikachu;
}
private void timer1_Tick(object sender, EventArgs e)
{
if (pictureBox1.Left + pictureBox1.Width >= this.Width)
hDirection = "left";
if (pictureBox1.Left <= 0)
hDirection = "right";
if (pictureBox1.Top + pictureBox1.Height >= this.Height)
vDirection = "up";
else if (pictureBox1.Top <= 0)
vDirection = "down";
if (hDirection == "left")
pictureBox1.Left -= 10+rand.Next(1,10);
if(hDirection == "right")
pictureBox1.Left += 10+rand.Next(1, 10);
if (vDirection == "down")
pictureBox1.Top += 10;
if (vDirection == "up")
pictureBox1.Top -= 10;
//pictureBox1.Top += 10;
}
private void pictureBox1_Click(object sender, EventArgs e)
{
if (!timer1.Enabled)
{
timer1.Interval -= 20;
timer1.Start();
}
else
{
timer1.Stop();
SoundPlayer sp = new SoundPlayer(Properties.Resources.pikachuaudio);
sp.PlaySync();
}
}
private void button1_Click(object sender, EventArgs e)
{
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.