BedRoom.cs
using party.house.rooms.furniture; // for Bed, BedType, Chair
namespace party.house.rooms
{
class BedRoom : Room // BedRoom is a type of Room
{
Bed bed;
Chair chair;
public BedRoom(string name) : base(name) // call base constructor
{bed = new Bed();}
public BedRoom(string name, Bed bed) : base(name) // call base constructor
{
this.bed = bed;
}
public BedRoom(string name, Bed bed, Chair chair) : base(name)
{
this.bed = bed;
this.chair = chair;
}
public Chair GetChair()
{
return chair;
}
public void SetChair(Chair chair)
{
this.chair = chair;
}
public void RemoveChair()
{
chair = null;
}
override public string ToString()
{
string message = base.ToString(); // name
message += " is silent; ";
message += bed.ToString();
if (chair != null)
{
message += ", chair: ";
message += chair.Id;
}
return message;
}
}
}
Comments
Post a Comment