示例#1
0
        /// <summary>
        /// Withdraw the money from the bank.
        /// </summary>
        /// <param name="bank">The bank is an instance to access the members of BankCashCounter class.</param>
        /// <returns>updated cash</returns>
        public int WithdrawMoney(BankCashCounter bank)
        {
            try
            {
                ////print cash available in bank
                Console.WriteLine("Available cash : {0} ", BankCashCounter.InitialCash);
                Console.WriteLine("\nEnter the Amount to be withdrawn from the Bank : ");
                bank.Amount = Convert.ToInt32(Console.ReadLine());

                ////check if amount entered is available in bank
                if (bank.Amount < BankCashCounter.InitialCash)
                {
                    ////Decrement bank cash by amount withdrawn
                    BankCashCounter.InitialCash -= bank.Amount;
                    Console.WriteLine("\nAmount withdrawn successfully...");
                }
                else
                {
                    Console.WriteLine("\nCannot withdraw due to insufficient cash...");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(BankCashCounter.InitialCash);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="BankCashCounter{T}"/> class.
        /// </summary>
        public void BankCashCounterOperations()
        {
            try
            {
                int  choice;
                char ans;

                //// Insert into queue
                for (int i = 1; i <= 2; i++)
                {
                    this.utilityObject.InsertElementIntoQueue(i);
                }

                ////Remove from queue if done with transactions
                foreach (int i in this.queue1.DataElement)
                {
                    Console.WriteLine("Visiter : ");
                    do
                    {
                        BankCashCounter bank = new BankCashCounter();
                        Console.WriteLine("Which operation do you want to perform : ");
                        Console.WriteLine("1.Deposit\t2.Withdrawal : ");
                        choice = Convert.ToInt32(Console.ReadLine());

                        ////Choose the type of transaction
                        switch (choice)
                        {
                        case 1:
                            //// Deposite money into the Bank
                            Console.WriteLine("\nRemaining Bank Amount is {0} ...\n", this.utilityObject.DepositeMoney(bank));
                            break;

                        case 2:
                            ////Withdraw money from Bank
                            Console.WriteLine("\nRemaining Bank Amount is {0} ...\n", this.utilityObject.WithdrawMoney(bank));
                            break;

                        default:
                            Console.WriteLine("\nWrong Choice...");
                            break;
                        }

                        Console.WriteLine("\nDo you want to perform more transactions (y/n) : ");
                        ans = Convert.ToChar(Console.ReadLine());
                    }while (ans == 'y' || ans == 'Y');
                    this.utilityObject.RemoveElementFromQueue();
                }

                Console.WriteLine("\nQueue Ended..... ");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
示例#3
0
        /// <summary>
        /// Deposit money into the bank.
        /// </summary>
        /// <param name="bank">The bank is an instance to access the members of BankCashCounter class.</param>
        /// <returns>Updated Initial cash</returns>
        public int DepositeMoney(BankCashCounter bank)
        {
            try
            {
                do
                {
                    Console.WriteLine("\nEnter the Amount to be deposited into the Bank /nNote : Must be greater than zero : ");
                    bank.Amount = Convert.ToInt32(Console.ReadLine());
                }while (bank.Amount < 0);

                ////Increment bank cash by amount deposited
                BankCashCounter.InitialCash += bank.Amount;
                Console.WriteLine("\nAmount deposited successfully...");
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            return(BankCashCounter.InitialCash);
        }
示例#4
0
        /// <summary>
        /// Defines the entry point of the application.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public static void Main(string[] args)
        {
            try
            {
                char ans;
                do
                {
                    Console.WriteLine("1.Linked List Operations For String ");
                    Console.WriteLine("2.Linked List Operations For Integer ");
                    Console.WriteLine("3.Balanced Parenthesis ");
                    Console.WriteLine("4.Bank Cash Counter ");
                    Console.WriteLine("5.Calender");
                    Console.WriteLine("6.Palindrome Checker");
                    Console.WriteLine("7.Prime number 2D array");
                    Console.WriteLine("8.Prime Anagram number 2D array");
                    Console.WriteLine("9.Prime Anagram numbers using Stack");
                    Console.WriteLine("10.Prime Anagram numbers using Queue");
                    Console.WriteLine("11.Number of Binary Search Trees");
                    Console.WriteLine("12.Hashing Array");

                    int ch = Convert.ToInt32(Console.ReadLine());
                    switch (ch)
                    {
                    case 1:
                        ReadIntoLinkedList <string> b = new ReadIntoLinkedList <string>();
                        break;

                    case 2:
                        ReadIntegerFromFile <int> b1 = new ReadIntegerFromFile <int>();
                        b1.OrderedListOperation();
                        break;

                    case 3:
                        BalanceParenthesis b2 = new BalanceParenthesis();
                        b2.CheckBalancedParenthesis();
                        break;

                    case 4:
                        BankCashCounter bcc = new BankCashCounter();
                        bcc.BankCashCounterOperations();
                        break;

                    case 5:
                        Calendar.DisplayCalendar();
                        break;

                    case 6:
                        PalindromeChecker pc = new PalindromeChecker();
                        pc.PalindromeCheckMethod();
                        break;

                    case 7:
                        Prime2DArray.Prime2DOperation();
                        break;

                    case 8:
                        PrimeAnagram2DArray.PrimeAnagramFunction();
                        break;

                    case 9:
                        PrimeAnagramNumberUsingStack ps = new PrimeAnagramNumberUsingStack();
                        ps.PrintPrimeAnagram();
                        break;

                    case 10:
                        PrimeAnagramNumberUsingQueue pq = new PrimeAnagramNumberUsingQueue();
                        pq.PrintPrimeAnagram();
                        break;

                    case 11:
                        InputBinary.BinaryTree();
                        break;

                    case 12:
                        InputForHashing input = new InputForHashing();
                        input.CallHashingFunction();
                        break;

                    default:
                        Console.WriteLine("Invalid Choice...");
                        break;
                    }

                    Console.WriteLine("\nDo you want to continue in Menu (y/n) : ");
                    ans = Convert.ToChar(Console.ReadLine());
                }while (ans == 'Y' || ans == 'y');
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.WriteLine("Thank you...");
        }