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 Build the State Change Events

Kyle Baker
Kyle Baker
1,884 Points

Confused about "kind" argument in the Pomodoro app example.

I'm a bit confused about how the "kind" argument (is it an argument or parameter?) is defined. At what point do we tell the program that "kind" is FOCUS or BREAK?

2 Answers

Andrew Winkler
Andrew Winkler
37,739 Points

A parameter is a variable in a method definition. When a method is called, the arguments are the data you pass into the method's parameters. the quote to code by is "You define parameters, and you make arguments."

public void MyMethod(String myParam) { }

//versus

String myArg1 = "this is my argument";
myClass.MyMethod(myArg1);

Considering the code from the video:

public class Home {
  private Attempt mCurrentAttempt;
private void prepareAttempt(AttemptKind kind) {
    mCurrentAttempt = new Attempt(kind, "");
  }
}

"kind" is a parameter of prepareAttempt().

During this video, Craig is defining prepareAttempt method... short and sweet Craig will focus on the different "kinds" after he sets up the basic function that uses them.

Kyle Baker
Kyle Baker
1,884 Points

Great, thanks. This answers my question about whether it is an argument or parameter but what about, "At what point do we tell the program that "kind" is FOCUS or BREAK?"

When Craig is using the Evaluate Expression tool in the video, he is setting the state of the application (or "telling the program" that the kind is FOCUS or BREAK). AttemptKind is of type enum, so we are passing the argument AttemptKind.FOCUS or AttemptKind.BREAK into the prepareAttempt() method. This is how the app knows if the kind is FOCUS or BREAK.