Question: 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:

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
Get step-by-step solutions from verified subject matter experts
