Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Challenge: Building a Composed Warrior | Introduksjon til Python OOP
Practice
Projects
Quizzes & Challenges
Quizer
Challenges
/
Objektorientert Programmering i Python

bookChallenge: Building a Composed Warrior

Oppgave

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.

Løsning

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 18
single

single

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

close

bookChallenge: Building a Composed Warrior

Sveip for å vise menyen

Oppgave

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.

Løsning

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 18
single

single

some-alt