예제 #1
0
        // Creates Accounts
        private static void Createaccounts(List <Account> accounts)
        {
            // The total number of accounts to be created
            int NumberOfAccounts = TUI.ReadInteger("How many Accounts would you like to create? ");

            // the creation Loop
            for (int i = 0; i < NumberOfAccounts; i++)
            {
                Console.WriteLine($"Account number - {++RunningAccountNumber}");
                Console.WriteLine("Which account Would You Like to create?: ");
                Console.WriteLine("1. Savings Account");
                Console.WriteLine("2. Checking Account");
                int     input   = TUI.ReadIntegerRange(1, 2);
                Account account = null;
                // creates account according to the type
                switch (input)
                {
                case 1:
                    account = new SavingsAccount();
                    break;

                case 2:
                    account = new CheckingAccount();
                    break;
                }

                account.Create(RunningAccountNumber);
                accounts.Add(account);
            }
        }
예제 #2
0
        // Handles the accounts menu
        private static void HandleAccounts(List <Account> accounts, bool accountsCreated = false)
        {
            int input;                  // User input

            do
            {
                // Displays Account Menu
                DisplayAccountsMenu();
                input = TUI.ReadInteger();
                switch (input)
                {
                //
                case 1:
                    Createaccounts(accounts);
                    Console.WriteLine("Accounts have been created!");
                    accountsCreated = true;
                    break;

                case 2:
                    if (accountsCreated)
                    {
                        HandleAccount(accounts);
                    }
                    break;

                case 3:
                    break;

                default:
                    Console.WriteLine("Woops! That didn't work.");
                    break;
                }
            } while (input != 3);
        }
예제 #3
0
        public void IsValidInputTestInvalid()
        {
            TUI           _t     = new TUI();
            FileIO        _filer = new FileIO(_t);
            Authenticator auth   = new Authenticator(_t, _filer);

            Assert.IsFalse(auth.IsValidInput("1x#"));
        }
예제 #4
0
        public void IsValidInputTestSucceed()
        {
            TUI           _t     = new TUI();
            FileIO        _filer = new FileIO(_t);
            Authenticator auth   = new Authenticator(_t, _filer);

            Assert.IsTrue(auth.IsValidInput("1234"));
        }
예제 #5
0
    protected virtual void OnAdjustPageSibling()
    {
        bool pageShow = UIMessageBoxBase.m_MessageBox == null;

        for (int i = 0; i < m_Pages.Count; i++)
        {
            bool pageOverlay = pageShow && m_Pages.Count - 1 == i;
            TUI.ReparentRestretchUI(m_Pages[i].rectTransform, pageOverlay ? tf_OverlayPage : tf_CameraPage);
        }
    }
예제 #6
0
    protected void SetControlViewMode(UIControlBase control, bool overlay)
    {
        if (!m_ControlSiblings.ContainsKey(control))
        {
            Debug.LogError("?");
            return;
        }

        TUI.ReparentRestretchUI(control.rectTransform, overlay ? tf_OverlayControl : tf_CameraControl);
        control.transform.SetSiblingIndex(m_ControlSiblings[control]);
    }
예제 #7
0
 public override IDocEntity SaveChanges(bool ignoreCache, DocConstantPermission permission)
 {
     BioPortal = BioPortal?.TrimAndPruneSpaces();
     CUI       = CUI?.TrimAndPruneSpaces();
     MedDRA    = MedDRA?.TrimAndPruneSpaces();
     Name      = Name?.TrimAndPruneSpaces();
     RxNorm    = RxNorm?.TrimAndPruneSpaces();
     SNOWMED   = SNOWMED?.TrimAndPruneSpaces();
     TUI       = TUI?.TrimAndPruneSpaces();
     URI       = URI?.TrimAndPruneSpaces();
     return(base.SaveChanges(ignoreCache, permission));
 }
예제 #8
0
        // Processes The loan
        // returns the status after processsing
        public void Process(Account account)
        {
            {
                bool   result = false;
                string reason = "";

                // Checks if the account already has a loan.
                if (!account.HasLoan)
                {
                    // Verification Check
                    if (!(TUI.ReadInteger("Please Enter Your unique accountID for verification: ") == account.AccountID))
                    {
                        reason = "Verification Error";
                    }
                    else
                    {
                        // Checks the initial Balance Before Giving Loan.
                        if (account.Balance > Amount)
                        {
                            // Asks For all the details
                            Amount               = TUI.ReadDecimal("Please Enter What amount of loan would you like : ");
                            Days                 = TUI.ReadInteger("For How many Days: ");
                            Rate                 = TUI.ReadInteger("The intrest rate from the chart: ");
                            Installments         = TUI.ReadIntegerRange(3, 10, "How many installments would you like? (3-10): ");
                            AmountPerInstallment = ((Rate * Days) + Amount) / Installments;
                            account.Balance     += Amount;
                            account.HasLoan      = true;
                            DateIssued           = DateTime.Now;
                            InstallmentsLeft     = Installments;
                            LateCharge           = TUI.ReadDecimal("Please Enter the Late Charge displayed on the chart.");
                            Console.WriteLine("Loan Successfully Initiated!");
                            Console.WriteLine($"This is your balance now {account.Balance:C}");
                            Console.WriteLine($"The Loan is due on: {DateExpire.ToShortDateString()}");
                            result = true;
                        }
                        else
                        {
                            reason = "Low Balance";
                            Console.WriteLine($"This is your balance {account.Balance:C}");
                            Console.WriteLine($"This is your amount {Amount:C}");
                        }
                    }
                }
                else
                {
                    reason = "Loan Already Issued";
                }
                if (!(result && reason == ""))
                {
                    Console.WriteLine($"Loan Couldn't be processed please try again, reason: {reason}.");
                }
            }
        }
예제 #9
0
        public override void Initialize()
        {
            // Determine the position and size of the interface.
            int x = 100, y = 100, w = 50, h = 30;
            // Pass an empty provider to the panel (the interface will be drawn on Main.tile).
            object provider = FakeProviderAPI.CreateReadonlyTileProvider("TicTacToe", x, y, w, h);
            // Although we can use as a provider, for example, FakeTileRectangle from FakeManager:
            //object provider = FakeManager.FakeManager.Common.Add("TestPanelProvider", x, y, w, h);

            // Create a panel with a wall of diamond gemspark wall with black paint.
            Panel root = TUI.Create(new Panel("TicTacToe", x, y, w, h, null,
                                              new ContainerStyle()
            {
                Wall = WallID.DiamondGemspark, WallColor = PaintID.White
            }, provider)) as Panel;

            root.SetupGrid(new ISize[] { new Absolute(20), new Relative(100) });

            var menu = root[0, 0] = new VisualContainer(new ContainerStyle()
            {
                WallColor = PaintID.Black
            });

            menu.SetupLayout(Alignment.Up, Direction.Down, Side.Center, null, 0);
            menu.AddToLayout(new Button(0, 0, 20, 4, "Start", null, new ButtonStyle()
            {
                Wall      = WallID.AmberGemspark,
                WallColor = PaintID.DeepGreen
            }, (self, touch) =>
            {
                for (int i = 0; i < root[1, 0].ChildCount; i++)
                {
                    root[1, 0].GetChild(i).RemoveAll();
                }
                root[1, 0].Update().Apply().Draw();
            }));
            menu.AddToLayout(new Button(0, 0, 20, 4, "help", null, new ButtonStyle()
            {
                Wall      = WallID.AmberGemspark,
                WallColor = PaintID.Gray
            }, (self, touch) => TSPlayer.All.SendInfoMessage("HELP")));

            var game = root[1, 0] = new TicTacToe();

            game["turn"] = 0;
        }
예제 #10
0
        // Handles loans For a Given Account
        private static void HandleLoan(Account account)
        {
            int input;              // User input

            do
            {
                // Displays Loan Menu
                DisplayLoanMenu(account);
                input = TUI.ReadInteger();
                switch (input)
                {
                // Initiate Loan
                case 1:
                    account.InitiateLoan();
                    break;

                // Initiate Payments of installments
                case 2:
                    if (account.HasLoan)
                    {
                        account.PayInstallments();
                    }
                    break;

                // Loan Status; Or overview
                case 3:
                    if (account.HasLoan)
                    {
                        Console.WriteLine(account.AccLoan.ToString());
                    }
                    break;

                // Exit
                case 4:
                    break;

                // Failsafe
                default:
                    break;
                }
            } while (input != 4);
        }
 // Overrides
 public override void Create(int account_id)
 {
     Balance          = TUI.ReadDecimal("Please Enter the initial Balance.");
     FeeChargedPerTxn = TUI.ReadDecimal("Please Enter the Fee Charged Per Transaction");
     base.Create(account_id);
 }
예제 #12
0
 // overrides
 public override void Create(int account_id)
 {
     Balance     = TUI.ReadDecimal("Please Enter the initial Balance.");
     IntrestRate = TUI.ReadDecimal("Please Enter the intrest Rate");
     base.Create(account_id);
 }
예제 #13
0
        // Pays Specific number of installments
        public void PayInstallments(Account account)
        {
            int    InstallmentsToPay = TUI.ReadInteger("How many installments would you like to pay? ");
            string reason            = "";

            // Checking if you pay more than installments present
            if (InstallmentsToPay > InstallmentsLeft && InstallmentsToPay > Installments)
            {
                reason = "Installments out of Bound. (More to pay than available)";
            }
            else
            {
                decimal AmountToPay = InstallmentsToPay * AmountPerInstallment;

                // Checks for the expiry and adds extra ammount to initial
                if (DateTime.Compare(DateExpire, DateTime.Now) < 0)
                {
                    TimeSpan TimePeriod = DateExpire - DateTime.Now;
                    decimal  Extra      = (LateCharge * (int)TimePeriod.TotalDays);
                    Console.WriteLine($"The Date of Loan has been Expired! You will have to pay {Extra.ToString():C} extra." +
                                      $" For late by {(int)TimePeriod.TotalDays} days.");
                    AmountToPay += Extra;
                }

                // Checks if the owner is capable of paying the amount
                if (AmountToPay > account.Balance)
                {
                    reason = "Insufficient Balance.";
                }
                else
                {
                    // Verification Check
                    if (!(TUI.ReadInteger("Please Enter Your unique accountID for verification: ") == account.AccountID))
                    {
                        reason = "Verification Error";
                    }
                    else
                    {
                        // Gives a Chance to quit
                        if (!TUI.ReadBool("Do You want to Continue?"))
                        {
                            reason = "Terminated by User";
                        }
                        else
                        {
                            account.Balance  -= AmountToPay;
                            InstallmentsLeft -= InstallmentsToPay;
                            if (InstallmentsLeft == 0)
                            {
                                reason = Complete(account);
                            }
                        }
                    }
                }
            }
            if (reason != "")
            {
                Console.WriteLine($"The action was cancelled, Reason: {reason}");
            }
            else
            {
                Console.WriteLine("Installments Successfully paid!");
            }
        }
예제 #14
0
        // handles account menu, selecting one account
        private static void HandleAccount(List <Account> accounts)
        {
            bool    accountSelected = false;
            Account account         = new Account();
            int     input;

            do
            {
                if (accountSelected)
                {
                    DisplayMenu(account);
                }
                else
                {
                    DisplayMenu();
                }
                Console.Title = "Account";
                input         = TUI.ReadInteger("write your input here: ");
                Console.Clear();
                const string errormsg = "Please select a account first";

                // TODO: make functions for each of them
                switch (input)
                {
                // Opens Selection Menu
                case 1:
                    int account_id = TUI.ReadInteger("please enter your account id you want: ");
                    if (account_id <= RunningAccountNumber)
                    {
                        var query = from _account in accounts
                                    where _account.AccountID == account_id
                                    select _account;

                        foreach (Account _account in query)
                        {
                            account = _account;
                        }
                        accountSelected = true;
                    }
                    else
                    {
                        Console.WriteLine("Please check your account number again.");
                    }
                    break;

                // Add Deposit
                case 2:
                    if (accountSelected)
                    {
                        decimal balance = TUI.ReadDecimal("How much you want to deposit: ");
                        account.Deposit(balance);
                    }
                    else
                    {
                        Console.WriteLine(errormsg);
                    }
                    break;

                // Widrawl Menu
                case 3:
                    if (accountSelected)
                    {
                        decimal amount = TUI.ReadDecimal("How much you want to widraw");
                        account.Widraw(amount);
                    }
                    else
                    {
                        Console.WriteLine(errormsg);
                    }
                    break;

                // Account Details
                case 4:
                    if (accountSelected)
                    {
                        Console.WriteLine(account.ToString());
                    }
                    else
                    {
                        Console.WriteLine(errormsg);
                    }
                    break;

                // Shows the intrest
                // NOTE: For Savings Account Only
                case 5:
                    if (accountSelected)
                    {
                        if (account is SavingsAccount savingsAccount)
                        {
                            Console.WriteLine($"{savingsAccount.CalculateIntrest():C}");
                        }
                    }
                    else
                    {
                        Console.WriteLine(errormsg);
                    }
                    break;

                // Displays Loan Menu
                case 6:
                    if (accountSelected)
                    {
                        HandleLoan(account);
                    }
                    else
                    {
                        Console.WriteLine(errormsg);
                    }
                    break;

                // The exit
                case 7:
                    break;

                // If nothing works
                default:
                    Console.WriteLine("Woops! That didn't work.");
                    break;
                }
            } while (input != 7);
        }