I am trying to make a simple food delivery system by using data structures. I hold the Neighborhood names in an ArrayList and I hold the Delivery Count, Food Name and it's count in GenericList. I drew the schematic and attached the photo.
I coded the program which prints the "Hood Name and it's delivery count" my code and my outputs are here:
using System;
using System.Collections;
using System.Collections.Generic;
namespace temp
{
internal class delivery
{
public string food;
public int count;
}
internal class Hood
{
public string Name;
public int Number;
}
class programm
{
static void Main(string[] args)
{
string[] HoodName = { "Cherryhood", "NewCastle", "Greenlight", "Summerlin", "Westcity", "Paradise", "Legions", "Flamingos" };
int[] TeslimatSayisi = { 4, 2, 7, 2, 7, 3, 0, 1 };
ArrayList arrayList = new ArrayList();
int counter = 0;
List<Hood> genericList;
Hood ClassExample;
for (int i = 0; i < HoodName.Length;)
{
genericList = new List<Hood>();
int elementCount = (int)Math.Pow(2, counter);
for (int j = 0; j < elementCount; j++)
{
ClassExample = new Hood();
ClassExample.Name = HoodName[i];
ClassExample.Number = TeslimatSayisi[i];
genericList.Add(ClassExample);
i++;
if (i == HoodName.Length) break;
}
arrayList.Add(genericList);
counter++;
}
int counter2 = 0;
foreach (List<Hood> temp in arrayList)
{
foreach (Hood temp2 in temp)
Console.WriteLine("Hood: " + temp2.Name +" | "+" Delivery Count: " + temp2.Number);
}
My outputs are:
Hood: Cherryhood | Delivery Count: 4
Hood: NewCastle | Delivery Count: 2
Hood: Greenlight | Delivery Count: 7
Hood: Summerlin | Delivery Count: 2
Hood: Westcity | Delivery Count: 7
Hood: Paradise | Delivery Count: 3
Hood: Legions | Delivery Count: 0
Hood: Flamingos | Delivery Count: 1
How can I get an output like this:
Hood: Cherryhood | Delivery Count: 4 | Food's, count: Salat:2, Taco:5, Pizza:1, Burger:2
Hood: NewCastle | Delivery Count: 2 | Food's, count: Pasta:15, Cake,7
Hood: Greenlight | Delivery Count: 7 | Food's, count: ................
Hood: Summerlin | Delivery Count: 2 | ..........
Hood: Westcity | Delivery Count: 7 |...........
Hood: Paradise | Delivery Count: 3 |.................
Hood: Legions | Delivery Count: 0 |...........
Hood: Flamingos | Delivery Count: 1 |.....................
I can guess I have to make a food list and count list like this:
foods = {pizza, taco, burger, salad, pasta, cake..........}
count = {1, 5, 2, 2, 15 ,7...........}
I need to create the delivery class (containing the Meal Name, Quantity fields). Then I have to fill each of the Generic Lists in the ArrayList with the number of Delivery objects in the relevant neighborhood. I can create a food list and randomly select food information from there. For this project, We can assume that each delivery can consist of only one type of meal (including how many).
I am pretty new on C# and Data Structures thanks a lot for the help.
