public static void Check() { bool isSafe = true; int pressure; UserLib.WriteTitle("Pressure Check"); while (isSafe) { pressure = UserLib.GetInt("Enter Pressure > "); if (pressure < LOW_PRESSURE) { Console.WriteLine("Pressure is too low!"); } else if ((pressure >= LOW_PRESSURE) && (pressure <= HIGH_PRESSURE)) { Console.WriteLine("Pressure is Normal!"); } else if ((pressure > HIGH_PRESSURE) && (pressure < DANGEROUS_PRESSURE)) { Console.WriteLine("Pressure is too high!"); } else if (pressure >= DANGEROUS_PRESSURE) { Console.WriteLine("Pressure is DANGEROUS!"); isSafe = false; } } Console.WriteLine("Shut Down!!!"); }
/// <summary> /// This method will ask the user to enter the number of miles /// and it will convert that value to feet and display the /// result to the user /// </summary> public static void TestMilesToFeet() { UserLib.WriteTitle("Task 4.1 Miles -> Feet"); miles = UserLib.GetDouble("Please enter the number of miles > "); feet = DistanceConverter.MilesToFeet(miles); Console.WriteLine("The number of feet = " + feet.ToString("#.##")); }
/// <summary> /// ******************************************************* /// This method will End the Game with the overall Winner's name /// ******************************************************* /// </summary> private static void EndGame() { Console.Clear(); UserLib.WriteTitle(Title); Console.WriteLine("The overall winner is " + Game.Winner); }
/// <summary> /// This method will ask the user to enter the number of feet /// and it will convert that value to miles and display the /// result to the user /// </summary> public static void TestFeetToMiles() { UserLib.WriteTitle("Task 4.1 Feet -> Miles"); feet = UserLib.GetDouble("Please enter the number of feet > "); miles = DistanceConverter.FeetToMiles(feet); Console.WriteLine("The number of miles = " + miles.ToString("#.##")); }
public static void Play() { bool won = false; bool lost = false; int diceNo1; int diceNo2; int total; UserLib.WriteTitle("Craps Game"); while (!won && !lost) { diceNo1 = Dice.Throw(); diceNo2 = Dice.Throw(); total = diceNo2 + diceNo1; Console.WriteLine("Total = " + total); Console.ReadKey(); if ((total == 2) || (total == 3) || (total == 12)) { lost = true; Console.WriteLine("You have lost!!!"); } } }
public static void BuyWeapons() { decimal money; decimal price; int count = 0; decimal total = 0; decimal moneyLeft = 0; UserLib.WriteTitle("Game Store"); money = UserLib.GetDecimal("Enter the amount of money you have to spend > "); for (count = 1; count <= 6; count++) { price = UserLib.GetDecimal("Enter the price of item " + count + " > "); total += price; moneyLeft = money - total; Console.WriteLine("Money Left = " + moneyLeft.ToString("c")); } Console.WriteLine(); Console.WriteLine("You have bought " + count + " weapons"); Console.WriteLine("Total Cost = " + total.ToString("c")); Console.WriteLine("Money Left = " + moneyLeft.ToString("c")); }
public static void Load() { double weight = 0; double totalWeight = 0; int count = 0; decimal moneyTaken = 0; bool isFull = false; UserLib.WriteTitle("Passenger Ferry"); while (!isFull) { count++; weight = UserLib.GetDouble("Enter next passenger weight > "); if (totalWeight + weight > MAX_WEIGHT) { Console.WriteLine("Max weight exceeded!"); Console.WriteLine("Passenger Rejected!"); isFull = true; count--; } else { Console.WriteLine("Passenger Accepted!"); moneyTaken += 100; totalWeight += weight; } } Console.WriteLine("Total Money = " + moneyTaken.ToString("c")); Console.WriteLine("Number of Passenger = " + count); Console.WriteLine("Total Weight = " + totalWeight.ToString("####")); }
public static void ShowName() { int x = 2, y = 10; ConsoleColor colour; String[] colorNames = ConsoleColor.GetNames(typeof(ConsoleColor)); string name; int count = 0; name = "Derek"; while (count < 10) { y = y + 1; UserLib.WriteTitle("Show Name"); Console.SetCursorPosition(x, y); Console.Write(name); Thread.Sleep(500); Console.Clear(); Console.BackgroundColor = (ConsoleColor)Enum.Parse(typeof(ConsoleColor), colorNames[count]); count++; } }
/// <summary> /// This method will ask the user to enter the number of miles /// and it will convert that value to feet and display the /// result to the user /// </summary> public void TestMilesToFeet() { UserLib.WriteTitle("Task 4.1 Miles -> Feet"); miles = UserLib.GetDouble("Please enter the number of miles > "); feet = converter.MilesToFeet(miles); Console.WriteLine("The number of feet = " + feet); }
public void InputValues() { UserLib.WriteTitle("Game Score"); player = UserLib.GetString("Your name > "); aliens = UserLib.GetInt("How many aliens have you killed > "); treasure = UserLib.GetInt("How much treasure have you found > "); hours = UserLib.GetInt("How many hours did you play > "); }
public void WriteChapter(int chapter) { UserLib.WriteTitle("Task 4.2 " + Title); Console.WriteLine("As I slowly opened the back door, I saw a \n" + Weapon + " lying on the floor. I called out \n" + Name + "'s name and followed the blood trail into \n" + "the next room. In the darkness I saw \n" + Name + " lying at a very sinister angle."); }
/// <summary> /// This is the main method that can be used to run an instance /// of this Tournament class /// </summary> public static void Main() { UserLib.WriteTitle("5.1 Tournament Scores"); Tournament myTournament = new Tournament(); myTournament.GetDetails(); myTournament.ShowDetails(); myTournament.ShowBest(); Console.ReadKey(); }
/// <summary> /// ******************************************************* /// This method will Get the Player's Choice /// ******************************************************* /// </summary> private static void GetPlayerChoice() { Console.Clear(); UserLib.WriteTitle(Title); Console.WriteLine("Turn no " + turn + " of " + MAXN_TURNS); string[] choices = new string[] { Game.SCISSORS, Game.PAPER, Game.STONE }; int choiceNo = UserLib.GetChoice(choices); Game.PlayerChoice = choices[choiceNo - 1]; Console.WriteLine(); }
//This method shows how many votes each song has public void Show() { Console.Clear(); UserLib.WriteTitle("Top Ten MP3"); int i = 0; foreach (string song in songs) { i++; Console.WriteLine("\tSong No " + i + " has " + " < " + votes[i - 1] + " > " + " votes " + song); //Console.WriteLine("\tTotal number of votes " + " < " + votes[i] + " > "); } }
/// <summary> /// This method will repeatedly ask the user to vote for one /// of the top ten songs. It will store that vote in a votes /// array. /// </summary> public void GetVote() { int songNo; UserLib.WriteTitle("Top 10 MP3 Songs"); do { songNo = UserLib.GetInt("Choose 1 - " + songs.Count() + " > "); if (songNo > 0 && songNo <= MAXN_SONGS) { votes[songNo - 1]++; Show(); } else { Console.WriteLine(); Console.WriteLine("Song " + songNo + "does not exists!"); } Show(); } while (songNo != 0); }
public static void TestFeetToMiles() { UserLib.WriteTitle("Task 4.1 Feet -> Miles"); }
/// <summary> /// ******************************************************* /// This method will Start the Game /// ******************************************************* /// </summary> private static void StartGame() { UserLib.WriteTitle(Title); Game.Start(); playerName = UserLib.GetString("Please enter your name > "); }