Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i need help solving the error coding below, i use programing language c# please provide steps of how you fixed these problems, showed how you

i need help solving the error coding below, i use programing language c# please provide steps of how you fixed these problems, showed how you fixed them, and making sure the code runs fine thank you, heres the error below

image

heres my original code

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace Lab4
{
   internal static class Program
   {
       ///


       /// The main entry point for the application.
       ///

       [STAThread]
       static void Main()
       {
           Application.EnableVisualStyles();
           Application.SetCompatibleTextRenderingDefault(false);
           Application.Run(new Form1());
       }
   }
}

public class Labourer
{  
   private static int labourerCount = 0;
 
   public Labourer()
   {
       labourerCount++;
   }

   public int WorkerCount
   {
       get
       {
           return labourerCount;
       }
   }
 
   public void Speak()
   {
       
       MyTextBox.Text += "mumble mumble" + Environment.NewLine;
   }

   public void Move()
   {
   
       MyTextBox.Text += "location changed" + Environment.NewLine;
   }
}

public class Apprentice : Labourer
{
   // Static field to record how many apprentices have been created
   private static int apprenticeCount = 0;

   // Protected field for the worker name
   protected string workerName;

   // Property to display the apprentice count
   public int ApprenticeCount
   {
       get
       {
           return apprenticeCount;
       }
   }

   // Read-only property to return the worker name
   public string Name
   {
       get
       {
           return workerName;
       }
   }

   // Constructor to take in a name string and set the name backing field
   public Apprentice(string name)
   {
       workerName = name;

       // Increment the apprentice counter
       apprenticeCount++;
   }
}

public class Journeyman : Apprentice
{
   // Constructor to take in a name string and pass it to the base class
   public Journeyman(string name) : base(name)
   {
   }

   // Method to output ' fixes all the mistakes with their magic hammer'
   public void FixItAll()
   {
       // Write to the output control
       MyTextBox.Text += Name + " fixes all the mistakes with their magic hammer" + Environment.NewLine;
   }
}

  private void textBox1_TextChanged(object sender, EventArgs e)
       {
           myTextbox.Text += "message";
           myTextbox.Text += Environment.NewLine;
           
       }

       private void button1_Click(object sender, EventArgs e)
       {
           // Create a labourer object and assign it to a variable
           Labourer labourer1 = new Labourer();

           // Have the object speak
           labourer1.Speak();

           // Have the object move
           labourer1.Move();

           // Print out how many labourers have been created
           MyTextBox.Text += "Number of labourers created: " + labourer1.WorkerCount.ToString() + Environment.NewLine;

           // Create another labourer object (in a new variable)
           Labourer labourer2 = new Labourer();

           // Have the object speak
           labourer2.Speak();

           // Have the object move
           labourer2.Move();

           // Print out how many labourers have been created
           MyTextBox.Text += "Number of labourers created: " + labourer2.WorkerCount.ToString() + Environment.NewLine;

           // Create a new labourer object and assign it to the first variable created (should only have 2 variables of type labourer)
           Labourer labourer3 = labourer1;

           // Have the object speak
           labourer3.Speak();

           // Have the object move
           labourer3.Move();

           // Print out how many labourers have been created
           MyTextBox.Text += "Number of labourers created: " + labourer3.WorkerCount.ToString() + Environment.NewLine;

           Apprentice apprentice = new Apprentice("Bob");

           // Have it speak
           apprentice.Speak();

           // Have it move
           apprentice.Move();

           // Print out how many LABOURERS have been created
           MyTextBox.Text += "Number of labourers created: " + apprentice.WorkerCount.ToString() + Environment.NewLine;

           // Print out how many apprentices have been created
           MyTextBox.Text += "Number of apprentices created: " + apprentice.ApprenticeCount.ToString() + Environment.NewLine;

           // Create an object of type journeyman
           Journeyman journeyman = new Journeyman("John");

           // Have it move
           journeyman.Move();

           // Have it speak
           journeyman.Speak();

           // Have it fix it all
           journeyman.FixItAll();

           // Display its name
           MyTextBox.Text += "Journeyman's name: " + journeyman.Name + Environment.NewLine;

           // Print out how many LABOURERS have been created
           MyTextBox.Text += "Number of labourers created: " + journeyman.WorkerCount.ToString() + Environment.NewLine;

           // Print out how many apprentices have been created
           MyTextBox.Text += "Number of apprentices created: " + journeyman.ApprenticeCount.ToString() + Environment.NewLine;

           // Create another journeyman
           Journeyman journeyman2 = new Journeyman("Mary");

           // Have it move
           journeyman2.Move();

           // Have it speak
           journeyman2.Speak();

           // Have it fix it all
           journeyman2.FixItAll();

           // Display its name
           MyTextBox.Text += "Journeyman's name: " + journeyman2.Name + Environment.NewLine;

           // Print out how many LABOURERS have been created
           MyTextBox.Text += "Number of labourers created: " + journeyman2.WorkerCount.ToString() + Environment.NewLine;

           // Print out how many apprentices have been created
           MyTextBox.Text += "Number of apprentices created: " + journeyman2.ApprenticeCount.ToString() + Environment.NewLine;
       }
   }
}

CS0103 The name 'My TextBox' does not exist in the current context CS0103 The name 'MyTextBox' does not exist in the current context CS0103 The name 'My TextBox' does not exist in the current context CS0103 The name 'My TextBox' does not exist in the current context CS0103 The name 'My TextBox' does not exist in the current context CS0103 The name 'My TextBox' does not exist in the current context CS0103 The name 'My TextBox' does not exist in the current context CS0103 The name 'My TextBox' does not exist in the current context > CS0103 The name 'My TextBox' does not exist in the current context CS0103 The name 'MyTextBox' does not exist in the current context > CS0103 The name 'My TextBox' does not exist in the current context CS0103 The name 'MyTextBox' does not exist in the current context CS0103 The name 'My TextBox' does not exist in the current context CS0103 The name 'My TextBox' does not exist in the current context Lab4 Lab4 Lab4 Lab4 Lab4 Lab4 Lab4 Lab4 Lab4 Lab4 Lab4 Lab4 Lab4 Lab4 Form1.cs Form1.cs Form1.cs Form1.cs Form1.cs Form1.cs Form1.cs Form1.cs Form1.cs Form1.cs Form1.cs Program.cs Program.cs Program.cs 40 Active 52 Active 64 Active 75 Active 78 Active 93 Active 96 Active 99 Active 114 Active 117 Active 120 Active 45 Active 51 Active 102 Active

Step by Step Solution

3.44 Rating (170 Votes )

There are 3 Steps involved in it

Step: 1

Heres an how you can fix the code using System using SystemWindowsForms namespace Lab4 internal stat... 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

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

Write a program to check an input year is leap or not.

Answered: 1 week ago

Question

Write short notes on departmentation.

Answered: 1 week ago

Question

What are the factors affecting organisation structure?

Answered: 1 week ago

Question

What are the features of Management?

Answered: 1 week ago

Question

Briefly explain the advantages of 'Management by Objectives'

Answered: 1 week ago

Question

How has technology had an impact on product design?

Answered: 1 week ago