Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace unnamed_project_idk
- {
- class Program
- {
- static void Main(string[] args)
- {
- Phonebook();
- }
- static void Phonebook()
- {
- Console.ForegroundColor = ConsoleColor.Magenta;
- Console.WriteLine("Phonebook, add contacts, whats the contact name..", Console.ForegroundColor);
- string contactname = Console.ReadLine();
- List<string> contacts = new List<string>();
- Console.WriteLine("Whats the contacts phone number..");
- int contactnumber = Convert.ToInt32(Console.ReadLine());
- contacts.Add($"{contactname} at number {contactnumber}");
- Console.WriteLine("Would you like to see what contacts you have so far?");
- string viewc = Console.ReadLine();
- if(viewc == "yes")
- {
- foreach(var contact in contacts)
- {
- Console.WriteLine(contact);
- }
- }
- else if(viewc == "no")
- {
- Console.WriteLine("Okey");
- }
- else
- {
- Console.WriteLine("Please type either yes or no");
- }
- KeepGoing();
- }
- static void KeepGoing()
- {
- Console.WriteLine("Would you like to add more contacts?");
- string[] answers = {"yes", "yeah"};
- string response = Console.ReadLine();
- bool canswer = Array.Exists(answers, answer => answer.Equals(response));
- if(canswer)
- {
- Phonebook();
- }
- else if(response == "no")
- {
- Console.WriteLine("C'ya nerd");
- }
- else
- {
- Console.WriteLine("Please either type yes, yeah, or no");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement