For the sake of this example, suppose we're making a dumbed-down game of Clue™. We have a class for each Room in the mansion, and subclasses for the Suspect and Weapon in each Room. Something like:
class Room
{
public string Name;
public int Width;
public int Height;
// and so on...
public class Suspect
{
public string Name;
public bool isPurple;
}
public class Weapon
{
public string Name;
public bool IsMetal;
}
}
Before adding the Suspect and Weapon classes, the Room constructor looked something like:
public Room(string Name, int Width, int Height)
{
this.Name = Name;
this.Width = Width;
this.Height = Height;
}
Initializing a room used to be as simple as: Room[i] = new Room("Conservatory", 7, 3); - but after the nested classes were introduced, can their initialization be handled through a shared constructor with the main class? Something like:
Room[i] = new Room("Library", 8, 5, "Professor Plum", true, "Candlestick", true);
I can't seem to find any examples of a similar setup. How can I accomplish this?