**----------------------------** **-------- Burrito.cs --------** **----------------------------** //Burrito.cs is same as Burrito.Java using System; using System.Threading; namespace BurritoBrotherApplication { public class Burrito { public static int numofCustomers = 0; public static int numofServers = 4; public static int numofStoreCapacity = 25; public static int MaxArrivalWindow = 4000; //Values defined is in milliseconds. That would be 4 seconds time. public static int MaxCookingSpeed = 500; //Values defined is in milliseconds. That would be 10 seconds time. public static int MaxCheckoutSpeed = 10; //Values defined is in milliseconds. That would be 10 seconds time. public static bool defaultSelection; static void Main(string[] args) { int selectCase; do { defaultSelection = true; Console.Clear(); Console.WriteLine("Welcome to Burrito Brothers restaurant"); Console.WriteLine("Pease Select the appropriate menu."); Console.WriteLine("1. Select Random Value Execution."); Console.WriteLine("2. Select Manual Value Execution."); selectCase = int.Parse(Console.ReadLine()); switch (selectCase) { //Only focusing insert Customer Size case 1: numofCustomers = 7; break; case 2: Console.WriteLine("How many Customers you want to generate?"); numofCustomers = int.Parse(Console.ReadLine()); while (numofCustomers > 15 || numofCustomers < 2) { Console.WriteLine("Please Enter Correct Number of Customer Generate Values (Value must limit to 15)."); numofCustomers = int.Parse(Console.ReadLine()); } break; default: defaultSelection = false; Console.WriteLine("Incorrect Input. Please select appropriate menu."); Console.WriteLine("Refreshing Page."); Thread.Sleep(2000); break; } } while (!defaultSelection); Console.WriteLine("------------- Customers activity --------------------|-------------------- Servers activity --------------"); StoreExecution str = new StoreExecution(); for (int i = 0; i < numofServers; ++i) { Thread ServerInitialization = new Thread(new ThreadStart(new ServerInitialization.ServerInitialization(i))); ServerInitialization.Start(); } for (int i = 0; i < numofCustomers; ++i) { Thread Customers = new Thread(StoreExecution.getMarketObject()); Customers.Start(); try { Random randObj = new Random() Thread.Sleep((int)(1 + MaxArrivalWindow * randObj.NextDouble())); } catch (Exception e) { throw e; } } } } } Error: Having Error after my switch statement **----------------------------** **------- Customer.cs --------** **----------------------------** using System; using System.Collections.Generic; using System.Text; namespace BurritoBrotherApplication { public class Customer : Burrito { private int custID; private int orderSize; public Customer() { Random rnd = new Random(); this.orderSize = rnd.Next(5, 25); } public int getOrderSize() { return orderSize; } public void reOrderSize() { this.orderSize = this.orderSize - 3; } public int getCustomerID() { return custID; } public void setCustomerID(int custID) { this.custID = custID; } } } No Error Detected **----------------------------** **--------- Server.cs --------** **----------------------------** using System; using System.Collections.Generic; using System.Text; namespace BurritoBrotherApplication { public class ServerInitialization { public int serverID; private static Customer atCounter = new Customer(); static private int ServersInStore = Burrito.numofServers; public ServerInitialization(int serverNum) { this.serverID = serverNum; } public static void GetServer() { try { //Shop.getShop().semStartServing.acquire(); StoreExecution.getMarketObject().semCounter.WaitOne(); atCounter = StoreExecution.getMarketObject().Counters(serverID); StoreExecution.getMarketObject().semCounter.Release(); if (atCounter.getOrderSize() > 3) { atCounter.reOrderSize(); // redusing ordersize by 3 buritos StoreExecution.getMarketObject().Cooking(3, serverID); Console.WriteLine("Customer #" + atCounter.getCustomerID() + " should reenter the line"); StoreExecution.getMarketObject().CheckNumOfCustomersInStore(atCounter, false); StoreExecution.getMarketObject().semServing.Release(); } else { StoreExecution.getMarketObject().Cooking(atCounter.getOrderSize(), serverID); StoreExecution.getMarketObject().GoToPay(atCounter); if (!StoreExecution.getMarketObject().RegisterLine.isEmpty() && StoreExecution.getMarketObject().semRegister.WaitOne()) { Console.WriteLine("Server # " + serverID + " is on register"); StoreExecution.getMarketObject().Register(); Console.WriteLine("Server # " + serverID + " has left register"); } } } catch (Exception e) { throw e; } } public static void run() { bool working = true; while (working) { try { // try to serve customer if no customer in line wait if (StoreExecution.customerInQueue > 0) { GetServer(); } else { working = false; // closing store Console.WriteLine("Server #" + serverID + " finish his job"); --ServersInStor; if (ServersInStor == 0) { Console.WriteLine("Store is closed"); } } } catch (Exception e) { throw e; } } } } } Error(s) 1. Unable to access serverID in GetServer() Method 2. Unable to access LinkedList **-----------------------------------** **-------- StoreExecution.cs --------** **-----------------------------------** using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; namespace BurritoBrotherApplication { public class StoreExecution : Burrito { private static StoreExecution getMarkObj = new StoreExecution(); private static int customerShopping = 0; public static int customerInQueue = 0; private static int CustomerID = 0; private Customer[] line = new Customer[Burrito.numofStoreCapacity]; public static LinkedList RegisterLine = new LinkedList(); public Semaphore semCustomerShopping = new Semaphore(1, 1); public Semaphore semServing = new Semaphore(0, 1); public static Semaphore semRegister = new Semaphore(1, 1); public Semaphore semRegisterLine = new Semaphore(1, 1); public Semaphore semCounter = new Semaphore(1, 1); public Semaphore semLine = new Semaphore(1, 1); public Semaphore semOrdersItems = new Semaphore(1, 1); public static StoreExecution getMarketObject() { return getMarkObj; } public void CheckIn() { try { semCustomerShopping.WaitOne(); // only one customer can enter store at a time. ++CustomerID; if (customerShopping < numofStoreCapacity) { ++customerShopping; Customer Cust = new Customer(); Cust.setCustomerID(CustomerID); Console.WriteLine("Welcome! Customer #" + Cust.getCustomerID() + " have places the order of " + Cust.getOrderSize() + " burritos."); CheckNumOfCustomersInStore(Cust, true); semServing.Release(); // letting server now that there is customer in the store. semCustomerShopping.Release(); // now other customer can enter the store } else { Console.WriteLine("There are many Cusomers currently Shopping. Please Wait..."); Console.WriteLine("\n CustomerID - " + CustomerID + " has left the shop."); semCustomerShopping.Release(); // now other customer can enter the store } } catch (Exception e) { throw e; } } public void CheckNumOfCustomersInStore(Customer Cust, bool newCust) { try { semLine.WaitOne(); if (customerInQueue == 0) { CustomerInQueue(1, 0, Cust); } else { if (customerInQueue == 1 && !newCust) line[1] = Cust; else { if (customerInQueue == 1 && newCust) { if (Cust.getOrderSize() > line[0].getOrderSize()) line[1] = Cust; else { line[1] = line[0]; line[0] = Cust; } } else { for (int i = 0; i < customerInQueue - 1; ++i) { if (line[i].getOrderSize() > line[i + 1].getOrderSize()) { CustomerInQueue(customerInQueue + 1, i + 1, Cust); break; } if (i == customerInQueue - 2) line[i + 2] = Cust; } } } } ++customerInQueue; semLine.Release(); } catch (Exception e) { throw e; } } public void CustomerInQueue(int customerInQueue, int Sortuntill, Customer Cust) { if (customerInQueue == 1) line[0] = Cust; else { for (int i = customerInQueue - 1; i > Sortuntill; --i) { if (Cust.getOrderSize() < line[i - 1].getOrderSize()) { line[i] = line[i - 1]; //moving elements if (i == Sortuntill + 1) { line[i - 1] = Cust; break; } } else { line[i] = Cust; break; } } } Console.WriteLine("Customer #" + Cust.getCustomerID() + " having " + Cust.getOrderSize() + " of burritos is waiting in line"); } public Customer Counters(int serverID) { Customer atCounter; String Line = ""; if (Burrito.defaultSelection) { for (int i = 0; i < customerShopping; ++i) Line = Line + "C" + StoreExecution.getMarketObject().line[i].getCustomerID() + "(" + StoreExecution.getMarketObject().line[i].getOrderSize() + ")-"; Console.WriteLine("Customers in line: " + Line); } atCounter = line[0]; //serving first customer in the line Console.WriteLine("\n Server #" + serverID + " serving Customer #" + atCounter.getCustomerID()); /*test*///Prnt.getPrnt().ServerIsFree(serverID,atCounter); for (int i = 0; i < customerShopping; ++i) //moving the line line[i] = line[i + 1]; --customerShopping; //customer is on counter, not in line anymore line[customerShopping] = null; return atCounter; } public void Cooking(int burritos, int ServerID) { try { semOrdersItems.WaitOne(); Console.WriteLine("Server #" + ServerID + " has obtained all ingredients"); semOrdersItems.Release(); Console.WriteLine("Cooking..."); try { Thread.Sleep(burritos * Burrito.MaxCookingSpeed); //simulating servers work } catch (Exception e) { throw e; } } catch (Exception e) { throw e; } } public void GoToPay(Customer atCounter) { LinkedList RegisterPrnt = new LinkedList(); string AtRegister = ""; try { semRegisterLine.WaitOne(); RegisterLine.AddLast(atCounter); //adding customer into register queue if (Burrito.defaultSelection) { RegisterPrnt = RegisterLine; for (int i = 0; i < RegisterPrnt.Count; ++i) { AtRegister = AtRegister + "C" + RegisterPrnt.ToList()[i].getCustomerID() + "<="; } Console.WriteLine("Customers on register:"); Console.WriteLine(AtRegister); } semRegisterLine.Release(); } catch (Exception ex) { throw ex; } } public static void Register() { Customer cust; if (RegisterLine.Count > 0) { cust = RegisterLine.First.Value; Console.WriteLine("Customer #" + cust.getCustomerID() + " is paying..."); try { Thread.Sleep(5000); //simulating paying } catch (Exception e) { throw e; } Console.WriteLine("Good bye! Customer #" + cust.getCustomerID() + " is leaving the store"); --customerShopping; //customer exits the shop } semRegister.Release(); } } }