Extra Exercises
Home Practice Exercises¶
-
Create a
SIMCard
class!- The SIM card must be initialized with a number that cannot be changed later.
- Anyone should be able to query (read) the number.
- Solution
-
Create a
MobilePhone
class!- A SIM card can be inserted into the mobile phone.
- What kind of relationship exists between the mobile phone and the SIM card?
- The card should be replaceable.
- The card should be removable.
- Solution
- A SIM card can be inserted into the mobile phone.
-
Create a function that replaces the SIM card in the phone!
- The parameters should be passed by value.
- Check at the call site whether the SIM card was actually replaced in the phone.
- Solution
-
Demonstrate the same replacement using references!
- What changed?
- Examine both the usage and the call site!
- Solution
-
Create a
Provider
class!- Only the provider should be able to change the number of an already existing SIM card.
- Solution
Last update:
2025-09-04
Created: 2025-09-04
Created: 2025-09-04