Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Challenge: Building a Composed Warrior | Introduction à la POO en Python
Programmation Orientée Objet en Python

bookChallenge: Building a Composed Warrior

Tâche

Swipe to start coding

Practice using composition by building a simple warrior game:

  • Create a Weapon class with a name and attack value.
  • Create a Warrior class with a name that can equip a weapon (store it as an attribute) and has a method to show its current weapon.
  • Equip the warrior with the weapon.
  • Use composition. The warrior should have a weapon, not inherit from it.

Solution

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 18
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

close

bookChallenge: Building a Composed Warrior

Glissez pour afficher le menu

Tâche

Swipe to start coding

Practice using composition by building a simple warrior game:

  • Create a Weapon class with a name and attack value.
  • Create a Warrior class with a name that can equip a weapon (store it as an attribute) and has a method to show its current weapon.
  • Equip the warrior with the weapon.
  • Use composition. The warrior should have a weapon, not inherit from it.

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 1. Chapitre 18
single

single

some-alt