Defining Classes Lab
Defining Classes Lab
Solution
Create a new class and ensure proper naming
Page 1 of 5
Solution
Create a method Deposit(decimal amount)
Page 2 of 5
Examples
Input Output
Create 1 Account already exists
Create 1 Insufficient balance
Deposit 1 20 Account ID1, balance 10.00
Withdraw 1 30
Withdraw 1 10
Print 1
End
Deposit 2 20 Account does not exist
Withdraw 2 30 Account does not exist
Print 2 Account does not exist
End
Solution
Create a Dictionary<int, BankAccount> to store existing accounts
Create the input loop:
Check the type of command and execute accordingly (optional: you can create a separate method for each
command)
Implement the Create command:
Page 3 of 5
Implement the rest of the commands following the same logic.
Solution
Create the class as usual:
Page 4 of 5
Create method GetBalance():
Page 5 of 5