public static void ComputerTalk() { string numToConvertStr; string result; bool continueConverting = true; while (continueConverting == true) { Console.Write("Input a Number : "); numToConvertStr = Console.ReadLine(); // user enters number to convert to bionary int numToConvert = Convert.ToInt32(numToConvertStr); //creates an int converting the number the user entered to int32 result = ""; // result string while (numToConvert > 1) // loop through and create the binary string { int remainder = numToConvert % 2; //finding the remainder of the int to convert result = Convert.ToString(remainder) + result; //setting the string result to the new value ... then adding every value after to the front of the string numToConvert /= 2; // dividing the number to convert in half to restart sequence } result = Convert.ToString(numToConvert) + result; Console.WriteLine(numToConvertStr + " In Binary is: {0}", result); Console.WriteLine(""); Console.Write("Would you like to continue converting numbers? Y/N"); // asking user if they would like to convert another number string continueBinary = Console.ReadLine(); if (continueBinary == "y" || continueBinary == "Y") { Console.Clear(); continueConverting = true; } else if (continueBinary == "n" || continueBinary == "N") { Console.Clear(); continueConverting = false; OSMain.Main(); } } }
public static void MainMenu() { Console.WriteLine("Select an option to continue: "); Console.WriteLine("\n\n(1) Display Vending Machine Items"); Console.WriteLine("(2) Purchase"); Console.WriteLine("(3) Exit"); Console.Write("\nChoice: "); string userChoice = Console.ReadLine(); if (userChoice == "1") { Console.Clear(); //ListInventory(Item.Inventory); Console.WriteLine(ListInventory(Item.Inventory)); Console.Write("\n\n To return to Main Menu press enter."); string returntoMenu = Console.ReadLine(); if (returntoMenu != null) { Console.Clear(); MainMenu(); } } else if (userChoice == "2") { Console.Clear(); LogGenerator.Log($"-----------------Log Start ({DateTime.Now})----------------"); Transaction.PurchaceMenu(); } else if (userChoice == "3") { Console.Clear(); OSMain.Main(); } else { Console.Clear(); OSMain.Main(); } }
public static void NumberGameGame() { int speed = 5; var randomInt = new Random(); string gameMessage = "Let's play a guessing game, set the highest number."; OSMain.SkyNetTyping(gameMessage, speed); bool properGuess = false; int upperValue = 0; int numberToGuess = 0; while (!properGuess) { try { upperValue = int.Parse(Console.ReadLine()); numberToGuess = randomInt.Next(0, upperValue); properGuess = true; if (upperValue > 9000) { string big = " IT'S OVER 9000!!!!!\n\n"; OSMain.SkyNetTyping(big, speed); } } catch { string badUperNumber = "That was not a real number please type a number."; OSMain.SkyNetTyping(badUperNumber, speed); } } // BEFORE TRY CATCH //int upperValue = int.Parse(Console.ReadLine()); //int numberToGuess = randomInt.Next(0, upperValue); //Console.WriteLine($"Guess a number between 0 and {upperValue}"); string guessingMessage = $"Guess a number between 0 and {upperValue}: "; OSMain.SkyNetTyping(guessingMessage, speed); bool Continue = true; while (Continue == true) { string userGuess = Console.ReadLine(); try { int guess = int.Parse(userGuess); /* * if (upperValue > 9000) * { * string big = " IT'S OVER 9000!!!!!!!"; * SkyNetTyping(big, speed); * } */ if (guess < numberToGuess) { Console.WriteLine("WRONG!"); string low = "TOO LOW\n"; OSMain.SkyNetTyping(low, speed); } else if (guess > numberToGuess) { Console.WriteLine("WRONG!"); string high = "TOO HIGH "; OSMain.SkyNetTyping(high, speed); } if (guess == numberToGuess) { Console.WriteLine("CORRECT!"); string playAgain = "Would you like to play agin? (Y/N)"; OSMain.SkyNetTyping(playAgain, speed); string userPlayAgain = Console.ReadLine(); if (userPlayAgain == "Y" || userPlayAgain == "y") { Console.Clear(); NumberGame.NumberGameGame(); //Continue = true; } else { Continue = false; Console.Clear(); OSMain.Main(); } } else { Console.WriteLine("Guess again... or if you want to quit type 'q'"); Continue = true; } } catch { if (userGuess == "q") { Continue = false; break; } Console.WriteLine("Please enter a real number. "); } //Console.WriteLine("GAME OVER!"); //Thread.Sleep(1000); } Console.Clear(); OSMain.Main(); }