Exemplo n.º 1
0
 static void CreateAccount(string firstName, string lastName, string accountType)
 {
     if (accountType == "savings")
     {
         SavingsAccount account = new SavingsAccount(firstName, lastName);
         ManageSavingsLotteryAccount(account);
     }
     else if (accountType == "credit")
     {
         CreditAccount account = new CreditAccount(firstName, lastName);
         ManageCreditAccount(account);
     }
     else
     {
         LotteryAccount account = new LotteryAccount(firstName, lastName);
         ManageSavingsLotteryAccount(account);
     }
 }
Exemplo n.º 2
0
 static void ManageCreditAccount(CreditAccount account)
 {
     while (true)
     {
         Console.WriteLine("Please enter your action (deposit, charge, addpayment, print, quit):");
         var action = Console.ReadLine();
         while (!creditAccountActions.Contains(action))
         {
             Console.WriteLine("Valid account actions are deposit, charge, addpayment, print and quit.");
             Console.WriteLine("Please enter your action to proceed:");
             action = Console.ReadLine();
         }
         if (action == "quit")
         {
             break;
         }
         else if (action == "print")
         {
             account.PrintStatementTransaction();
         }
         else if (action == "deposit" || action == "charge" || action == "addpayment")
         {
             Console.WriteLine("Please enter the amount that you want to process");
             var amount = Decimal.TryParse(Console.ReadLine(), out decimal decimalAmount);
             while (!amount)
             {
                 Console.WriteLine("Please enter a valid amount that you want to process (decimal)");
                 amount = Decimal.TryParse(Console.ReadLine(), out decimalAmount);
             }
             if (action == "deposit")
             {
                 account.Deposit(decimalAmount);
             }
             else if (action == "charge")
             {
                 account.Charge(decimalAmount);
             }
             else
             {
                 account.AddPayment(decimalAmount);
             }
         }
     }
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            bool HasNumber(string input)//elegxos na mhn dwthoun arithmitika stoixeia
            {
                return(input.Where(x => Char.IsDigit(x)).Any());
            }

            Console.WriteLine("Welcome to our Bank.\nPlease enter first name:\n");
            string firstName = Console.ReadLine();

            while (HasNumber(firstName))
            {
                Console.WriteLine("Please enter first name without numbers:\n");
                firstName = Console.ReadLine();
            }

            Console.WriteLine("Please enter last name:\n");
            string lastName = Console.ReadLine();

            while (HasNumber(lastName))
            {
                Console.WriteLine("Please enter last name without numbers:\n");
                lastName = Console.ReadLine();
            }

            Regex ibanRegex = new Regex("[0-9]");

            Console.WriteLine("Please enter IBAN:\n");
            string iban = Console.ReadLine();

            while (!(ibanRegex.IsMatch(iban) && iban.Length == 16)) //elegxoume an to iban exei mono arithmous kai einai 16pshfio
            {
                Console.WriteLine("Please enter a 16 numbers - IBAN without chars:\n");
                iban = Console.ReadLine();
            }

            Customer customer1 = new Customer(firstName, lastName, iban);

            long amount;


            Console.WriteLine("Please choose:\n 1 for Credit Account.\n 2 for Savings Account.\n 3 for Lottery Account.\n 4 Quit. \n");
            string decision = Console.ReadLine();

            while (decision != "4")
            {
                switch (decision)
                {
                case "1":
                    CreditAccount creditAccount1 = new CreditAccount(firstName, lastName, iban);
                    Console.WriteLine("Please choose:\n 1 for Charge.\n 2 for Deposit.\n 3 for Add Payment.\n 4 Quit. \n");
                    decision = Console.ReadLine();
                    while (decision != "4")
                    {
                        switch (decision)
                        {
                        case "1":
                            Console.WriteLine("Write your amount:\n");
                            amount = long.Parse(Console.ReadLine());
                            creditAccount1.charge(amount);
                            break;

                        case "2":
                            Console.WriteLine("Write your amount:\n");
                            amount = long.Parse(Console.ReadLine());
                            creditAccount1.deposit(amount);
                            break;

                        case "3":
                            creditAccount1.addPayment();
                            break;

                        default:
                            Console.WriteLine("Choose right number");
                            break;
                        }

                        Console.WriteLine("Please choose:\n 1 for Charge.\n 2 for Deposit.\n 3 for Add Payment.\n 4 Quit.\n");
                        decision = Console.ReadLine();
                    }


                    break;

                case "2":
                    SavingsAccount savingsAccount1 = new SavingsAccount(firstName, lastName, iban);
                    Console.WriteLine("Please choose:\n 1 for Withdraw.\n 2 for Deposit.\n 3 for Add Interest.\n 4 Quit.\n");
                    decision = Console.ReadLine();
                    while (decision != "4")
                    {
                        switch (decision)
                        {
                        case "1":
                            Console.WriteLine("Write your amount:\n");
                            amount = long.Parse(Console.ReadLine());
                            savingsAccount1.withdraw(amount);
                            break;

                        case "2":
                            Console.WriteLine("Write your amount:\n");
                            amount = long.Parse(Console.ReadLine());
                            savingsAccount1.deposit(amount);
                            break;

                        case "3":
                            savingsAccount1.addInterest();
                            break;

                        default:
                            Console.WriteLine("Choose right number");
                            break;
                        }

                        Console.WriteLine("Please choose:\n 1 for Withdraw.\n 2 for Deposit.\n 3 for Add Interest.\n 4 Quit.\n");
                        decision = Console.ReadLine();
                    }

                    break;

                case "3":
                    LotteryAccount lotteryAccount1 = new LotteryAccount(firstName, lastName, iban);
                    Console.WriteLine("Please choose:\n 1 for Withdraw.\n 2 for Deposit.\n 3 Quit.\n");
                    decision = Console.ReadLine();
                    while (decision != "3")
                    {
                        switch (decision)
                        {
                        case "1":
                            Console.WriteLine("Write your amount:\n");
                            amount = long.Parse(Console.ReadLine());
                            lotteryAccount1.withdraw(amount);
                            lotteryAccount1.winPercentage();         //sygkrinei 2 tyxaious arithmous se kathe synallagi me pithanotita 1% na dwsei 50 eyrw
                            break;

                        case "2":
                            Console.WriteLine("Write your amount:\n");
                            amount = long.Parse(Console.ReadLine());
                            lotteryAccount1.deposit(amount);
                            lotteryAccount1.winPercentage();
                            break;

                        default:
                            Console.WriteLine("Choose right number.\n");
                            break;
                        }

                        Console.WriteLine("Please choose:\n 1 for Withdraw.\n 2 for Deposit.\n 3 Quit.\n");
                        decision = Console.ReadLine();
                    }

                    break;

                default:
                    Console.WriteLine("Choose right number.\n");
                    break;
                }

                Console.WriteLine("Please choose:\n 1 for Credit Account.\n 2 for Savings Account.\n 3 for Lottery Account.\n 4 Quit. \n");
                decision = Console.ReadLine();
            }
        }