static void Main(string[] args) { //Create keyboard object ConsoleKeyInfo keyboard = new ConsoleKeyInfo(); //Declare and initialize sentinel bool keep_going = false; do { //Display main menu Console.WriteLine(StandardMessages.DisplayMainMenu()); keyboard = Console.ReadKey(); switch (keyboard.Key) { case ConsoleKey.D1: case ConsoleKey.NumPad1: //Calculate total retail price CalculateRetailPrice.CalculateTotalPrice(); break; case ConsoleKey.Escape: //End program keep_going = true; break; default: //Displays invalid option Console.WriteLine(StandardMessages.DisplayInvalidOption()); Console.ReadLine(); break; } Console.Clear(); } while (keep_going == false); }
//Non-Preferred customer transaction method public static void CustomerItemPurchaseNotPreferred(List <NonPreferredCustomer> inputList, int index, string input) { bool loop = false; decimal purchasePrice; NonPreferredCustomer notPreferredTransaction = new NonPreferredCustomer(); Console.WriteLine(StandardMessages.DisplayNotPreferredCustomerMessage()); notPreferredTransaction.CustomerStatus = false; do { //Get users purchase price Console.Write("Enter purchase price ==> "); input = Console.ReadLine(); //Determine if user inputs a number or character if (decimal.TryParse(input, out purchasePrice)) { notPreferredTransaction.PurchaseAmount = purchasePrice; notPreferredTransaction.TransactionNumber = notPreferredTransaction.TransactionNumber + index; inputList.Add(notPreferredTransaction); DisplayCustomerTransaction.DisplayNonPreferredTransaction(purchasePrice); Console.WriteLine(StandardMessages.DisplayEnterMessage()); Console.ReadLine(); loop = true; } else { //If user enters anything other than a number display invalid input. Console.WriteLine(StandardMessages.DisplayInvalidChoice()); Console.ReadLine(); } } while (loop == false); }
static void Main(string[] args) { bool exit = false; Car thisCar = new Car(); do { Console.WriteLine(StandardMessages.DisplayMenu()); switch (Console.ReadLine()) { case "1": CarInformation.CreateCar(thisCar); break; case "2": thisCar.Accelerate(); break; case "3": thisCar.Brake(); break; case "4": exit = true; break; default: StandardMessages.DisplayChoiceError(); break; } Console.WriteLine(StandardMessages.DisplaySpeed(thisCar)); } while (exit == false); }
public static void CreateZombieAdvCharacter(Player player, GameRoom room) { //Sentinel to control loop bool characterLoop = false; string input; Console.WriteLine(StandardMessages.CreateCharacterDirections()); Console.ReadLine(); Console.Clear(); do { //Character creation menu Console.WriteLine(StandardMessages.DisplayCreateCharacterMenu()); input = Console.ReadLine(); switch (input) { case "1": //Creat name and password CreateNameAndPassword(player, characterLoop); break; case "2": //Select player class SelectPlayerClass(player, input, characterLoop); break; case "3": //Select player race SelectPlayerRace(player, input, characterLoop); break; case "4": //Display created player information Console.WriteLine($"Name: {player.Name}\nPassword: {player.Password}\nCLass: {player.ClassType}\nRace: {player.Race}"); Console.ReadLine(); break; case "5": //Test to ensure player completes character creation if (player.Name == "" || player.Password == "" || player.ClassType == "" || player.Race == "") { Console.WriteLine("You must complete all tasks to proceed!"); Console.ReadLine(); } else { characterLoop = true; PlayerMovement.CharacterMovement(player, room); } break; default: Console.WriteLine(StandardMessages.InvalidSelection()); break; } Console.Clear(); } while (characterLoop == false); }
static void Main(string[] args) { bool exit = false; Car car = new Car(); do { StandardMessages.Menu(); string input = Console.ReadLine(); switch (input) { case "1": car = Work.GetCarInfo(); break; case "2": car.Accelerate(); Console.WriteLine($"The {car.Year} {car.Make} is going {car.Speed} mph."); break; case "3": car.Brake(); Console.WriteLine($"The {car.Year} {car.Make} is going {car.Speed} mph."); break; case "4": exit = true; break; } } while (exit == false); }
static void Main() { // Variable for true false used incase user wants to continue the program. bool exit = false; // Reads the order at the start of the program. Will notify user immediately if there is an error in their pricing. ListCreation.ReadOrder(); do { // Switch that uses goes to menu options and uses the user's choice. switch (StandardMessages.Menu()) { case "yes": { // "" is for cleaning up apperance and then the program records the user's text file into a list for use in calculation. Console.WriteLine(""); // Validates whether the user entered the products correctly or with a proper amount. ProductListAndValidation.PurchaseValidation(); break; } case "no": { // Exit's the program if the user says no. exit = true; break; } } } while (exit == false); }
static void Main(string[] args) { bool exit = false; Car car = new Car(); do { StandardMessages.DisplayMenu(); switch (Console.ReadLine()) { case "1": car = BuildCar.GetCarInfo(); break; case "2": car.Accelerate(); StandardMessages.DisplayCarSpeed(car); break; case "3": car.Brake(); StandardMessages.DisplayCarSpeed(car); break; case "4": exit = true; break; default: StandardMessages.DisplayMenuError(); break; } } while (exit == false); }
static void Main(string[] args) { Builder.Build(); // Build all of the list. BuildPlayer.BuildAPlayer(); bool exit = false; string[] Weapons = { "EnergySword", "PlasmaBow", "ProtonPistol", "DecoyGrenade" }; string[] Potions = { "HealthPotion", "StaminaPotion" }; string[] Treasure = { "Credits", "Titanium", "Electronic Parts" }; List <string> Items = new List <string>() { "Map", "Armor", "Plasma Arrows", "Proton Bullets" }; DisplayCurrentRoom.CurrentRoom(); do { Console.Write(StandardMessages.DisplayMenu()); //Taking the user's choice and passing it through a switch statement. Using console.readline for the argument. switch (Console.ReadLine()) { case "1": break; case "2": Console.WriteLine(StandardMessages.PromptForMovement()); GameAction.PlayerActions(Console.ReadLine(), Player._player); break; case "3": Console.WriteLine(StandardMessages.PromptForAttack()); GameAction.PlayerActions(Console.ReadLine(), Player._player); break; case "4": Console.WriteLine(StandardMessages.AdminCenter()); Create.PromptForCreation(); break; case "5": //Exit the program --> Set the boolean variable to true and display goodbye message. Console.WriteLine(StandardMessages.DisplayGoodbye()); Console.ReadLine(); exit = true; break; default: //Call number error message for incorrect menu choice. Console.WriteLine(StandardMessages.DisplayNumberError()); Console.ReadLine(); break; } } while (exit == false); }
public static void MainMenu() { //Declare and initilize loop variable bool mainMenuLoop = false; //Loop to control main menu options do { Console.Clear(); Console.WriteLine(StandardMessages.DisplayMainMenu()); //Get menu choice from user string menuChoice = (Console.ReadLine()); //Use to control the selction of the main menu switch (menuChoice) { case "1": case "Start": Console.Clear(); mainMenuLoop = true; break; case "2": case "Settings": case "settings": case "S": case "s": Console.WriteLine(StandardMessages.DisplaySettingsMenu()); Console.ReadLine(); break; case "3": case "Options": case "options": case "O": case "o": OptionMenu(); break; case "4": case "Exit": case "exit": case "E": case "e": mainMenuLoop = true; System.Environment.Exit(0); break; default: Console.WriteLine(StandardMessages.InvalidSelection()); Console.ReadLine(); break; } } while (mainMenuLoop == false); }
static void Main(string[] args) { // Create variable for user input and sentry for loop bool exit = false; List <Employee> employees = new List <Employee>(); // Do while loop for menu do { Console.Write(StandardMessages.DisplayMenu()); // Switch to direct to proper process switch (Console.ReadLine()) { case "1": BuildEmployees.BuildEmployeeClassObjects(employees); Console.WriteLine(""); Console.WriteLine(StandardMessages.DisplayEmployee(employees[employees.Count - 1])); //WL in the create employee case to show the user what info they entered break; case "2": Console.WriteLine(""); for (int i = 0; i < employees.Count; i++) { Console.WriteLine(StandardMessages.DisplayEmployee(employees[i])); //For loop to display everything in the list } Console.WriteLine(""); break; case "3": Console.WriteLine(""); if (employees.Count == 0) //If statement is created just incase the user enters 3 as the first command { //the program will tell the user to enter an employee's information first Console.WriteLine(StandardMessages.ListIsEmptyError()); Console.WriteLine(""); break; } else { Console.WriteLine(StandardMessages.DisplayAverageAge(employees)); //Average age is calculated with the .Average() method } //I wasn't sure if it belonged here in main or in StandardMessages since it uses a method Console.WriteLine(""); break; case "4": exit = true; break; default: Console.WriteLine(StandardMessages.DisplayNumberError()); Console.WriteLine(""); break; } } while (exit == false); }
public static Person Capture() { Person output = new Person(); StandardMessages.InstructionMessage("first"); output.FirstName = Console.ReadLine(); StandardMessages.InstructionMessage("last"); output.LastName = Console.ReadLine(); return(output); }
public static void CreateWeapon() { Weapon weapon = new Weapon(); bool error = false; try { StreamWriter outputFile = File.AppendText(@"../../../TextAdventureLib/Docs/Weapons.csv"); Console.Write("Enter the name of the weapon: "); weapon.Name = Console.ReadLine().Trim(); Console.Write("Enter the description of the weapon: "); weapon.Description = Console.ReadLine().Trim(); do { Console.Write("Enter the durablitly of the weapon: "); weapon.Durability = ConvertInput.ConvertToInt(Console.ReadLine().Trim()); if (weapon.Durability > 0) { Console.WriteLine(StandardMessages.DisplayCreaterNumberError()); error = true; } else { error = false; } } while (error == true); do { Console.Write("Enter the damage of the weapon: "); weapon.Damage = ConvertInput.ConvertToInt(Console.ReadLine().Trim()); if (weapon.Damage > 0) { Console.WriteLine(StandardMessages.DisplayCreaterNumberError()); error = true; } else { error = false; } } while (error == true); outputFile.Write($"{weapon.Name},{weapon.Description},{weapon.Durability},{weapon.Damage}"); outputFile.Close(); } catch (Exception ex) { Console.WriteLine(ex); } World.weapons.Add(weapon); Console.WriteLine("Weapon created successfully!"); }
public static void DisplayCustomerInformation(List <Customer> inputList) { //Clear current screen Console.Clear(); Console.WriteLine(StandardMessages.CustomerInformationTitle()); //Loop to display customer information foreach (var Customer in inputList) { Console.WriteLine($"Name: {Customer.Name}\nCustomer# {Customer.CustomerNumber}\nAddress: {Customer.Address}\nPhone Number: {Customer.PhoneNumber}\n" + $"Mail Preference: {(Customer.MailingListOption ? "Yes" : "No")}\n--------------------------------\nPress Enter for Main Menu"); } Console.ReadLine(); }
public static void MoveWest(ref int positionV, ref int positionH, Room[,] rooms) { //TODO Fix code to move west if (positionH != 0) { positionH = positionH - 1; Console.WriteLine(StandardMessages.RoomMove() + rooms[positionV, positionH].Name);; } else { Console.WriteLine("You can't move further west."); } }
public static void MoveSouth(ref int positionV, ref int positionH, Room[,] rooms) { //TODO Fix code to move south if ((positionV == 0 && positionH == 2) || (positionV == 1 && positionH == 0) || (positionV == 2 && positionH == 2) || (positionV == 3 && positionH == 0)) { positionV++; Console.WriteLine(StandardMessages.RoomMove() + rooms[positionV, positionH].Name); } else { Console.WriteLine("You aren't near any stairs and cannot go down to the next floor."); } }
public static bool Validate(Person person) { if (string.IsNullOrWhiteSpace(person.FirstName)) { StandardMessages.DisplayValidationError("first"); return(false); } if (string.IsNullOrWhiteSpace(person.LastName)) { StandardMessages.DisplayValidationError("last"); return(false); } return(true); }
public static void CreateMob() { Mob mob = new Mob(); bool error = false; try { StreamWriter outputFile = File.AppendText(@"../../../TextAdventureLib/Docs/Monsters.csv"); Console.Write("Enter the name of the mob: "); mob.Name = Console.ReadLine().Trim(); do { Console.Write("Enter the health of the mob: "); mob.Health = ConvertInput.ConvertToInt(Console.ReadLine().Trim()); if (mob.Health < 0) { error = true; Console.WriteLine(StandardMessages.DisplayCreaterNumberError()); } else { error = false; } } while (error == true); do { Console.Write("Enter the damage of the mob: "); mob.Damage = ConvertInput.ConvertToInt(Console.ReadLine().Trim()); if (mob.Damage < 0) { error = true; Console.WriteLine(StandardMessages.DisplayCreaterNumberError()); } else { error = false; } } while (error == true); outputFile.Write($"{mob.Name},{mob.Health},{mob.Damage}"); outputFile.Close(); } catch (Exception ex) { Console.WriteLine(ex); } World.mobs.Add(mob); Console.WriteLine("Mob created successfully!"); }
//Displays non-preferred customer data(note: Option is located in main program menu) public static void DisplayNotPreferredCustomerInformation(List <NonPreferredCustomer> inputList) { //Clear current screen Console.Clear(); Console.WriteLine(StandardMessages.NonPreferredCustomerInformationTitle()); //Loop to display customer information foreach (var nonPreferredCustomer in inputList) { Console.WriteLine($"Preferred Status: {(nonPreferredCustomer.CustomerStatus ? "Yes" : "No")}\nTransaction#: {nonPreferredCustomer.TransactionNumber}" + $"\n--------------------------------\n"); } Console.WriteLine(StandardMessages.DisplayEnterMessage()); Console.ReadLine(); }
static void Main(string[] args) { bool exit = false; List <Employee> age = new List <Employee>(); do { Console.WriteLine(StandardMessages.Menu()); switch (Console.ReadLine()) { case "1": Console.WriteLine(StandardMessages.AskForName()); Console.ReadLine(); break; case "2": Console.WriteLine(StandardMessages.AskForPhoneNumber()); Console.ReadLine(); break; case "3": Console.WriteLine(StandardMessages.AskForAge()); Console.ReadLine(); break; case "4": Console.WriteLine(StandardMessages.DisplayEmployee()); //Console.WriteLine(); Console.ReadLine(); break; case "5": Console.WriteLine(StandardMessages.DisplayAverageAge()); Console.WriteLine(Employee.Count); break; case "6": exit = true; break; default: break; } } while (exit == false); }
public static void BuildACustomer(List <Customer> inputList, bool loop, string input) { //Clear current screen Console.Clear(); //Create customer object Customer output = new Customer(); Console.WriteLine(StandardMessages.EnterCustomerInformationTitle()); //Get customer name Console.Write(StandardMessages.EnterCustomerName()); output.Name = Console.ReadLine(); //Get customer ID# Console.Write(StandardMessages.EnterCustomerIDNumber()); output.CustomerNumber = Console.ReadLine(); //Get customer address Console.Write(StandardMessages.EnterCustomerAddress()); output.Address = Console.ReadLine(); //Get customer phone number Console.Write(StandardMessages.EnterCustomerPhoneNumber()); output.PhoneNumber = Console.ReadLine(); do { //Get customers mailing preference Console.Write("Do you wish to be on the mailing list yes/no? ==> "); input = Console.ReadLine().ToLower(); //Decision structure for mailing preference if (input == "yes" || input == "y") { output.MailingListOption = true; loop = true; } else if (input == "no" || input == "n") { output.MailingListOption = false; loop = true; } else { Console.WriteLine(StandardMessages.DisplayInvalidChoice()); Console.ReadLine(); } } while (loop == false); inputList.Add(output); }
public static bool Validate(Person user) { // Checks to be sure the first and last names are valid if (string.IsNullOrWhiteSpace(user.FirstName)) { StandardMessages.DisplayErrorMessage("first name"); return(false); } if (string.IsNullOrWhiteSpace(user.LastName)) { StandardMessages.DisplayErrorMessage("last name"); return(false); } return(true); }
public static void SelectPlayerRace(Character player, bool characterLoop, ConsoleKeyInfo keyboard) { Console.Clear(); //Select player race do { Console.WriteLine(StandardMessages.DisplaySelectPlayerRace()); keyboard = Console.ReadKey(); switch (keyboard.Key) { case ConsoleKey.D1: case ConsoleKey.NumPad1: player.PlayerRace = "Human"; characterLoop = true; break; case ConsoleKey.D2: case ConsoleKey.NumPad2: player.PlayerRace = "Elf"; characterLoop = true; break; case ConsoleKey.D3: case ConsoleKey.NumPad3: player.PlayerRace = "Dwarf"; characterLoop = true; break; case ConsoleKey.D4: case ConsoleKey.NumPad4: player.PlayerRace = "Wizard"; characterLoop = true; break; case ConsoleKey.Escape: characterLoop = true; break; default: Console.WriteLine(StandardMessages.DisplayInvalidOption()); break; } Console.Clear(); } while (characterLoop == false); }
static void Main(string[] args) { //Setinel to control loop bool menuLoop = false; //Get input from user string input; //Create objects RetailItemLibrary.Items jackets = new RetailItemLibrary.Items("Jackets", 12, 59.05m); RetailItemLibrary.Items jeans = new RetailItemLibrary.Items("Jeans", 40, 34.95m); RetailItemLibrary.Items shirts = new RetailItemLibrary.Items("Shirts", 20, 24.95m); do { //Displays main menu Console.Write(StandardMessages.DisplayMainMenu()); //Controls the process flow of the menu input = Console.ReadLine(); switch (input) { case "1": //Display retail items list Console.WriteLine("\n\n*Retail Item List*"); Console.WriteLine(StandardMessages.DisplayRetailItems(jackets.Description, jackets.UnitsOnHand, jackets.Price)); Console.WriteLine(StandardMessages.DisplayRetailItems(jeans.Description, jeans.UnitsOnHand, jeans.Price)); Console.WriteLine(StandardMessages.DisplayRetailItems(shirts.Description, shirts.UnitsOnHand, shirts.Price)); Console.WriteLine(StandardMessages.ReturnToMainMenu()); Console.ReadLine(); break; case "2": //Exit main program menuLoop = true; break; default: //Displays invalid choice Console.WriteLine(StandardMessages.DisplayInvalidChoice()); Console.WriteLine(StandardMessages.ReturnToMainMenu()); Console.ReadLine(); break; } //Clears current screen Console.Clear(); } while (menuLoop == false); }
public static void CreateCar(Car thisCar) { Console.WriteLine("Let's build a car!"); Console.WriteLine("What is the car's year?: "); thisCar.Year = StandardMessages.MakeInt(Console.ReadLine()); if (thisCar.Year < 1900) { Console.WriteLine($"{thisCar.Year} is not a valid year. Please try again."); } else { Console.WriteLine("What is the car's make?: "); thisCar.Make = Console.ReadLine(); Console.WriteLine("Your car has been created!"); Console.WriteLine($"Year: {thisCar.Year} \nMake: {thisCar.Make}"); } }
static void Main(string[] args) { StandardMessages.WelcomeMessage(); Person user = PersonDataCapture.Capture(); bool isUserValid = PersonalValidator.Validate(user); if (isUserValid == false) { StandardMessages.EndApplication(); return; } AccountGenerator.CreateAccount(user); StandardMessages.EndApplication(); }
public static void SelectPlayerClass(Character player, bool characterLoop, ConsoleKeyInfo keyboard) { //Select player class do { Console.Clear(); Console.WriteLine(StandardMessages.DisplaySelectPlayerClass()); keyboard = Console.ReadKey(); switch (keyboard.Key) { case ConsoleKey.D1: case ConsoleKey.NumPad1: player.PlayerClass = "Warrior"; characterLoop = true; break; case ConsoleKey.D2: case ConsoleKey.NumPad2: player.PlayerClass = "Mage"; characterLoop = true; break; case ConsoleKey.D3: case ConsoleKey.NumPad3: player.PlayerClass = "Thief"; characterLoop = true; break; case ConsoleKey.D4: case ConsoleKey.NumPad4: player.PlayerClass = "Cleric"; characterLoop = true; break; case ConsoleKey.Escape: characterLoop = true; break; default: Console.WriteLine(StandardMessages.DisplayInvalidOption()); break; } Console.Clear(); } while (characterLoop == false); }
public static bool LoginPlayer(List <Player> inputList) { StreamReader inputfile; string input, password, name; string[] tokens; Player thisPlayer = new Player(); try { Console.Write(StandardMessages.GetPlayerName()); name = Console.ReadLine(); inputfile = File.OpenText($@"../../../TextAdventureLib/Players/{name}.csv"); input = inputfile.ReadLine(); tokens = input.Split(','); Console.Write(StandardMessages.GetPlayerPassword()); password = Console.ReadLine(); if (password.Equals(tokens[2])) { thisPlayer.Name = tokens[0]; thisPlayer.Health = int.Parse(tokens[1]); thisPlayer.Password = tokens[2]; thisPlayer.Class = tokens[3]; thisPlayer.Race = tokens[4]; thisPlayer.Admin = bool.Parse(tokens[5]); inputList.Add(thisPlayer); inputfile.Close(); return(true); } else { Console.WriteLine(StandardMessages.DisplayPasswordError()); return(false); } } catch (Exception ex) { Console.WriteLine(StandardMessages.DisplayReturnPlayerError()); return(false); } }
static void Main(string[] args) { // Initial new list of people List <Person> people = new List <Person>(); // Main method controls the flow of the program using the for loop for (int i = 0; i < 1; i++) { people.Add(PersonDataCapture.Capture()); } // Iterate over the result printing the standard message foreach (Person person in people) { StandardMessages.OutputMessage(person.FirstName, person.LastName); } StandardMessages.EndApplication(); }
public static void CreateNameAndPassword(Player player, bool characterLoop) { Console.Clear(); //Create user name Console.Write("Enter your name ==> "); string playerName = Console.ReadLine(); player.Name = playerName; do { //Create Password Console.WriteLine(StandardMessages.DisplayPasswordCreationInformation()); Console.Write("Enter your Password ==> "); string passWord1 = Console.ReadLine(); player.Password = passWord1; Console.Write("Reenter your Password ==> "); string passWord2 = Console.ReadLine(); //Decision structure to confirm password guidelines if (passWord1 != passWord2) { Console.WriteLine("Passwords do not match!"); player.Password = "******"; } else if (passWord1.Length < 8) { Console.WriteLine("Password is not long enough!"); player.Password = "******"; } else if (passWord1.Length > 15) { Console.WriteLine("Password is to long!"); player.Password = "******"; } else { Console.WriteLine("Great Job! Press enter to continue."); characterLoop = true; } Console.ReadLine(); Console.Clear(); } while (characterLoop == false); }
static void Main(string[] args) { bool exit = false, loginSuccess; Player thisPlayer = new Player(); do { Console.WriteLine(StandardMessages.Menu()); switch (Console.ReadLine()) { case "1": thisPlayer = BuildPlayer.BuildAPlayer(); PlayGame.Game(thisPlayer); Console.WriteLine(""); break; case "2": List <Player> players = new List <Player>(); loginSuccess = ReturningPlayer.LoginPlayer(players); if (loginSuccess == true) { thisPlayer = players[0]; PlayGame.Game(thisPlayer); } Console.WriteLine(""); break; case "3": exit = true; break; default: Console.WriteLine(StandardMessages.MenuError()); Console.WriteLine(""); break; } } while (exit == false); }