예제 #1
0
파일: Program.cs 프로젝트: waelhawa/ATMLab
        } //end UserRegister

        public static void UserDeposit(ATM bank)
        {
            double amount = AmountEntry(amountEntry);

            bank.Deposit(amount);
            Console.Clear();
            Console.WriteLine($"Logged in as user: {bank.User.Name}");
            Console.WriteLine($"The amount {amount} was added successfully.");
        } //end UserDeposit
예제 #2
0
        static void Main(string[] args)
        {
            ATM            a        = new ATM();
            List <Account> accounts = a.Accounts;

            foreach (Account acc in accounts)
            {
                Console.WriteLine(acc.Name);
            }
            a.CheckBalance();
            a.Logout();
            a.Login("Joey", "123456");
            a.CheckBalance();
            a.Deposit(2000);
            a.CheckBalance();

            a.Login("asdfghj", "12345678");
            a.Logout();
        }
예제 #3
0
        public static void AtmGreetingAndLogic()
        {
            ATM    atm = new ATM(); // have to create the atm object NON Static methods MUST be tied to an object
            string name, password;

            // need the object to use the non static method
            Console.WriteLine("Welcome to the crappy atm! ");
            Console.WriteLine("Please register "); // testing the functionaility of the classes

            Console.Write("Name: ");
            name = Console.ReadLine();

            Console.WriteLine("Password: "******"Please Login ");

            name     = GetUserInput("Enter Username: "******"Enter password please ");

            atm.Login(name, password);

            //atm.Register(GetUserInput("Enter Name: "), GetUserInput("Enter password: "******"Make a selection: ");
                    // 1. checkbalance
                    if (response == "1")
                    {
                        atm.CheckBalance();
                    }

                    // 2. deposit
                    if (response == "2")
                    {
                        Console.WriteLine("How much would you like to deposit? ");
                        double depositedAmount = Convert.ToDouble(Console.ReadLine());
                        atm.Deposit(depositedAmount);
                        Console.WriteLine($"You deposited {depositedAmount}");
                        atm.CheckBalance();
                    }

                    // 3 Withdraw
                    if (response == "3")
                    {
                        Console.WriteLine("How much would you like to withdraw? ");
                        double withdrawnAmount = Convert.ToDouble(Console.ReadLine());
                        atm.Withdraw(withdrawnAmount);
                        Console.WriteLine($"You withdrew {Math.Round(withdrawnAmount, 2)}");
                        atm.CheckBalance();
                    }
                    if (response == "4")
                    {
                        Console.WriteLine("Exiting the program");
                        Environment.Exit(0);
                    }
                }
            }
        }