Return to Video

Using Interfaces for Algorithm Reuse Average Area - Intro to Java Programming

  • 0:00 - 0:04
    You've seen some interesting interfaces with drawable and likeable, but let me
  • 0:04 - 0:09
    give you another very common reason why people like to use interfaces. And that
  • 0:09 - 0:16
    is to be able to reuse an algorithm. Consider a common algorithm to compute an
  • 0:16 - 0:21
    average. Here I have an array of countries, each of which has a name and an
  • 0:21 - 0:27
    area. And I want to know, what is the average area of all of these countries.
  • 0:27 - 0:30
    Now of course, I could write a loop to compute that, but lets say I want to a
  • 0:30 - 0:35
    method that does this for any set of countries. So, I'd like you to complete
  • 0:35 - 0:39
    this method that takes an array of countries. For each of them, find out what
  • 0:39 - 0:44
    the area is simply by calling the Get Area method. Add up all those areas, and
  • 0:44 - 0:47
    then return the average.
Cím:
Using Interfaces for Algorithm Reuse Average Area - Intro to Java Programming
Leírás:

more » « less
Video Language:
English
Team:
Udacity
Projekt:
cs046: Intro to Programming
Duration:
0:48

English subtitles

Felülvizsgálatok Compare revisions