Modifying an existing class
Modifying a class: add or change a constructor parameter, property or method, then update every new call that creates its objects and re-run your tests.
Understanding Modifying an existing class in ACARA Digital Technologies Years 9–10
What it does: The new call passes both arguments, so it matches the updated constructor and the object gets a score. A method is added inside the class and can then be used on objects like p1.addPoints(5), which you should check by re-running your tests. Old calls leave the new parameter undefined, so update every new call to pass a value. The property needs this. in front of it. Without this.score, no property is stored on the object. Methods sit inside the class body beside the constructor, not inside it. JavaScript does not rename other uses. Old .score code would now give undefined.
Common mistakes: The new score property was added to the constructor body, but the parameter was not added. 'score' is undefined, so the constructor should be constructor(name, score). The new age property is being given the name parameter. It should store the age parameter: this.age = age;.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 743–781) and word search (Modules 743–809).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
this.score = score;Fill in the Blanks
Spot the Error
Student with a class code? Join your class →