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 trialmarkmneimneh
14,132 PointsChallenge Question wording seems to be wrong
The Challenge is
Challenge Task 2 of 2
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. PS. Sorry for making you type that all out. You can do it in your IDE if you want to.
Bummer! I expected to find the display name of 'JVC', but I didn't. Please correct it
Bummer is saying/expecting JVC ... but the Challenge says we should expect Jvc ... note the case.
This is my enum
package sample.model;
/**
-
Created by Mark on 10/1/2016. */
public enum Brand { JVC("Jvc"), SONY("Sony"), COBY("Coby"), APPLE("Apple");
private final String mName; private Brand(String name) { this.mName = name; } public String getDisplayName(){ return mName; }
}
It gets a bummer unless I replace JVC("Jvc"), with JVC("JVC"),
Can someone please explain.
Thanks
package com.example.model;
public enum Brand {
JVC("Jvc"),
SONY("Sony"),
COBY("Coby"),
APPLE("Apple");
private final String mName;
private Brand(String name) {
this.mName = name;
}
public String getDisplayName(){
return mName;
}
}
5 Answers
lloyso
14,141 Pointspackage com.example.model;
public enum Brand {
JVC("JVC"), SONY("Sony"), COBY("Coby"), APPLE("Apple");
private String mDisplayName;
Brand(String displayName) { mDisplayName = displayName; }
public String getDisplayName(){ return mDisplayName; } }
markmneimneh
14,132 PointsWell .... Assume that I am from Mars and never heard of JVC.
Once again, I think wording in the Challenge is wrong; and once again, Craigs should fix the wording so folks from different parts of the world don't have to dig out what JVC is.
Mike Ulanoski
13,319 PointsJapan Victor Corporation
Zach Freitag
20,341 PointsSpoiler Alert!
package com.example.model;
public enum Brand {
// Your code here
JVC("JVC"),
SONY("Sony"),
COBY("Coby"),
APPLE("Apple");
private String mDisplayName;
// Constructor
Brand(String displayName) {
mDisplayName = displayName;
}
// Getter
public String getDisplayName(){
return mDisplayName;
}
}
Hope these comments help explain what's going on.
Chance Edward
4,507 PointsMr.Freitag this was VERY helpful😣
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 PointsWell , JVC is obviously abbreviation, and challenge and Craig expect it to be
JVC("JVC")
And my challenge error is:
I expected to find the display name of 'JVC', but I didn't. Please correct it
So the solution with all capitals is both logic and intuitive ... and machine hints you to make it all CAPS...
If you are trying to use the task literally
eg: SONY should have a display name of Sony.
I think you should take into consideration that all corporations names ("Sony", "Coby", "Apple") are not ALL caps except for JVC, which is abbreviation, and has to be written in all CAPS both for enum name as well as display name
lloyso
14,141 PointsThis is what worked for me on task 2
package com.example.model;
public enum Brand { // Your code here JVC("JVC"), SONY("Sony"), COBY("Coby"), APPLE("Apple");
private String mDisplayName;
// Constructor Brand(String displayName) { mDisplayName = displayName; }
// Getter public String getDisplayName(){ return mDisplayName; } }
chase singhofen
3,811 Pointschase singhofen
3,811 Pointsthe above from lloyso worked for me after trying it for hours.
the workspace is fustrating at times b/c when you get error you have no idea how to fix the syntax editor is extreamly vague.