© Doug Winnie 2021
D. WinnieEssential Java for AP CompScihttps://doi.org/10.1007/978-1-4842-6183-5_55

55. Class, Extend Thyself!

Doug Winnie1  
(1)
Mission Hills, KS, USA
 

With our basic class created for the mage, we can look at other characters in our game and see how they compare to each other. We can see from their character sheets that they each have different skills and rules that govern how these skills are populated with values at the time of instantiation and construction.

The Mage class defines strength, intelligence, agility, and wisdom as the main fields and then uses a set of calculations to create their values and determine hit points and mana:
public class Mage {
    // Name
    public String name;
    // Skill attributes
    public int strength; ...

Get Essential Java for AP CompSci: From Programming to Computer Science now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.