Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C Sharp Please Someone has asked you to implement the following UML Class Diagram: They have coded the Abstract Base Class (ABC) Appliance for you.

C Sharp Please

Someone has asked you to implement the following UML Class Diagram:

image text in transcribed

They have coded the Abstract Base Class (ABC) Appliance for you. Heres his implementation:

public abstract class Appliance

{

protected string make;

protected ApplianceState state;

public Appliance(string make)

{

this.make = make;

}

//Virtual Methods

public virtual string Description()

{

string description = string.Empty;

description += "Im a " + make + " appliance.";

description += Environment.NewLine;

description += "My state is " + state;

description += Environment.NewLine;

return description;

}

//Abstract Methods

public abstract void TurnOn();

public abstract void TurnOff();

}

ApplianceState is an enumeration. It has two members: Off and On. Complete the Appliance class implementation, and test it in the Main method. Note: even though the Description method declared in the Appliance class is marked virtual, dont override it in the derived classes.

Below is the test program that they require you to use.

class Program

{

static void Main()

{

//Input

Appliance maytag = new Fridge("Maytag");

Appliance amana = new Oven("Amana");

Appliance kitchenAid = new Dishwasher("Kitchen Aid");

Appliance whirlpool = new Dishwasher("Whirlpool");

Appliance[] appliances = new Appliance[4];

appliances[0] = maytag;

appliances[1] = amana;

appliances[2] = kitchenAid;

appliances[3] = whirlpool;

//Process & Output

DescribeYourselves(appliances);

TurnOnAppliances(appliances);

DescribeYourselves(appliances);

TurnOffAppliances(appliances);

DescribeYourselves(appliances);

Console.Read();

}

public static void DescribeYourselves(Appliance[] appliances)

{

foreach (Appliance appliance in appliances)

{

Console.WriteLine(appliance.Description());

}

Console.WriteLine();

}

public static void TurnOnAppliances(Appliance[] appliances)

{

foreach (Appliance appliance in appliances)

{

appliance.TurnOn();

}

Console.WriteLine();

}

public static void TurnOffAppliances(Appliance[] appliances)

{

foreach (Appliance appliance in appliances)

{

appliance.TurnOff();

}

Console.WriteLine();

}

}

UML CLASS DIAGRAM Appliance make: string + Appliance (string) + Description (): string Dishwasher Fridge Oven + Dishwasher (string) + Fridge (string) + Oven (string) + Turn On (): void + Turn On (void + Turn On : void UML CLASS DIAGRAM Appliance make: string + Appliance (string) + Description (): string Dishwasher Fridge Oven + Dishwasher (string) + Fridge (string) + Oven (string) + Turn On (): void + Turn On (void + Turn On : void

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

Question

1.who the father of Ayurveda? 2. Who the father of taxonomy?

Answered: 1 week ago

Question

Commen Name with scientific name Tiger - Wolf- Lion- Cat- Dog-

Answered: 1 week ago