English subtitles

← Objects Demo - Intro to Java Programming

Get Embed Code
7 Languages

Showing Revision 4 created 05/25/2016 by Udacity Robot.

  1. Here we hear from BlueJ. And it would really good idea if you fire up your own
  2. BlueJ and move to lesson two days as your project. When you open it, you will
  3. see the screen with a Day block here. And this is what gives us objects. Let me
  4. show you how to make an object. You right-click on it, and you select the line
  5. that says New Day. You can now give it a name. For right now, we'll accept the
  6. default. Down here, you'll find your first object. This is how BlueJ represents
  7. objects. As little blobs, it's a little-known fact that all objects are red.
  8. And to manipulate an object, you again, right-click on it. You can ask it to
  9. get the current year. Here's the answer. This particular day is somewhere in
  10. 2013. See when, the month is March, 3, the day of the month, is the 20th.
  11. That's the day that I recorded this lesson. We can make another day object. And
  12. now, let's pick, the first line here. Now, we ask which year month and day we
  13. might actually want. Let's fill in something. Then, we'll pick a year of 1964.
  14. The month of 11 or November, and the day of 28, as I'm sure everyone remembers,
  15. on November 28th, 1964, the first spaceship was, to Mars, was launched. Now
  16. here, we have another day object. It looks just like the first one. It has a
  17. different name. But if we wanted to find out anything about it, so we can in
  18. the same way ask it what's your year, and here it tells us. Now, let's do
  19. something more interesting. Let's take our first object here and let's ask it
  20. what day comes a hundred days later. Now, it doesn't look like it, but this
  21. object now has changed. It has moved itself a hundred days later. Remember, it
  22. was originally March 20th. Now, when we ask it what's your month, you'll see
  23. it's June. That makes sense, from March, 100 days is June, or maybe it would be
  24. July. Somehow, this thing knows how to do this computation. How about the day?
  25. It's June 28th. I wouldn't have known how to do that. Except by tediously
  26. getting out a calendar and counting the days, but our day object knows. How
  27. does it know? I don't know, and I don't care. It doesn't matter. I can use it,
  28. as long as I understand what it does for me. So, that's a great example of an
  29. object. Something that knows how to do a very specific thing, namely to deal
  30. with calendars, just like the water heater knows how to do very specific thing,
  31. namely to heat water.