public void AddingJokes() { Console.WriteLine("Write the joke to be added:"); string joke = Console.ReadLine(); joker.AddJoke(joke); }
public void Start() { while (true) { Console.WriteLine("Commands:"); Console.WriteLine(" 1 - add a joke"); Console.WriteLine(" 2 - draw a joke"); Console.WriteLine(" 3 - list jokes"); Console.WriteLine(" X - stop"); string command = Console.ReadLine(); if (command == "X") { break; } if (command == "1") { Console.WriteLine("Write the joke to be added:"); string joke = Console.ReadLine(); manager.AddJoke(joke); } else if (command == "2") { Console.WriteLine("Drawing a joke."); string joke = manager.DrawJoke(); Console.WriteLine(joke); } else if (command == "3") { Console.WriteLine("Printing the jokes."); manager.PrintJokes(); } } }
public static void Main(string[] args) { JokeManager manager = new JokeManager(); manager.AddJoke("What is red and smells of blue paint? - Red paint."); manager.AddJoke("What is blue and smells of red paint? - Blue paint."); Console.WriteLine("Drawing jokes:"); for (int i = 0; i < 5; i++) { Console.WriteLine(manager.DrawJoke()); } Console.WriteLine(""); Console.WriteLine("Printing jokes:"); manager.PrintJokes(); }
public void Start() { Console.WriteLine("What a joke!"); while (true) { Console.WriteLine("Commands:"); Console.WriteLine(" 1 - add a joke"); Console.WriteLine(" 2 - draw a joke"); Console.WriteLine(" 3 - list jokes"); Console.WriteLine(" X - stop"); string command = Console.ReadLine(); if (command == "X") { break; } if (command == "1") { Console.WriteLine("Write the joke to be added:"); string joke = Console.ReadLine(); //jokes.Add(joke); jokes.AddJoke(joke); } else if (command == "2") { Console.WriteLine("Drawing a joke."); /*if (jokes.Count == 0) * { * Console.WriteLine("Jokes are in short supply."); * } * else * { * Random draw = new Random(); * int index = draw.Next(0, jokes.Count); * Console.WriteLine(jokes[index]); * }*/ Console.WriteLine(jokes.DrawJoke()); } else if (command == "3") { Console.WriteLine("Printing the jokes."); /*foreach (string joke in jokes) * { * Console.WriteLine(joke); * }*/ jokes.PrintJokes(); } } }
public void Start() { //List<string> jokes = new List<string>(); //Console.WriteLine("What a joke!"); while (true) { Console.WriteLine("Commands:"); Console.WriteLine(" 1 - add a joke"); Console.WriteLine(" 2 - draw a joke"); Console.WriteLine(" 3 - list jokes"); Console.WriteLine(" X - stop"); string command = Console.ReadLine(); if (command == "X" || command == "x") { break; //return; } /*int score = Convert.ToInt32(command); * if (score < 3 || score > 0) * { * continue; * }*/ if (command == "1") { Console.WriteLine("Write the joke to be added:"); string joke = Console.ReadLine(); manager.AddJoke(joke); } if (command == "2") { Console.WriteLine("Drawing a joke."); string joke = manager.DrawJoke(); Console.WriteLine(joke); } if (command == "3") { Console.WriteLine("Printing the jokes."); manager.PrintJokes(); } } }
public void Start() { string userInput; while (true) { Console.WriteLine("Commands:"); Console.WriteLine("1 - add a joke"); Console.WriteLine("2 - draw a joke"); Console.WriteLine("3 - list jokes"); Console.WriteLine("X - stop"); userInput = Console.ReadLine(); if (userInput == "1") { Console.WriteLine("Write the joke to be added:"); userInput = Console.ReadLine(); manager.AddJoke(userInput); } else if (userInput == "2") { Console.WriteLine(manager.DrawJoke()); } else if (userInput == "3") { Console.WriteLine("Printing the jokes."); manager.PrintJokes(); } else if (userInput == "X") { break; } else { } } }
public void Start() //Starts the functions in the program { while (true) //Starts the program loop { Console.WriteLine("Commands:" + "\n" + "1 - add a joke" + "\n" + "2 - draw a joke" + "\n" //Prints out the possible commands for the user to see + "3 - list jokes" + "\n" + "X - stop"); string input = Console.ReadLine(); //User input if (input == "X" || input == "x") { break; } if (input == "1") { Console.WriteLine("Write the joke to be added:"); jokeManager.AddJoke(Console.ReadLine()); //Adds whatever the user inputs into the list of jokes in JokeManager } else if (input == "2") { Console.WriteLine("Drawing a joke."); Console.WriteLine(jokeManager.DrawJoke()); //Draws a random joke from the list } else if (input == "3") { Console.WriteLine("Printing jokes."); //Prints out all the jokes in the list jokeManager.PrintJokes(); } } }