1 of 12

A Second Look at Classes and Objects

Michael Wagner

2 of 12

Instance Methods/Fields v. Static Methods/Fields

3 of 12

Methods and Objects

4 of 12

The toString Method

5 of 12

Writing an equals Method

6 of 12

Example

Read all the movies from a movie database. Create a Movie and a MovieDemo class.

Movie

  • Equals method that accepts a year and a genre
  • toString method that describes the movie
  • Static method called loadDatabase

MovieDemo

  • Static method that asks the user for a year and genre
    • Search for movies based on year and genre
  • Static method to randomly print a movie

Movie database: movie_list.txt

7 of 12

Copy Constructor and Method

8 of 12

Aggregation

9 of 12

this Keyword

10 of 12

Enumeration

11 of 12

Example

Ask the user for a day of the week. Convert this word to spanish.

12 of 12

Garbage Collection