Let's Take out lunch step 4 stuck

Hi everyone,
I’m currently having trouble wrapping my head around on what question 4 is asking.
Here is a link to the project: https://www.codecademy.com/courses/learn-intermediate-java/projects/intermediate-java-collections-takeout

public class Food implements Priced<Integer>{
  private String name;
  private String description;
  private int price;

  public Food (String name, String description, int price){
    this.name = name;
    this.description = description;
    this.price = price;
  }

  @Override
  
}

here is what I got so far but I am totally lost when i look at the hint
" A toString() method can be overridden to display a custom String representation of an object which is useful when printing the object. "

I have tried going back to the lessons but it just wont stick on how generics work.

The default toString() method gives you the class name and the memory address of the object. It’s not very helpful. So instead, you can define your own so that printing your food object gives a useful result that actually describes the object.

Something like the following should work. I didn’t carefully consider spaces and so on, so you’ll need to modify it or write your own, but hopefully you can see the purpose of it now.

@Override    
public String toString() {
    return this.name + this.description + "Cost:  " + this.price;
}
1 Like