I can't seem to successfully run the program. I'm only a couple weeks into learning c# and I can't seem to find a solution to this problem..
What I have to do is implement a loop into this project and I was thinking about looping my DisplayInfo method to display all 4 houses as well as all the info about them at the same time.
public class Houses
{
public string Address;
public string Color;
public int Price;
public int RoomNumbers;
public void DisplayInfo()
{
Console.WriteLine($"Address: {Address}");
Console.WriteLine($"The color of the propery is: {Color}");
Console.WriteLine($"The price of this property is valued at ${Price}");
Console.WriteLine($"This property has {RoomNumbers} rooms.");
}
}
class Program
{
static void Main(string[] args)
{
Houses[] house = new Houses[4];
{
house[0].Address = "55 New Bridge Ln.";
house[0].Color = "Red";
house[0].Price = 200000;
house[0].RoomNumbers = 2;
house[1].Address = "101 Coders Dr.";
house[1].Color = "Yellow";
house[1].Price = 250000;
house[1].RoomNumbers = 3;
house[2].Address = "2041 Hungry Man Cir.";
house[2].Color = "Green";
house[2].Price = 350000;
house[2].RoomNumbers = 5;
house[3].Address = "3080 Falmoth Dr.";
house[3].Color = "Purple";
house[3].Price = 400000;
house[3].RoomNumbers = 6;
}
for (int i = 0; i < house.Length; i++)
{
house[i].DisplayInfo();
}
}
} }