Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Objects (Retired) Delivering the MVP Validation

Kevin McFarland
Kevin McFarland
5,122 Points

What exactly is the extent of "Delivering the MVP" challenge in Java Objects Stage 4?

Here's the Task...

Challenge Task 1 of 1

So I was wondering if you could help me with some of these code challenges. As you might've seen when a member field name doesn't match the style we've talked about, I send an error about it. Let's write some code to validate the style of the field name.

I've added the method validatedFieldName it will return the validated field name. If the value passed in doesn't meet the requirements, throw an IllegalArgumentException. I'll keep you posted on the results every time you press check work.

Code Challenge

public class TeacherAssistant {

  public static String validatedFieldName(String fieldName) {

    // These things should be verified:
    // 1.  Member fields must start with an 'm'
    // 2.  The second letter in the field name must be uppercased to ensure camel-casing

    // NOTE:  To check if something is not equal use the != symbol. eg: 3 != 4

    return fieldName;
  }

}

I'm having a hard time ascertaining the extent of the code challenge.

Are we being ask to iterate over fieldName - checking for lowercase first letter("m"), uppercase second letter and then lower case on all subsequent letters within fieldName?

Throwing exceptions in each case if not validating true?

Or am I over thinking the process?

Thanks,

Kevin

1 Answer

Tulio Albuquerque
Tulio Albuquerque
12,676 Points

you are been ask to see if the first letter is 'm' and if the second letter is uppercase, if one of those is false you throw the exception.