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 trialSohale Vu
18,322 PointsCreating the Message Code Challenge
I'm trying to get the 1st part of this challenge to work. I have declared the new ParseObject as
ParseObject Event = new ParseObject();
below where it asks to place the code. It just tells me that I have compiler error.
8 Answers
John W
21,558 PointsThe question asks you to define a ParseObject object with the class name parameter "Event", not an object instance named "Event.
Also, the ParseObject constructor requires a String parameter as the class name parameter. Hence you should define it something like this:
ParseObject someNameForTheInstance = new ParseObject( "Event" );
Paul Stevens
4,125 PointsHello,
eventName is a string, not a variable and has to have quotation marks around it :
mEvent.put("eventName", "Birthday party");
That should sort it out.
james white
78,399 PointsYou are right, Marc-Oliver, when you say: "This one seems tricky, indeed."
Personally I'm not seeing where "mEvent" is defined anywhere?!
The challenge says:
Challenge Task 2 of 3
Set the name of the event as "Birthday party". Use "eventName" as the key.
So I decided to go with (because it passed):
import android.app.Activity;
import com.parse.ParseObject;
import java.util.Date;
import java.util.GregorianCalendar;
public class MainActivity extends Activity {
// Some code omitted!
public void addNewEvent() {
// param 1 = year, param 2 = month, param 3 = day
Date date = new GregorianCalendar(2014, 0, 1).getTime();
// Add code here!
ParseObject event = new ParseObject("Event");
event.put("eventName", "Birthday party");
event.put("eventDate",date);
}
}
Sohale Vu
18,322 PointsThank you very much John that helped out a lot. I do have a question on the second part of the challenge. I have put down
<p>i
mport android.app.Activity;
import com.parse.ParseObject;
import java.util.Date;
import java.util.GregorianCalendar;
public class MainActivity extends Activity {
// Some code omitted!
public void addNewEvent() {
// param 1 = year, param 2 = month, param 3 = day
Date date = new GregorianCalendar(2014, 0, 1).getTime();
// Add code here!
ParseObject mEvent = new ParseObject( "Event" );
mEvent.put(eventName, "Birthday party");
}
}
</p>
```
but did doesn't seem to be working.
Marc-Oliver Gern
8,747 PointsThis one seems tricky, indeed. I am stuck with task 3 as well.
Ajay Maheshwari
Courses Plus Student 6,423 PointsPut the event name in double quotes "eventname"
Ajay Maheshwari
Courses Plus Student 6,423 PointsMarc-Oliver Gern please try this
import android.app.Activity;
import com.parse.ParseObject;
import java.util.Date;
import java.util.GregorianCalendar;
public class MainActivity extends Activity {
// Some code omitted!
public void addNewEvent() {
// param 1 = year, param 2 = month, param 3 = day
Date date = new GregorianCalendar(2014, 0, 1).getTime();
//date.put("eventDate",(2014,0,1));
ParseObject mEvent = new ParseObject( "Event" );
mEvent.put("eventName", "Birthday party");
mEvent.put("eventDate",date);
// Add code here!
}
}
MUZ141063 Erick Chapupa
4,477 Pointshow did you guys come up with that code,i need ton understasnd thanx