Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Error on all Input strings ( int y = Convert.ToInt 3 2 ( txtY . Text ) ; ) Code: C## namespace Assignment

Error on all Input strings ("int y = Convert.ToInt32(txtY.Text);")
Code: C##
namespace Assignment_3
{
public partial class Maze : Form
{
/*
* Northeast
*[0,1][0,1]
*[-1,0][0,0][1,0/] Southwest[-1,0][1,0]Northwest
*[0,-1][0,-1]
* Southeast
*/
public Maze()
{
InitializeComponent();
}
private void Maze_Load(object sender, EventArgs e)
{
txtOutput.Text = "You are in a room with an exit to the North, Northeast, Northwest, South, Southeast, Southwest, East, and West.";
txtX.Text ="0";
txtX.Text ="0";
}
private void btnNorth_Click(object sender, EventArgs e)
{
int x = Convert.ToInt32(txtX.Text);
int y = Convert.ToInt32(txtY.Text);
if (x ==0 && y ==0)
{
txtOutput.Text = "You are in a room with an exit to the South or Southeast.";
btnNorth.Enabled = false;
btnEast.Enabled = false;
btnSouth.Enabled = true;
btnWest.Enabled = false;
btnNortheast.Enabled = false;
btnSoutheast.Enabled = false;
btnNorthwest.Enabled = false;
btnSouthwest.Enabled = false;
//btnWest.Visible = false;
txtY.Text ="1";
}
else if (x ==0 && y ==-1)
{
txtOutput.Text = "You are in a room with an exit to the North, Northeast, Northwest, South, Southeast, Southwest, East, and West.";
btnNorth.Enabled = true;
btnEast.Enabled = true;
btnSouth.Enabled = true;
btnWest.Enabled = true;
btnNortheast.Enabled = true;
btnSoutheast.Enabled = true;
btnNorthwest.Enabled = true;
btnSouthwest.Enabled = true;
//btnWest.Visible = false;
txtY.Text ="0";
}
}
private void btnSouth_Click(object sender, EventArgs e)
{
int x = Convert.ToInt32(txtX.Text);
int y = Convert.ToInt32(txtY.Text);
if (x ==0 && y ==0)
{
txtOutput.Text = "You are in a room with an exit to the North or Northeast.";
btnNorth.Enabled = true;
btnEast.Enabled = false;
btnSouth.Enabled = false;
btnWest.Enabled = false;
btnNortheast.Enabled = false;
btnSoutheast.Enabled = false;
btnNorthwest.Enabled = false;
btnSouthwest.Enabled = false;
txtY.Text ="-1";
}
else if (x ==0 && y ==1)
{
txtOutput.Text = "You are in a room with an exit to the North, Northeast, Northwest, South, Southeast, Southwest, East, and West.";
btnNorth.Enabled = true;
btnEast.Enabled = true;
btnSouth.Enabled = true;
btnWest.Enabled = true;
btnNortheast.Enabled = true;
btnSoutheast.Enabled = true;
btnNorthwest.Enabled = true;
btnSouthwest.Enabled = true;
txtY.Text ="0";
}
}
private void btnEast_Click(object sender, EventArgs e)
{
int x = Convert.ToInt32(txtX.Text);
int y = Convert.ToInt32(txtY.Text);
if (x ==0 && y ==0)
{
txtOutput.Text = "You are in a room with a lever in it and an exit to the West or Southwest.";
btnNorth.Enabled = false;
btnEast.Enabled = false;
btnSouth.Enabled = false;
btnWest.Enabled = true;
btnNortheast.Enabled = false;
btnSoutheast.Enabled = false;
btnNorthwest.Enabled = false;
btnSouthwest.Enabled = false;
btnAction.Visible = true;
btnAction.Text = "Pull Lever?";
txtX.Text ="1";
}
else if (x ==-1 && y ==0)
{
txtOutput.Text = "You are in a room with an exit to the North, Northeast, Northwest, South, Southeast, Southwest, East, and West.";
btnNorth.Enabled = true;
btnEast.Enabled = true;
btnSouth.Enabled = true;
btnWest.Enabled = true;
btnNortheast.Enabled = true;
btnSoutheast.Enabled = true;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions