Now what we need to do here is create our methods that interacts with the user to change the balance property inside our ATM class.
We already created our add method so let’s add a method to withdraw from our balance.
public int Withdraw(int amount)
{
return Balance = Balance - amount;
}
Wait a minute, what about if we don’t have any in our balance account? Don’t worry about that, we deal with that later.
Now create the method that simply returns the balance property.
public int Account()
{
return Balance;
}
Great! Let’s update our switch case with our new methods.
case "Account":
Console.WriteLine($"\nCurrent balance: {atm.Account()}");
break;
case "Withdraw":
Console.Write("Type amount to withdraw and press enter : ");
int withdraw = Int32.Parse(Console.ReadLine());
int resultWithdraw = atm.Withdraw(withdraw);
Console.WriteLine($"\nCurrent balance: {result.ToString()}");
break;
Let’s try it out!
First we check the balance with account and it’s 0.

Now add 5 to the balance.

Now let’s withdraw 3.

Perfect!
Now in the final post we’ll create a log for our ATM actions.