ch3p-Kitchen (a type of Room)

AppParty     Diner Bed







Kitchen.cs


using System.Collections.Generic; // for List
using party.house.rooms.furniture; // for Chair, Table, KitchenTable
using party.house.occupants; // for Robot

namespace party.house.rooms
{
class Kitchen : Room // Kitchen is a type of Room
{
List<Chair> chairs;
Table table;

public Kitchen(string name) : base(name) // call base constructor
{
chairs = new List<Chair>();
table = new KitchenTable("Kitchen table");
}

public Kitchen(string name, Table table) : base(name) // call base constructor
{
chairs = new List<Chair>();
this.table = table;
}

public Table GetTable()
{
return table;
}

public void SetTable(Table table)
{
this.table = table;
}

public void AddChair(Chair chair)
{
chairs.Add(chair);
}

public void RemoveChair(Chair chair)
{
chairs.Remove(chair);
}

public void CleanKitchen(Robot r)
{
System.Console.WriteLine(r.ToString() + " cleans the kitchen");
table.ClearTable();
}

override public string ToString()
{
string message = base.ToString(); // name
message += " is practical; it has a ";
message += table.Id;
message += " and ";
message += chairs.Count;

if (chairs.Count == 1)
{message += " chair: ";}
else {message += " chairs: ";}

foreach (Chair c in chairs)
{
message += c.Id;
message += ", ";
}

return message;
}
}
}









AppParty     Diner BACK_TO_TOP Bed



Comments

Popular posts from this blog

Contents