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 trialannapoff
13,552 PointsI can't seem to get this to work!
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.
using the code we just built in IntelliJ, i adapted it for this exercise, but it's not working! am i supposed to use private int display? am i supposed to use different display names? like: SONY("Sony"),
any help would be much appreciated!
package com.example.model;
public enum Brand {
// Your code here
JVC,
Sony,
Coby,
Apple;
private mdisplayName;
private Brand(mdisplayName) {
mDisplayName = displayName;
mDisplayName = displayName.getDisplayName();
}
public getdiplayName() {
return mDisplayName;
}
}
1 Answer
Gregory Maxwell
35,429 PointsLooks like you can use Strings for the displays for this one, i.e. SONY("Sony").
Also, take a closer look at your constructor -- it won't compile as it stands. There are two problem areas: the argument list is malformed and the constructor's final line (which is unnecessary, anyway) is calling an invalid method for the type (which wasn't declared, but was presumably meant to be String).
Finally, check the spelling of your getDisplayName() method!
If you continue to have issues, the following worked for me:
package com.example.model;
public enum Brand {
JVC("JVC"), SONY("Sony"), COBY("Coby"), APPLE("Apple");
private String displayName;
private Brand(String displayName){
this.displayName = displayName;
}
public String getDisplayName(){
return this.displayName;
}
}
Hope that helps!