Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Challenge: Admin | Inheritance
In-Depth Python OOP
course content

Contenu du cours

In-Depth Python OOP

In-Depth Python OOP

1. OOP Concepts
2. Inheritance
3. Encapsulation
4. Polymorphism and Abstraction
5. Magic Methods

book
Challenge: Admin

Tâche

Swipe to start coding

You have a User class from the last challenge.
The methods are corrected (User -> {self.username} in strings).
Let's define the Admin class!

  1. Define the Admin class inherited from the User class.
  2. Define the create_content() admin's method that prints the string:
    f"{self.username} creates the content".
  3. Define the update_content() admin's method that prints the string:
    f"{self.username} updates the content".
  4. Define the delete_content() admin's method that prints the string:
    f"{self.username} deletes the content".

Note

Admin has all the capabilities of User that do not need to be reimplemented. This is an example of how inheritance makes our life easier.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 2
toggle bottom row

book
Challenge: Admin

Tâche

Swipe to start coding

You have a User class from the last challenge.
The methods are corrected (User -> {self.username} in strings).
Let's define the Admin class!

  1. Define the Admin class inherited from the User class.
  2. Define the create_content() admin's method that prints the string:
    f"{self.username} creates the content".
  3. Define the update_content() admin's method that prints the string:
    f"{self.username} updates the content".
  4. Define the delete_content() admin's method that prints the string:
    f"{self.username} deletes the content".

Note

Admin has all the capabilities of User that do not need to be reimplemented. This is an example of how inheritance makes our life easier.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 2. Chapitre 2
Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
We're sorry to hear that something went wrong. What happened?
some-alt