Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace unnamed_project_idk
  5. {
  6. class Program
  7. {
  8. static void Main(string[] args)
  9. {
  10. Phonebook();
  11. }
  12. static void Phonebook()
  13. {
  14. Console.ForegroundColor = ConsoleColor.Magenta;
  15. Console.WriteLine("Phonebook, add contacts, whats the contact name..", Console.ForegroundColor);
  16. string contactname = Console.ReadLine();
  17.  
  18. List<string> contacts = new List<string>();
  19. Console.WriteLine("Whats the contacts phone number..");
  20. int contactnumber = Convert.ToInt32(Console.ReadLine());
  21. contacts.Add($"{contactname} at number {contactnumber}");
  22. Console.WriteLine("Would you like to see what contacts you have so far?");
  23.  
  24. string viewc = Console.ReadLine();
  25. if(viewc == "yes")
  26. {
  27. foreach(var contact in contacts)
  28. {
  29. Console.WriteLine(contact);
  30. }
  31. }
  32. else if(viewc == "no")
  33. {
  34. Console.WriteLine("Okey");
  35. }
  36. else
  37. {
  38. Console.WriteLine("Please type either yes or no");
  39. }
  40. KeepGoing();
  41. }
  42. static void KeepGoing()
  43. {
  44. Console.WriteLine("Would you like to add more contacts?");
  45. string[] answers = {"yes", "yeah"};
  46. string response = Console.ReadLine();
  47.  
  48. bool canswer = Array.Exists(answers, answer => answer.Equals(response));
  49. if(canswer)
  50. {
  51. Phonebook();
  52. }
  53. else if(response == "no")
  54. {
  55. Console.WriteLine("C'ya nerd");
  56. }
  57. else
  58. {
  59. Console.WriteLine("Please either type yes, yeah, or no");
  60. }
  61. }
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement