CS 1110/1111: Introduction to Programming

Lecture 39

Announcements

A student asked me to compose a rhyme about this class:

In just one course we learned to code,
which didn't make out heads explode!
We learned of loops, both for and while.
Of methods we learned quite a pile
of useful facts, like how they run
and how recursion makes them hum.
Of ifs, assignments, scope, and class
we learned from day one till the last.
while (this.rhymeHasMade(noSense)) {
    repeat this class;
    and don't feel dense;
}

Sometimes it takes a while, it's true,
to understand what code can do.

Talking Points

Movie & Theater Coded

We'll explore alternative designs.

Theater
- movies : ArrayList<Movie>
+ addMovie(Movie) : void
+ removeMovie(Movie) : void
+ isShowing(Movie) : boolean
- moviesAgreeWithMe() : boolean
Movie
- theaters : ArrayList<Theater>
+ addTheater(Theater) : void
+ removeTheater(Theater) : void
+ isAt(Theater) : boolean
- theatersAgreeWithMe() : boolean

Maybe only theaters know the showing information:

Theater
- movies : ArrayList<Movie>
+ addMovie(Movie) : void
+ removeMovie(Movie) : void
+ isShowing(Movie) : boolean
+ whatShowing() : ArrayList<Movie>
Movie
 
+ addTheater(Theater) : void
+ removeTheater(Theater) : void
+ isAt(Theater) : boolean
+ whereShowing() : ArrayList<Theater>

Maybe showings are stored elsewhere:

Theater
 
+ addMovie(Movie) : void
+ removeMovie(Movie) : void
+ isShowing(Movie) : boolean
+ whatShowing() : ArrayList<Movie>
Movie
 
+ addTheater(Theater) : void
+ removeTheater(Theater) : void
+ isAt(Theater) : boolean
+ whereShowing() : ArrayList<Theater>
Showing
- movie: Movie
- theater: Theater
- static allShowings : ArrayList<Showing>
+ static startShowing(Theater, Movie): void
+ static stopShowing(Theater, Movie): void
+ static isShowing(Theater, Movie): boolean
+ static isShowing(Movie): ArrayList<Theater>
+ static isShowing(Theater): ArrayList<Movie>

From Lecture

002 (1pm): Movie.java, Theater.java, Showing.java, CopyOfMovie.java, CopyOfTheater.java

001 (3pm): Jumper.java, JumperScreen.java.

Copyright © 2014 by Luther Tychonievich. All rights reserved.