Exercise on Classes
Explore the fundamentals of ES6 classes through practical exercises that involve creating player and non-player characters within a simulated 10x10 game field. Learn to implement class inheritance, model character movement directions, and handle interactions such as scoring and eliminating non-player characters. This lesson enhances understanding of object-oriented features in JavaScript using real coding challenges.
We'll cover the following...
We'll cover the following...
Exercise 1:
Create a PlayerCharacter and a NonPlayerCharacter with a common ancestor Character. The characters are located in a 10x10 game field. All characters appear at a random location. Create the three classes, and make sure you can query where each character is.
Explanation:
This exercise has many solutions. We just used ...