KitchenTable.cs
using System.Collections.Generic; // for List
using party.house.rooms.tools; // for Tool
namespace party.house.rooms.furniture
{
class KitchenTable : Table // KitchenTable is a type of Table
{
List<Tool> tools; // tools for cooking
public KitchenTable(string name) : base(name) // call base constructor
{
tools = new List<Tool>();
}
public void AddTool(Tool t)
{
tools.Add(t);
}
public void RemoveTool(Tool t)
{
tools.Remove(t);
}
override public void ClearTable()
{
tools.Clear();
}
override public string ToString()
{
string message = base.ToString(); // name
message += " is useful";
foreach (Tool t in tools)
{
message += t.Id;
message += ", ";
}
return message;
}
}
}
Comments
Post a Comment