Challenge: Building a Composed Warrior
Aufgabe
Swipe to start coding
Practice using composition by building a simple warrior game:
- Create a
Weaponclass with anameandattackvalue. - Create a
Warriorclass with anamethat 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ösung
War alles klar?
Danke für Ihr Feedback!
Abschnitt 1. Kapitel 18
single
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen
Großartig!
Completion Rate verbessert auf 3.85
Challenge: Building a Composed Warrior
Swipe um das Menü anzuzeigen
Aufgabe
Swipe to start coding
Practice using composition by building a simple warrior game:
- Create a
Weaponclass with anameandattackvalue. - Create a
Warriorclass with anamethat 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ösung
War alles klar?
Danke für Ihr Feedback!
Abschnitt 1. Kapitel 18
single