Advertisement
Guest User

enigma machine

a guest
Oct 19th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. namespace EnigmaMachine
  9. {
  10. class Driver
  11. {
  12. static void Main(string[] args)
  13. {
  14. GetMenu menu = new GetMenu();
  15. GetMenu.DisplayMenu();
  16.  
  17. }
  18.  
  19. }
  20. class GetMenu
  21. {
  22. static Boolean exit;
  23.  
  24. public static void DisplayMenu()
  25. {
  26. while(!exit)
  27. {
  28. ReadMenu();
  29. int choice = ReceiveInput();
  30. PerformAction(choice);
  31. }
  32. }
  33. public static void ReadMenu()
  34. {
  35. String line;
  36. try
  37. {
  38. StreamReader sr = new StreamReader("H:\\MainScreen.txt");
  39. line = sr.ReadLine();
  40. while(line != null)
  41. {
  42. Console.WriteLine(line);
  43. line = sr.ReadLine();
  44. }
  45. sr.Close();
  46. Console.ReadLine();
  47. }
  48. catch (Exception e)
  49. {
  50. Console.WriteLine("Exception: " + e.Message);
  51. }
  52. finally
  53. {
  54. Console.WriteLine("Executing finally block.");
  55. }
  56. }
  57. private static int ReceiveInput()
  58. {
  59. int choice = -1;
  60. while(choice < 0 || choice > 7)
  61. {
  62. try
  63. {
  64. choice = Int32.Parse(Console.ReadLine());
  65. }
  66. catch (FormatException e)
  67. {
  68. Console.WriteLine("Invalid selection. Please try again.");
  69. }
  70. }
  71. return choice;
  72. }
  73. private static void PerformAction(int choice)
  74. {
  75. switch(choice)
  76. {
  77. case 0:
  78. exit = true;
  79. Console.WriteLine("Thank you for using the Enigma Machine.");
  80. break;
  81. case 1:
  82. }
  83. }
  84. }
  85. class Interpreter
  86. {
  87.  
  88. }
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement