CSharp OOP Basics Defining Classes Lab
CSharp OOP Basics Defining Classes Lab
Problems for exercises and homework for the "C# OOP Basics" course @ SoftUni.
You can check your solutions here: https://judge.softuni.bg/Contests/674/Defining-Classes-Lab
Solution
Create a new class and ensure proper naming
2. Methods
Create a class BankAccount (you can use class from previous task)
The class should have private fields for:
id: int
balance: double
The class should also have properties for:
© Software University Foundation (softuni.org). This work is licensed under the CC-BY-NC-SA license.
Solution
Create a method Deposit(double amount)
3. Test Client
Create a test client that tests your BankAccount class.
Support the following commands:
Create {Id}
Deposit {Id} {Amount}
Withdraw {Id} {Amount}
Print {Id}
End
© Software University Foundation (softuni.org). This work is licensed under the CC-BY-NC-SA license.
Examples
Input Output
Create 1 Account already exists
Create 2 Insufficient balance
Deposit 1 20 Account ID1, balance 10.00
Withdraw 1 30
Withdraw 1 10
Print 1
End
Create 1 Account does not exist
Deposit 2 20 Account does not exist
Withdraw 2 30 Account does not exist
Print 2
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
© Software University Foundation (softuni.org). This work is licensed under the CC-BY-NC-SA license.
Solution
Create the class as usual
© Software University Foundation (softuni.org). This work is licensed under the CC-BY-NC-SA license.
© Software University Foundation (softuni.org). This work is licensed under the CC-BY-NC-SA license.