Пример #1
0
 static void Main(string[] args)
 {
     Bank first = new Bank();
     Account ein = new Account(0, 0000,100);
     Account one = new Account(1, 1111, 100);
     first.accounts.Add(ein);
     first.accounts.Add(one);
     first.CreateAccount(2222, 20000);
     //this tests that creataccount adds the account properly to accounts
     for (int x = 0; x < first.accounts.Count; x++)
         Console.WriteLine(first.accounts[x].accountNum);
     Console.ReadLine();
     //tests basic functions
     one.Deposit(1000);
     one.Deposit(1000);
     one.Withdraw(300);
     one.Deposit(1000);
     one.Withdraw(900);
     one.Deposit(10000);
     one.Withdraw(9998000);
     one.Deposit(1000);
     one.Withdraw(300);
     Console.ReadLine();
     // ATM test
     Atm zero = new Atm();
     zero.ExecuteInput(first);
     zero.ExecuteInput(first);
     zero.ExecuteInput(first);
     Console.ReadLine();
 }
Пример #2
0
        static void Main(string[] args)
        {
            string yourAccount = string.Empty;
            int    choice      = 0;
            int    Cnt         = 0;

            Atm atm = new Atm();

            do
            {
                Cnt++;
                Console.Write("계좌를 입력하세요 : ");
                yourAccount = Console.ReadLine();
            } while (atm.account != yourAccount && Cnt < 3);
            if (Cnt >= 3)
            {
                Console.WriteLine("Bye~~ Bye~~");
            }
            else
            {
                do
                {
                    atm.menu();

                    //메뉴 선택
                    choice = Convert.ToInt32(Console.ReadLine());

                    switch (choice)
                    {
                    case (int)MyEnum.e_balance:
                        atm.inquireBalance();
                        break;

                    case (int)MyEnum.e_deposit:
                        atm.inquireDeposit();
                        break;

                    case (int)MyEnum.e_withdraw:
                        atm.inquireWithdraw();
                        break;

                    case (int)MyEnum.e_history:
                        atm.inquireHistory();
                        break;

                    case (int)MyEnum.e_exit:
                        break;

                    default:
                        Console.WriteLine("1,2,3,4,0 중에 선택하세요");
                        break;
                    }
                } while (choice != 0);
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            Atm atm = new Atm("ATM Machine");

            Customer customer1  = new Customer("Bob Ross", 1234123412341234, 1256, 1000);
            Customer customer2  = new Customer("Nick Kannon", 2635412987456125, 2232, 2530);
            Customer customer3  = new Customer("Drake Bell", 6395462874695135, 2233, 250);
            Customer customer4  = new Customer("Jonah Hill", 3333222211115555, 0021, 360);
            Customer customer5  = new Customer("Janice Bing", 6599441588762003, 7498, 1200);
            Customer customer6  = new Customer("David Blain", 7748555003612594, 9874, 970);
            Customer customer7  = new Customer("Sofia Vergara", 6329566310048579, 0100, 720);
            Customer customer8  = new Customer("James Morrison", 3322550010336699, 6565, 660);
            Customer customer9  = new Customer("Nelly Furdado", 6996366332232552, 9874, 250);
            Customer customer10 = new Customer("Tylor Swift", 7845123265988502, 6647, 450);

            atm.AddUser(customer1);
            atm.AddUser(customer2);
            atm.AddUser(customer3);
            atm.AddUser(customer4);
            atm.AddUser(customer5);
            atm.AddUser(customer6);
            atm.AddUser(customer7);
            atm.AddUser(customer8);
            atm.AddUser(customer9);
            atm.AddUser(customer10);


            Console.WriteLine("Wellcome to the ATM app");



            Console.WriteLine("Please enter your card number");
            string cardNum = Console.ReadLine();

            Int64.TryParse(cardNum, out long cardNumber);
            Console.WriteLine("Enter your pin number");
            string pinNum = Console.ReadLine();

            Int32.TryParse(pinNum, out int pinNumber);
            Customer.IsCardAndPinValid(atm, cardNumber, pinNumber);


            //Customer.TransactionAction(atm);
        }
Пример #4
0
        static void Main(string[] args)
        {
            var atm = new Atm();

            var dataReader = new ConsoleDataReader();
            var dataWriter = new ConsoleDataWriter();
            var dataClear  = new ConsoleClear();
            var options    = new Options();
            var menu       = new Menu(dataReader, dataWriter, dataClear);

            Console.Write(Constants.ENTER_START_SUM_MESSAGE);
            var startSum = int.Parse(Console.ReadLine());

            atm.StartSum     = startSum;
            atm.Menu         = menu;
            atm.Menu.Options = options;

            bool showMenu = true;

            while (showMenu)
            {
                showMenu = atm.Menu.MainMenu(ref startSum);
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            var ATM = new Atm();

            ATM.Calculate(179);
        }
Пример #6
0
        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);
        }
Пример #7
0
        static void Main(string[] args)
        {
            Atm atm = new Atm();

            atm.Run();
        }
Пример #8
0
        static void Main()
        {
            Atm BankAutomat = new Atm();

            Console.Write("Hallo User, ich bin ein Geldautomat!\n\nBitte geben sie ihren Namen ein : ");
            // zuerst wird Console.ReadLine() ausgeführt und ein text von der Konsole gelesen
            // der rückgabewert der methode ist ein string. auf diesem string führen wir direkt
            // die methode ToLower() aus. Der rückgabewert davon in ein kleingeschriebener text
            // dieser zurückgegebene text wird in der variable userName abgelegt.
            string userName = Console.ReadLine().ToLower();

            Console.Write("Bitte geben sie ihren PIN ein: ");
            string userPinS = Console.ReadLine();
            ushort userPin;

            // versucht aus dem string userPinS einen ushort zu machen, falls es !nicht! klappt
            // wird es als true gewertet für das if. Das Ausrufezeichen ist dabei für die invertierung
            // zuständig. Der zweite test prüft ob der original-string alles andere als exakt 4 zeichen
            // enthält. Dadurch haben wir alle möglichen fehler getestet und gehen bei einem fehler
            // in das if rein.
            if (!ushort.TryParse(userPinS, out userPin) || userPinS.Length != 4)
            {
                Console.WriteLine("Die Eingabe entspricht nicht dem PIN format, bye!");
                return; // beendet die Main vorzeitig
            }

            // der letzte parameter wird im inlined stil befüllt. Es wird die Variable userBalance
            // erstellt und diese direkt als parameter übergeben.
            switch (BankAutomat.GetBalance(userName, userPin, out int userBalance))
            {
            case ATMError.NoError:
                Console.WriteLine("Ihr Kontostand beträgt " + userBalance);
                break;     // beendet den switch

            case ATMError.PinError:
            case ATMError.UserError:
                Console.WriteLine("Kommst hier nicht rein, du hacker!!");
                return;     // beendet die ganze Main

            default:
                Console.WriteLine("Der Gerät klappt irgendwie nischt...tschuligom");
                return;     // beendet die ganze Main
            }

            Console.WriteLine("Möchten Sie Geld abheben? [y/n]");

            ConsoleKey nutzerTaste = Console.ReadKey(true).Key; // liesst die gedrückte taste auf der tastatur aus

            if (nutzerTaste == ConsoleKey.Y)                    // ist die gedrückte taste die Y taste gewesen?
            {
                Console.WriteLine("Wieviel möchten sie abheben?");
                int convertedNumber;                                        // lagerplatz für die Zahl vom nutzer, falls die konvertierung geklappt hat
                if (!int.TryParse(Console.ReadLine(), out convertedNumber)) // versuchen die nutzereingabe in eine Zahl zu verwandeln. Wenn es nicht klappt wird das if ausgeführt (wegen dem ! )
                {
                    // wenn tryparse sagt das die konvertierung fehlschlägt
                    Console.WriteLine("Das war keine gültige Zahl. Ende!");
                    return; // beendet die Main
                }

                switch (BankAutomat.Withdraw(userName, userPin, convertedNumber))
                {
                case ATMError.NoError:
                    Console.WriteLine("Das Geld wurde abgebucht");
                    BankAutomat.GetBalance(userName, userPin, out int newBalance);
                    Console.WriteLine("Neuer Kontostand : " + newBalance);
                    break;

                case ATMError.PinError:
                case ATMError.UserError:
                    Console.WriteLine("Kommst hier nicht rein, du hacker!!");
                    return;

                case ATMError.BalanceError:
                    Console.WriteLine("Sie haben nicht genug Geld");
                    break;

                default:
                    Console.WriteLine("Der Gerät klappt irgendwie nischt...tschuligom");
                    return;     // beendet die ganze Main
                }
            }
            Console.WriteLine("Bye");
        }
Пример #9
0
        static void Main(string[] args)
        {
            TimeSpan ts1 = new TimeSpan(12, 00, 00);
            TimeSpan ts2 = new TimeSpan(18, 00, 00);

            TimeSpan ts3 = new TimeSpan(10, 00, 00);
            TimeSpan ts4 = new TimeSpan(17, 00, 00);

            TimeSpan ts5 = new TimeSpan(22, 00, 00);
            TimeSpan ts6 = new TimeSpan(12, 00, 00);

            TimeSpan ts7 = new TimeSpan(17, 00, 00);
            TimeSpan ts8 = new TimeSpan(01, 00, 00);

            var        atm1 = new Atm("ATM1", ts1, ts2);
            var        atm2 = new Atm("ATM2", ts3, ts4);
            var        atm3 = new Atm("ATM3", ts5, ts6);
            var        atm4 = new Atm("ATM4", ts7, ts8);
            List <Atm> a    = new List <Atm>();

            a.Add(atm1);
            a.Add(atm2);
            a.Add(atm3);
            a.Add(atm4);


            var d1  = new Distance("User starting point", "ATM1", 5);
            var d2  = new Distance("User starting point", "ATM2", 60);
            var d3  = new Distance("User starting point", "ATM3", 30);
            var d4  = new Distance("User starting point", "ATM4", 45);
            var d5  = new Distance("ATM1", "ATM2", 40);
            var d6  = new Distance("ATM1", "ATM4", 45);
            var d7  = new Distance("ATM2", "ATM3", 15);
            var d8  = new Distance("ATM3", "ATM1", 40);
            var d9  = new Distance("ATM3", "ATM4", 15);
            var d10 = new Distance("ATM4", "ATM2", 30);

            List <Distance> dist = new List <Distance>();

            dist.Add(d1);
            dist.Add(d2);
            dist.Add(d3);
            dist.Add(d4);
            dist.Add(d5);
            dist.Add(d6);
            dist.Add(d7);
            dist.Add(d8);
            dist.Add(d9);
            dist.Add(d10);


            DateTime      t1      = new DateTime(2020, 05, 23);
            DateTime      t2      = new DateTime(2018, 08, 15);
            DateTime      t3      = new DateTime(2019, 03, 20);
            var           c1      = new Credit("SILVER", 0.2, 4500, t1, 20000);
            var           c2      = new Credit("GOLD", 0.1, 3000, t2, 25000);
            var           c3      = new Credit("PLATINIUM", 0.0, 4000, t3, 3000);
            List <Credit> credits = new List <Credit>();

            credits.Add(c1);
            credits.Add(c2);
            credits.Add(c3);

            //define deadline date and time
            DateTime deadlinedate = new DateTime(2019, 03, 19);
            TimeSpan deadlinetime = new TimeSpan(14, 00, 00);

            //remove the atms that does not corespond as schedule
            if (compareTime(ts1, ts2, deadlinetime) == 0)
            {
                a.Remove(atm1);
            }
            if (compareTime(ts3, ts4, deadlinetime) == 0)
            {
                a.Remove(atm2);
            }
            if (compareTime(ts7, ts8, deadlinetime) == 0)
            {
                a.Remove(atm4);
            }

            //remove the cards that have expiration date before 19.03.2019
            if (date(t1, deadlinedate) == -1)
            {
                credits.Remove(c1);
            }
            if (date(t2, deadlinedate) == -1)
            {
                credits.Remove(c2);
            }
            if (date(t3, deadlinedate) == -1)
            {
                credits.Remove(c3);
            }
            Console.Write("The valid ATMs are:  ");
            foreach (var i in a)
            {
                Console.WriteLine(i.getName());
            }
            Console.WriteLine("The valid cards are:");
            foreach (var j in credits)
            {
                Console.WriteLine(j.getType());
            }

            //if the atm was removed but it is still in Distance class, it has to be removed, in order to have just valid distances
            foreach (var i in dist)
            {
                foreach (var j in a)
                {
                    if (!a.Contains(j))
                    {
                        if (i.getFrom() == j.ToString())
                        {
                            dist.Remove(i);
                        }
                    }
                }
            }
            foreach (var i in dist)
            {
                foreach (var j in a)
                {
                    if (!a.Contains(j))
                    {
                        if (i.getTo() == j.ToString())
                        {
                            dist.Remove(i);
                        }
                    }
                }
            }

            dist.Remove(d4);
            dist.Remove(d6);
            dist.Remove(d9);
            dist.Remove(d10);
            Console.WriteLine("The valid distances are:");
            foreach (var d in dist)
            {
                Console.WriteLine("From: " + d.getFrom() + " " + "To: " + d.getTo());
            }

            int           s        = 7500;
            int           rest     = 0;
            double        fee      = 0;
            int           minDist  = 60;
            int           minDist2 = 60;
            List <string> atms     = new List <string>();

            while (s > 0)
            {
                //take the minimum distance in minutes

                string atm = " ";
                if (minDist != minDist2)
                {
                    foreach (var d in dist)
                    {
                        if (d.getMin() < minDist)
                        {
                            minDist = d.getMin();
                        }
                        minDist2 = minDist;
                    }
                }

                //take the atm with the minimum distance
                foreach (var i in dist)
                {
                    if (i.Equals(minDist))
                    {
                        if (i.getTo() != "User starting point")
                        {
                            atm = i.getTo();
                        }
                        else if (i.getFrom() != "User starting point")
                        {
                            atm = i.getFrom();
                        }
                    }
                }

                foreach (var i in credits)
                {
                    if (i.getAmount() < i.getLimit())
                    {
                        rest = i.getAmount();
                    }
                    //substract the fee from the total amount of money
                    if (i.getFee() != 0)
                    {
                        fee = i.getAmount();
                        fee = i.getAmount() - fee / 100 * i.getAmount();
                    }
                    if (i.getAmount() > i.getLimit())
                    {
                        rest = i.getLimit();
                    }
                }
                s = s - rest;
                if (rest > 5000)
                {
                    List <Atm> atml = new List <Atm>();
                    atms.Add(atm);
                    List <string> atms1 = new List <string>();
                    atms1.AddRange(atms);
                    atms1 = (from o in atml select o.ToString()).ToList();

                    atm = " ";
                }
            }
            Console.WriteLine("ATM1->ATM2" + " " + "ATM3->ATM1");
            Console.ReadLine();
        }