Robot.cs
using System.Collections.Generic; // for List
namespace party.house.occupants
{
class Robot
{
string name;
List<Guest> guests;
public Robot(string name)
{
this.name = name;
guests = new List<Guest>();
}
public List<Guest> getGuests()
{
return guests;
}
public void setGuests(List<Guest> guests)
{
this.guests = guests;
}
public void AddGuest (Guest g)
{
guests.Add(g);
}
public void RemoveGuest (Guest g)
{
guests.Remove(g);
}
public string Invitations()
{
string invitations = name + " invited: ";
foreach (Guest g in guests)
{
invitations += g.ToString();
invitations += ", ";
}
return invitations;
}
public void ClearGuests()
{
System.Console.WriteLine(name + " says Good bye to all the guests");
guests.Clear();
}
override public string ToString()
{
return name;
}
}
}
Comments
Post a Comment