public static void putMoney(Client client, List <Client> lstClients) { Console.WriteLine("Podaj kwotę do wpłaty"); client.accountBalance += Double.Parse(Console.ReadLine()); client.accountBalance = Math.Round(client.accountBalance, 2); CheckState(client); lstClients[clientIndex] = client; ClientDB.SaveList(lstClients); }
public static void getMoney(Client client, List <Client> lstClients) { double getBackMoney; Console.WriteLine("Podaj kwotę do wypłaty"); getBackMoney = Double.Parse(Console.ReadLine()); if (getBackMoney < client.accountBalance) { client.accountBalance -= getBackMoney; client.accountBalance = Math.Round(client.accountBalance, 2); CheckState(client); lstClients[clientIndex] = client; ClientDB.SaveList(lstClients); } else { Console.WriteLine("Brak odpowiednich środków do wykonania transakcji"); } }
public static void Main(string[] args) { List <Client> clients = new List <Client>(); clients = ClientDB.getList(); Client client = new Client(); bool exit = false; do { Console.Clear(); if (!Atm.isLogged) { Console.WriteLine("Zaloguj"); client = Atm.LogIn(clients); } else { Console.WriteLine("Menu:"); Console.WriteLine("1. Wyloguj"); Console.WriteLine("2. Wpłata pieniędzy"); Console.WriteLine("3. Wypłata pieniędzy"); Console.WriteLine("4. Stan konta"); Console.WriteLine("5. Zakończ"); int n = Convert.ToInt32(Console.ReadLine()); switch (n) { case 1: { if (Atm.isLogged) { Atm.Logout(); Console.WriteLine("Wylogowano"); } else { Console.WriteLine("Jesteś wylogowany"); } break; } case 2: { if (Atm.isLogged) { Atm.putMoney(client, clients); } else { Console.WriteLine("Nie jesteś zalogowany. \n" + "Zaloguj się aby wykonać transakcję"); } break; } case 3: { if (Atm.isLogged) { Atm.getMoney(client, clients); } else { Console.WriteLine("Nie jesteś zalogowany. \n" + "Zaloguj się aby wykonać transakcję"); } break; } case 4: { if (Atm.isLogged) { Atm.CheckState(client); Thread.Sleep(5000); } else { Console.WriteLine("Nie jesteś zalogowany. \n" + "Zaloguj się aby wykonać transakcję"); } break; } case 5: { exit = true; break; } default: { Console.WriteLine("nie ma takiej opcji"); Thread.Sleep(5000); break; } } } } while (!exit); }