Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Build a JavaFX Application Build a Pomodoro App Enums

chase singhofen
chase singhofen
3,811 Points

I dont know if i am using the getter correct. my syntax errors are all over the place with minor edits

Okay so now let's add a required display name property. At this time, just use the proper case of the brand. eg: SONY should have a display name of Sony.

Create a constructor that takes the display name. And add a public getter that returns the display name. Give it the name getDisplayName.

com/example/model/Brand.java
package com.example.model;

public enum Brand {
  // Your code here
  JVC, SONY, COBY, APPLE;
  private Brand displayName;

    Brand(String name) {
        displayName = SONY;
    }

    public Brand getDisplayName() {
        return displayName;
    }
}

1 Answer

Your enums should have parentheses after them with a string inside because:

Brand(String name)

The above means you need to do something like JVC("jvc"), SONY("sony") . . .etc