Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am using mindtap, please be aware of that. Please Help in C#, Make sure that the program passes the checks. One of the checks

I am using mindtap, please be aware of that. Please Help in C#, Make sure that the program passes the checks. One of the checks I already passed, I just need help with the other one.

checks:

Program produces correct output -- I already got this check

Fixed bug(s) in Breakfast class -- This the check I need help with, So this check requires these two tasks which are :

Fixed bug(s) in OneWayStreet class

Compilation failed: 3 error(s), 0 warnings NtTestb63dab4c.cs(12,26): error CS0246: The type or namespace name `OneWayStreet' could not be found. Are you missing `DebugTen02' using directive? NtTestb63dab4c.cs(18,5): error CS0246: The type or namespace name `OneWayStreet' could not be found. Are you missing `DebugTen02' using directive? NtTestb63dab4c.cs(19,21): error CS0841: A local variable `street' cannot be used before it is declared

Fixed bug(s) in TwoWayStreet class

Compilation failed: 3 error(s), 0 warnings NtTest0217e88a.cs(12,26): error CS0246: The type or namespace name `TwoWayStreet' could not be found. Are you missing `DebugTen02' using directive? NtTest0217e88a.cs(18,5): error CS0246: The type or namespace name `TwoWayStreet' could not be found. Are you missing `DebugTen02' using directive? NtTest0217e88a.cs(19,21): error CS0841: A local variable `street' cannot be used before it is declared

--------------------------------------------------------------------------------------------------------------------

Question:The provided file has syntax and/or logical errors. Determine the problem(s) and fix the program.

---------------------------------------------------------------------------------------------------------------------

Code given:

//namespace

using static System.Console;

//application namespace

namespace DebugTen02

{

class DebugTen02 //C# class

{

static void Main() //Main() method

{

//create object of OneWayStreet class

OneWayStreet oak = new OneWayStreet("Oak Avenue", "east");

//create object of TwoWayStreet

TwoWayStreet elm = new TwoWayStreet("Elm Street", "south");

WriteLine("On " + oak.Name + " " + oak.MakeUTurn());//print name and call method

WriteLine("On " + oak.Name + " " + oak.MakeUTurn());//print name and call method

WriteLine("On " + elm.Name + " " + elm.MakeUTurn());//print name and call method

WriteLine("On " + elm.Name + " " + elm.MakeUTurn());//print name and call method

}

}

abstract class Street //abstract class

{

protected string name;

protected string direction;

//constructor

public Street(string name, string travelDirection)

{

this.name = name;

direction = travelDirection;

}

public string Name //getter method

{

get

{

return this.name;

}

}

public abstract string MakeUTurn();

}

class OneWayStreet : Street //C# class

{

//constructor

public OneWayStreet(string name, string direction): base(name, direction)

{

}

public override string MakeUTurn() //method

{

string temp = "U Turn is illegal! Was going and still going " + direction;

return temp;

}

}

class TwoWayStreet : Street //C# class

{

//constructor

public TwoWayStreet(string name, string direction) : base(name, direction)

{

}

public override string MakeUTurn()

{

string wasGoing = direction;

string[] directions = { "north", "south", "east", "west" };

string[] oppDirections = { "south", "north", "west", "east" };

for (int x = 0; x < directions.Length; x++)

{

if (direction.Equals(directions[x]))

{

direction = oppDirections[x];

x = directions.Length;

}

}

string temp = "U Turn successful. Was going " + wasGoing +

". Now going " + direction;

return temp; //return

}

}

}

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

Recommended Textbook for

Hands-On Database

Authors: Steve Conger

2nd Edition

0133024415, 978-0133024418

More Books

Students also viewed these Databases questions

Question

Please help me evaluate this integral. 8 2 2 v - v

Answered: 1 week ago