Esempio n. 1
0
        static void Main(string[] args)
        {
            string            input    = string.Empty;
            AccountCollection accounts = new AccountCollection();

            while (input != "exit")
            {
                Console.Clear();
                Console.WriteLine("");
                Console.WriteLine("\t Login Menu");
                Console.WriteLine("Login (1)");
                Console.WriteLine("Create Account (2)");
                Console.WriteLine("Exit (exit)");

                input = Console.ReadLine();

                if (input == "1")
                {
                    Console.Clear();
                    Console.WriteLine("Please type in your Username:"******"");
                    Console.WriteLine("Please type in your Password:"******"5")
                        {
                            double number = 0;

                            Console.Clear();
                            Console.WriteLine("");
                            Console.WriteLine("\t \t Welcome to Super Cool Bank!");
                            Console.WriteLine("Make a Deposit (1)");
                            Console.WriteLine("Make a Withdrawal (2)");
                            Console.WriteLine("Check Transaction History (3)");
                            Console.WriteLine("Check Current Balance (4)");
                            Console.WriteLine("Logout (5)");
                            Console.WriteLine("");

                            account_input = Console.ReadLine();
                            switch (account_input)
                            {
                            case "1":
                                Console.WriteLine("Please enter deposit amount:");
                                account_input = Console.ReadLine();

                                if (double.TryParse(account_input, out number))
                                {
                                    Console.WriteLine(current_account.Deposit(number));
                                    Console.ReadKey();
                                    Console.Clear();
                                }
                                else
                                {
                                    Console.WriteLine("Invalid deposit amount. Press any key to continue...");
                                    Console.ReadKey();
                                    Console.Clear();
                                }



                                break;

                            case "2":
                                Console.WriteLine("Please enter withdraw amount:");
                                account_input = Console.ReadLine();

                                if (double.TryParse(account_input, out number))
                                {
                                    Console.WriteLine(current_account.Withrdraw(number));
                                    Console.ReadKey();
                                    Console.Clear();
                                }
                                else
                                {
                                    Console.WriteLine("Invalid Withrdraw amount. Press any key to continue...");
                                    Console.ReadKey();
                                    Console.Clear();
                                }

                                break;

                            case "3":
                                Console.WriteLine("Displaying transaction history...\n");
                                foreach (Transaction t in current_account.Get_History())
                                {
                                    Console.WriteLine("");
                                    Console.WriteLine("Previous Balance: {0} | Transaction Type: {1} | Transaction amount: {2} | Date: {3}", t.Get_Balance(), t.Get_Type(), t.Get_Amount(), t.Get_Date());
                                }

                                Console.ReadKey();
                                Console.Clear();
                                break;

                            case "4":
                                Console.WriteLine("Current Balance: ${0}", current_account.Get_Balance());
                                Console.WriteLine("Press any key to continue...");
                                Console.ReadKey();
                                Console.Clear();
                                break;
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                        Console.ReadKey();
                        Console.Clear();
                    }
                }

                if (input == "2")
                {
                    Console.Clear();
                    Console.WriteLine("Please type in your Username:"******"");
                    Console.WriteLine("Please type in your Password:"******"Account Created! Please log in... ");
                        Console.ReadKey();
                        Console.Clear();
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(e.Message);
                        Console.ReadKey();
                        Console.Clear();
                    }
                }
            }
        }