/// <summary> /// Övning 3: ExamineStack() /// /// Examines the datastructure Stack /// /// Simulera ännu en gång ICA-kö på papper. Denna gång med en stack . Varför är det inte så smart att använda en stack i det här fallet? /// En stack är en så kallad LIFO samling av data. Det innebär att det som adderades sist är det som hämtas först. /// Vilket är tvärt imot en kö som är en så kalald FIFO samling av data. Där den som adderades först hämtas först /// /// </summary> static void ExamineStack() { Console.WriteLine("ExamineStack"); /* * Loop this method until the user inputs something to exit to main menue. * Create a switch with cases to push or pop items * Make sure to look at the stack after pushing and and poping to see how it behaves */ ExamineStack examineStack = new ExamineStack(); examineStack.RunExamineStack(); }
/// <summary> /// Examines the datastructure Stack /// </summary> static void ExamineStack() { /* * Loop this method until the user inputs something to exit to main menue. * Create a switch with cases to push or pop items * Make sure to look at the stack after pushing and and poping to see how it behaves */ // Question 1: Then the first person that gets added to the line is the last one to go. The queue system gets reversed. Console.Clear(); ExamineStack examineStack = new ExamineStack(); bool quit = false; do { ExamineStackInfo(); char input = InputCheck(); switch (input) { case '+': examineStack.ReverseText(); Console.Clear(); break; case 'Q': quit = true; Console.Clear(); break; default: Console.WriteLine("Use '+' to type a name"); break; } } while (!quit); }