Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.28 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Banka
  8. {
  9. class Program
  10. {
  11. public static List<Account> ListOfAccounts = new List<Account>();
  12. public static int GlobalCounter = 0;
  13.  
  14. static void Main(string[] args)
  15. {
  16. Console.WriteLine("Welcome to our bank!");
  17. Console.WriteLine("1 - Make new account");
  18. Console.WriteLine("2 - Operations");
  19. Console.WriteLine("3 - Exit");
  20. while( true )
  21. {
  22. int unos = Convert.ToInt32(Console.ReadLine());
  23. if (unos == 3) break;
  24. else if( unos==1 )
  25. {
  26. Console.WriteLine("Name: ");
  27. string Name = Console.ReadLine();
  28. Console.WriteLine("Adress: ");
  29. string Adress = Console.ReadLine();
  30. Console.WriteLine("Phone");
  31. string Phone = Console.ReadLine();
  32. Console.WriteLine("Initial Amont: ");
  33. int InitialAmount = Convert.ToInt32(Console.ReadLine());
  34. Console.WriteLine("Password: ");
  35. string Password = Console.ReadLine();
  36. Console.WriteLine("Re-type Password: ");
  37. string Password2 = Console.ReadLine();
  38.  
  39. Account a = new Account(Name, Adress, Phone, InitialAmount, Password);
  40. ListOfAccounts.Add(a);
  41. }
  42. else if(unos==2)
  43. {
  44. Console.WriteLine("Enter your account number:");
  45. int RedniBroj = Convert.ToInt32(Console.ReadLine());
  46. while (true)
  47. {
  48.  
  49. if (RedniBroj < ListOfAccounts.Count()) break;
  50. else
  51. {
  52. Console.WriteLine("Account number is not valid. Please type again.");
  53. RedniBroj = Convert.ToInt32(Console.ReadLine());
  54. }
  55. }
  56. Console.WriteLine("Enter your password");
  57. static string Password = Console.ReadLine();
  58. Account a = ListOfAccounts[RedniBroj - 1];
  59. public static bool SucessLogin = true;
  60. if (a.Password != Password)
  61. {
  62. Console.WriteLine("Wrong password. Please try again.");
  63. static string Password2 = Console.ReadLine();
  64. if (a.Password != Password2)
  65. {
  66. SucessLogin = false;
  67. Console.WriteLine("Wrong password. You have one more try:");
  68. static string Password3 = Console.ReadLine();
  69. if (a.Password != Password3)
  70. {
  71. "Your account is blocked. You must call the bank imeadiately."
  72. }
  73. else SucessLogin=true;
  74. }
  75. else
  76. {
  77. SucessLogin = true;
  78. }
  79. }
  80. else if (SucessLogin==true )
  81. {
  82. Console.WriteLine("Select operation to process");
  83. Console.WriteLine("1 - Change password");
  84. Console.WriteLine("2 - Deposit money");
  85. Console.WriteLine("3 - Withdraw money");
  86. Console.WriteLine("4 - Print");
  87. Console.WriteLine("5 - Exit menu");
  88. int Operation = Convert.ToInt32(Console.ReadLine());
  89. switch
  90. {
  91. case 1:
  92. while(true)
  93. {
  94. Console.WriteLine("Type your new password");
  95. static string NewPassword1 = Console.ReadLine();
  96. Console.WriteLine("Retype your new password");
  97. static string NewPassword2 = Console.ReadLine();
  98. if (NewPassword1 != NewPassword2) Console.WriteLine("They do not match.Process will start from beggining")
  99. else
  100. {
  101. a.Password = NewPassword1;
  102. break;
  103. }
  104. }
  105. break;
  106. case 2:
  107. Console.WriteLine("Amount: ");
  108. int amount = Convert.ToInt32(Console.ReadLine());
  109. a.Balance += amount;
  110. Console.WriteLine("Operation Successful");
  111. break;
  112. case 3:
  113. Console.WriteLine("Amount:");
  114. int amount = Convert.ToInt32(Console.ReadLine());
  115. a.Balance -= amount;
  116. Console.WriteLine("Operation Successful");
  117. break;
  118. case 4:
  119. Console.WriteLine("Name: ",a.Name);
  120. Console.WriteLine("Adress: ",a.Adress);
  121. Console.WriteLine("Balance: ", a.Balance, " KM");
  122. Console.WriteLine("Account number: ",RedniBroj );
  123. break;
  124. case 5:
  125. Console.WriteLine("Good Bye");
  126. public static bool Exit = true;
  127. break;
  128. if(Exit) break;
  129. }
  130. }
  131. }
  132. }
  133.  
  134. }
  135. }
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement