Cake.cs
using party.house.rooms.ornaments; // for Candle
using party.house.rooms.tools; // for Match
namespace party.foods
{
class Cake : Food // Cake is a type of Food
{
public Cake(string name) : base(name) // call base constructor
{}
public void Celebrate()
{
Match m = new Match("Match");
System.Console.WriteLine(m); // m.ToString()
m.Light();
Candle c = new Candle("Candle");
System.Console.WriteLine(c); // c.ToString()
c.Light();
}
override public string ToString()
{
string message = base.ToString(); // name
message += " is delicious";
return message;
}
}
}
Comments
Post a Comment