I have create a class, islands, for which i have created 7 instances in the main class. Each instance has an in assigned, which represents how many containers need to be picked up from each.
class Program
{
public static int[,] TEUlayer1 = new int[4, 4] { { 1, 1, 1, 1 }, { 1, 1, 1, 1 }, { 1, 1, 1, 1 }, { 1, 1, 1, 1 } };
public static int[,] TEUlayer2 = new int[4, 4] { { 1, 1, 1, 1 }, { 1, 1, 1, 1 }, { 1, 1, 1, 1 }, { 1, 1, 1, 0 } };
public static Island is1 = new Island(2);
public static Island is2 = new Island(3);
public static Island is3 = new Island(1);
public static Island is4 = new Island(4);
public static Island is5 = new Island(2);
public static Island is6 = new Island(2);
public static Island is7 = new Island(1);
static void Main(string[] args)
{
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
Console.Write(TEUlayer1[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine();
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
Console.Write(TEUlayer2[i, j] + " ");
}
Console.WriteLine();
}
}
}
class Island
{
public int S8s4collection { get; set; }
public Island(int s8s)
{
s8s = S8s4collection;
}
}
it is probably worth ignoring the main method and TEUlayer1/2 parts. these represent a stack of containers on a small ship, but this isn't relevant to the question.
My question is can I create a loop, or some other function, that goes through each instance of the island class (is1, is2 ...) and appends the value associated with it to a list or array etc?
thanks!