Class for dog


public Dog(int dogsAge) {


Instruction: Inside of the constructor block, set the instance variable age equal to the dogsAge parameter


Here's code for a car constructor:

public Car (String model, int year){
  this.model = model;
  this.year = year;

The this keyword references a property of the object. In a constructor, it's a property of the object being created. When, in the Car constructor, we reference this.model, we are referencing the model instance variable of the current Car object.

This method could similarly be used to reference this.age of the Dog object you're working on.


Didn't work, could you please read the instruction again and if possible write the whole code for that part, I'd appreciate it!:slight_smile:


I cannot provide the code for you. Study the notation provided for assigning instance variables and attempt to adapt it to your code.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.