public void Start() { isStarted = true; while (isStarted) { int userInput; switch (currentState) { case MenuStateMachineState.Initialized: gui.ClearScreen(); menuPrinter.PrintHelloMessage(); userInput = gui.ReadInputInteger(); currentState = menuTransitionValidator.ValidateStateTransition(userInput, currentState); break; case MenuStateMachineState.OrderingBeverage: gui.ClearScreen(); menuPrinter.PrintAvailableBeverages(); userInput = gui.ReadInputInteger(); beverage = beverageFactory.CreateBeverage(userInput); currentState = menuTransitionValidator.ValidateStateTransition(userInput, currentState, beverage); break; case MenuStateMachineState.SelectBeverageSize: gui.ClearScreen(); menuPrinter.PrintAvailableBeverageSizes(); userInput = gui.ReadInputInteger(); currentState = menuTransitionValidator.ValidateStateTransition(userInput, currentState, beverage); beverage.SetBeverageSize(userInput.ToBeverageSize()); break; case MenuStateMachineState.SelectCoffeeType: gui.ClearScreen(); menuPrinter.PrintAvailableCoffeeTypes(); userInput = gui.ReadInputInteger(); currentState = menuTransitionValidator.ValidateStateTransition(userInput, currentState, beverage); (beverage as ICoffee).SetCoffeeType(userInput.ToCoffeeType()); break; case MenuStateMachineState.Finished: gui.ClearScreen(); gui.PrintMessageOnLine("Thank you for ordering! Here is your coffee!"); gui.PrintMessageOnLine($"Your order: {beverage.GetBeverageDetails()}"); gui.PrintMessageOnLine("Please enjoy and come again!"); currentState = MenuStateMachineState.Exit; break; case MenuStateMachineState.Exit: isStarted = false; break; } } }
public void PrintHelloMessage() { gui.PrintMessageOnLine("Hello! Welcome to Starbucks!"); gui.PrintMessageOnLine("How can I help you?"); gui.PrintMessageOnLine("1. Order a beverage"); gui.PrintMessageOnLine("2. Cancel"); }
public void Start() { isStarted = true; while (isStarted) { string userInput; switch (currentState) { case MenuStates.Initialized: menuPrinter.FirstScreen(); userInput = gui.ReadInput(); currentState = menuValidator.ValidateTransition(currentState, userInput); break; case MenuStates.AddingPerson: menuPrinter.SecondScreen(); person = gui.ReadPerson(); adressBook.AddPerson(person); currentState = menuValidator.ValidateTransition(currentState); break; case MenuStates.RemovingPerson: menuPrinter.ThirdScreen(); adressBook.RemovePerson(adressBook.people, person); currentState = menuValidator.ValidateTransition(currentState); break; case MenuStates.FindPersonByCNP: menuPrinter.FourthScreen(); gui.PrintMessageOnLine("Insert the CNP of the person that you wish to search for."); userInput = gui.ReadInput(); adressBook.ListAllPersons(adressBook.FindPersonByID(people, userInput)); currentState = menuValidator.ValidateTransition(currentState, userInput); break; case MenuStates.ShowAllPersons: menuPrinter.SeventhScreen(); adressBook.ListAllPersons(adressBook.people); currentState = menuValidator.ValidateTransition(currentState); break; case MenuStates.ShowAllPersonsFromCity: menuPrinter.FifthScreen(); gui.PrintMessageOnLine("Insert the city of the person that you wish to search for."); userInput = gui.ReadInput(); adressBook.ListAllPersons(adressBook.FindAllPersonsInCity(people, userInput)); currentState = menuValidator.ValidateTransition(currentState, userInput); break; case MenuStates.ShowAllPersonsFromCountry: menuPrinter.SixthScreen(); gui.PrintMessageOnLine("Insert the CNP of the person that you wish to search for."); userInput = gui.ReadInput(); adressBook.ListAllPersons(adressBook.FindAllPersonsInCountry(people, userInput)); currentState = menuValidator.ValidateTransition(currentState, userInput); break; case MenuStates.Finished: menuPrinter.SeventhScreen(); currentState = menuValidator.ValidateTransition(currentState); break; case MenuStates.Exit: isStarted = false; break; } } }
public void FirstScreen() { gui.ClearScreen(); gui.PrintMessageOnLine("Welcome to the adress book! How can we help you?"); gui.PrintMessageOnLine("1. Add a person"); gui.PrintMessageOnLine("2. Remove a person"); gui.PrintMessageOnLine("3. Show all persons"); gui.PrintMessageOnLine("4. Find a person by CNP"); gui.PrintMessageOnLine("5. Show all persons in a city"); gui.PrintMessageOnLine("6. Show all persons in a country"); }