dimanche 28 février 2021

C# , how to make a Key word to fulfill specific command

I need a help with the correct command (please read my question in the code below so that you understand what I'm asking precisely, method: static void Main(string[] args) )

namespace Bank
{
    class Bank
    {
        class BankAccount
        {
            private double balance = 0;
            public void Deposit(double n)
            {
                balance += n;
                Console.WriteLine($"You currently have {balance}");
            }
            public void Withdraw(double n)
            {


                  
                  

  if (balance >= n)
                { balance -= n;
                    Console.WriteLine($"After Withdrawal you have remained {balance}" + " in your Account");
                }
                else
                { Console.WriteLine("You need more money to Withdraw" + $"You currently have { balance}"); }
                
  

      }
        public double GetBalance()

        {
            Console.WriteLine($"Your Balance is : {balance}");
            return balance;
        }

    }
        static void Main(string[] args)
        {
        
        BankAccount Acc1 = new BankAccount();
        /* I want to type a specific key words that will allow me to proceed with certain command. 
         For example if I type "Deposit" it will proceed with the Deposit command below. And the same for Withdraw. But not both of them one by one (unless I type them both on purpose). */

        if (/* need correct command*/)
        { Acc1.Deposit(Convert.ToDouble(Console.ReadLine())); }

        else if (/* need correct command*/)
        { Acc1.Withdraw(Convert.ToDouble(Console.ReadLine())); }

        
    }
   
    }
}

Aucun commentaire:

Enregistrer un commentaire