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 Java Objects (Retired) Meet Objects Constructors

What is the purpose of GoKart challenge

I spent the last 20 years of my career writing programs. I have no idea of what this code is trying to accomplish!

GoKart.java
public class GoKart {
  private String mColor = "red";

  private String getColor() {
    return mColor;
  }
}

4 Answers

Tobias Edwards
Tobias Edwards
14,458 Points

The Go-Kart challenges are trying to help you to understand how to create and control classes in Java, along with learning to create methods inside these classes and pass values between classes and methods.

The challenges could be about anything, like 'apples and pears', but the 'Go-Kart' challenges show how this level of Java could be used in the real world, and tries to teach your the essentials of Java.

Tobias Edwards
Tobias Edwards
14,458 Points

You're pretty much room right in saying how one file holds the data and the other access's it. But it could be the other way around!

To make the code more structured and cleaned the program is split into two files: GoKart.java holds the 'meat' of the program - all the stuff you do to the variables, while Example.java accesses and chucks in values to GoKart.java.

The lessons try and teach us that it's cleaner and easier to follow if we pass code through multiple files, as long as those files have meaning - but don't create files for the sake of it! If this doesn't explain things I would suggest sending your question directly to Treehouse.

Lastly, out of interest, what 'simple' language were you using before? :)

Thanks. What I don't understand is what are the example.java and the GoKart.java files doing. Does one hold the data and the other is the program that accesses the data? I can make the challenge work, but I have no idea what we are trying to accomplish. I must admit, JAVA is not an easy language to use. The language I used was a whole lot simpler.

It was a universal string language developed by Bell Labs(AT&T). There were no semi colons or curly braces. IFs, ELSIFs and always ending with a FI(Backwards IF), and SUB ROUTINES. I guess the hardest part is learning new terminology. Thanks for explaining what the different files do.

Dan