For this example, suppose we are making a Clue β’ style game. We have a class for each room in the mansion and subclasses for the suspect and weapons in each room. Sort of:
class Room
{
public string Name;
public int Width;
public int Height;
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 this:
public Room(string Name, int Width, int Height)
{
this.Name = Name;
this.Width = Width;
this.Height = Height;
}
The initialization of the room was as simple as: Room[i] = new Room("Conservatory", 7, 3);- but after entering the nested classes, can they be initialized through a common constructor with the main class? Sort of:
Room[i] = new Room("Library", 8, 5, "Professor Plum", true, "Candlestick", true);
It seems that I do not see examples of such a setting. How can i do this?
source
share