Exercise on Classes

We'll apply our knowledge of classes to a video game model in which we there are two types of characters.

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.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.