Skip to content

Extra Exercises

Home Practice Exercises

  1. 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
  2. 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
  3. 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
  4. Demonstrate the same replacement using references!

    • What changed?
    • Examine both the usage and the call site!
    • Solution
  5. 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