Esempio n. 1
0
        } //end UserDeposit

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

            if (amount <= bank.CheckBalance())
            {
                Console.Clear();
                Console.WriteLine($"Logged in as user: {bank.User.Name}");
                Console.WriteLine($"The amount {amount} was withdrawn successfully.");
                bank.Withdraw(amount);
            }
            else
            {
                Console.Clear();
                Console.WriteLine($"Logged in as user: {bank.User.Name}");
                Console.WriteLine("Account balance not enough!");
            }
        } //end UserWithdraw
Esempio n. 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();
        }
Esempio n. 3
0
        } //end LoginMenu

        public static Account UserLogin(ATM bank)
        {
            string userName = UserEntry(usernameMessage, ".");
            string password = UserEntry(passwordMessage, ".");

            for (int i = 0; i < bank.accounts.Count; i++)
            {
                if (bank.accounts[i].Name == userName)
                {
                    if (bank.accounts[i].Password == password)
                    {
                        Console.Clear();
                        Console.WriteLine($"User {bank.accounts[i].Name} logged in successfully.");
                        return(bank.accounts[i]);
                    }
                    else
                    {
                        Console.WriteLine("Wrong Password!");
                    }
                }
            }
            return(null);
        } //end UserLogin
Esempio n. 4
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);
                    }
                }
            }
        }
Esempio n. 5
0
        } //end UserBalance

        public static void UserLogout(ATM bank)
        {
        } //end UserLogout
Esempio n. 6
0
        } //end UserWithdraw

        public static void UserBalance(ATM bank)
        {
            Console.Clear();
            Console.WriteLine($"Logged in as user: {bank.User.Name}");
            Console.WriteLine($"Current Balance: ${bank.CheckBalance()}");
        } //end UserBalance