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 trialAndrea De Nuzzo
Courses Plus Student 639 PointsWhat kind of information are we passing to the variable game in this.game = game?
Ok, I'm a little confused on this one. At minute 1:35 Craig makes a constructor that has as a parameter the creation of a game object from class Game
public Prompter(Game game){
this.game = game;
}
I dont really get what kind of information we are passing now to the constructon. If it was a int would be a number, a String would be a word or sentence, char would be a single letter. But what happens when we pass as parameter an object of a class we actually created? What kind of information is stored? Thanks!
1 Answer
Livia Galeazzi
Java Web Development Techdegree Graduate 21,083 PointsIt's not an int or a String, it's a Game (an object of type Game). Each class you create can be used to build an object. The information passed is a reference to that object, which includes all variables and methods of that object.
See my other answer on this topic: https://teamtreehouse.com/community/game-game-this-is-so-confusing