This course will be retired on June 1, 2025.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
We can now create some data model objects to hold the data we are getting from the Dark Sky service.
Related Links
- How to generate getters and setters without the "m" prefix (skip to the 5:33 mark)
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Back here in Android Studio,
let's create a new class in our project.
0:00
New Java class,
we'll call it current weather.
0:06
And hit OK.
0:08
Cool, next, let's define our variables.
0:18
So we need a private string.
0:23
We'll need one for the location label.
0:27
We'll need a private string for our icon.
0:31
A private long for our time.
0:39
The temperature is in double value.
0:45
As is humidity.
0:55
And for
precipitation we'll do a precipChance.
1:02
And we'll need a string for our summary.
1:09
Now we just need to type out
all of our getters and setters.
1:14
Well, okay, let's not type them all out.
1:17
We can use Android Studio's auto
generation feature to accomplish this.
1:20
If we go to Code, Generate,
Getter and Setter,
1:25
we can select all the variables,
and hit OK.
1:29
And there they are.
1:33
Very nice.
1:36
This is a great start for our data model.
1:37
We'll be making a few tweaks as
we continue on with the project.
1:40
For now, though, let's jump back and
look at this data format called JSON.
1:43
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up