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 trialMUZ1407800 Doubt Milazi
11,813 Pointswhere is me going wrong?????
now we are ready to parcel in.In the constructor that takes a Parcel parameter,add code to set the member variable from the Parcel passed in.Remember,use the appropriate read methods based on types ,and order matters.
Parcel parcel = getParcel();
Kelvin Charles
4,383 PointsmTitle = in.readString(); mYear = in.readInt();
2 Answers
Nazar Nasirzada
5,347 Points1) In the 1st task your code should be like that:
<p>
public VideoGame(Parcel in) {
// Task 1 code here!
mTitle = in.readString();
mYear = in.readInt();
}
</p>
2) Now it's time to work on the CREATOR variable. The first thing we need to do is return a new VideoGame in the createFromParcel() method. Make sure you use the source parameter!
<p>
@Override
public VideoGame createFromParcel(Parcel source) {
// Task 2 code here!
return new VideoGame(source);
}
</p>
3) Finally, we need to update the length of the array returned in the Creator's 'newArray()' method. Use the size parameter passed in.
<p>
@Override
public VideoGame[] newArray(int size) {
// Task 3 code here!
return new VideoGame[size];
}
</p>
Sexual Potatoes
12,051 PointsCode does not work
Alex Londono
2,033 PointsThank you very much. You made it so compressed I feel so dumb now :(
Patrick Munemo
14,892 PointsThank you Nazar it worked very well
mark gilchrist
Courses Plus Student 33,169 Pointsmark gilchrist
Courses Plus Student 33,169 PointsI don't 100% understand the question but normally
Parcel parcel =new Parcel(); //creates a new parcel unless Parcel is a singleton
however this looks like it is asking you to parse a Parcel to the constructor of another class so
now you can call