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

Challenge 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

com/example/model/Brand.java
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

package 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; } }

chase singhofen
chase singhofen
3,811 Points

the 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.

Well .... 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.

Japan Victor Corporation

Spoiler 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.

Mr.Freitag this was VERY helpful😣

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

Well , 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

This 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; } }