Issue
This is my Code so far:
public static void FillArray(int[,,,] array)
{
List<string> BusCompany = new List<string>();
BusCompany.Add("Sample Company 1");
BusCompany.Add("Sample Company 2");
BusCompany.Add("Sample Company 3");
BusCompany.Add("Sample Company 4");
BusCompany.Add("Sample Company 5");
List<string> Route = new List<string>();
BusCompany.Add("Sample Route 1");
BusCompany.Add("Sample Route 2");
List<string> Bus = new List<string>();
BusCompany.Add("Sample Bus 1");
BusCompany.Add("Sample Bus 2");
List<string> Seat = new List<string>();
BusCompany.Add("Seat 1");
BusCompany.Add("Seat 2");
BusCompany.Add("Seat 3");
BusCompany.Add("Seat 4");
BusCompany.Add("Seat 5");
BusCompany.Add("Seat 6");
BusCompany.Add("Seat 7");
BusCompany.Add("Seat 8");
BusCompany.Add("Seat 9");
BusCompany.Add("Seat 10");
List<string> Available = new List<string>();
BusCompany.Add("Yes");
string[,,,,] reservationTable;
for (int BC = 0; BC < BusCompany.Count; BC++)
{
string BusCompanyValue = BusCompany[BC];
for (int BR = 0; BR < Route.Count; BR++)
{
string BusRouteValue = Route[BR];
for (int BB = 0; BB < Bus.Count; BB++)
{
string BusValue = Bus[BB];
for (int BS = 0; BS < Seat.Count; BS++)
{
string SeatValue = Seat[BS];
reservationTable[BC, BR, BB, BS,];
}
}
}
}
}
What I want it to do is get the values from the each list, and populate the array in a way where each one becomes a property of the one before. Sorry don’t know how else to explain it.
For example one full thing would be
["Sample Company 1", "Sample Route 1", "Sample Bus 1", "Seat 1", "Yes"]
while another would be
["Sample Company 1", "Sample Route 1", "Sample Bus 1", "Seat 2", "Yes"]
and so on until all the different variations have been added. The "Yes" at the end is always the same value.
My main attempt has just been the code I showed above, so far I’ve gotten no result.
Solution
What I think you need is somethin glike this
class Company{
string Name;
List<Route> Routes;
List<Bus> Buses;
}
class Route{
string Name;
}
class Bus{
List<Seat> Seats;
}
class Seat{
int Number;
bool Booked;
}
Answered By – pm100
Answer Checked By – David Goodson (BugsFixing Volunteer)