Practice with Classes: Movie
- Make a Movie class and a MovieTest class.
- Static variables: ?
- Instance variables: title, ... , ?
- Are there default values for these?
- Constructors:
- Is a title required? Yes. Make it so using a constructor
- What other combination of parameters could be used to make a movie object?
- Static methods:
- Instance methods:
Deciding which methods there are depends on the big picture of what you are doing with the movies:
(i) possibly putting them into a playlist to play on a DVD player or video player,
or (ii) programming a movie rental place.
To do: Make 3 or 4 movies using MovieTest.java
What would we name each Movie object?
Array lists : a nicer solution
Other useful code:
m1 = new Movie("Moonrise Kingdom"); movieCollection.add(new Movie("Wrath of Khan")); movieCollection.add(m1); //adds to end //Print out the list of movies use a for-each loop for (Movie m : movieCollection) { System.out.println(m.toString()); }
To do: Can you print out only the titles of the movies?
This Movie.java and MovieTest.java will not be marked -- you just have to do them and I'll comment on them and correct them. I'll be marking the next assigment on bank accounts