290 likes | 455 Views
Homework 14. Sun., 12/7. ( MT sections ). Due. at midnight. Mon., 12/8. ( WTh sections ). Problems. http://www.cs.hmc.edu/courses/2003/fall/cs5/week_14/homework.html. Tutors available. Saturday afternoons Parsons Lab only (maybe) Sunday afternoons Lac Lab and Parsons
E N D
Homework 14 Sun., 12/7 ( MT sections ) • Due at midnight Mon., 12/8 ( WTh sections ) • Problems http://www.cs.hmc.edu/courses/2003/fall/cs5/week_14/homework.html • Tutors available Saturday afternoons Parsons Lab only (maybe) Sunday afternoons Lac Lab and Parsons Sunday evenings Lac Lab and Parsons Monday evenings Lac Lab and Parsons
Tutors available -- lab places and times Available in Parsons PC Labs (the CIS classrooms) Available in the LAC Lab (Linde Activities Center) You may also seek out tutors away from the labs, by phone, in the dorms, etc.
Visualizing Objects int capacity int count … films[0] films[1] films[2] Film[] films … addFilm displayAllFilms type FilmDB allFilms name int capacity int count … Director[] dirs dirs[0] dirs[1] dirs[2] addDirector displayAllDirectors type DirectorDB allDirs name
Visualizing Objects Director dir String rating String title double review int year display getTitle type Film f name String fname FilmDB filmDB String lname … getFullName getFilmDB type Director d name
Overview public static void main(String[] args) { // create a FilmDB and a DirectorDB… // start a large while loop
Option 7 -- high level if (uc == 7) // adding a film (1) get title (2) check if film is already there! (3) get director’s first and last name (4) check if director is already there! (5) create and add director, if needed d (6) get year, rating, and review (7) create new film f to allFilms f (8) ADD to d’s filmDB f
Method Matching addFilm allFilms (a FilmDB) addDirector getFullName displayAllFilms allDirs (a DirectorDB) getFilmDB displayFilmsByDirector f (a Film) displayAllDirectors getTitle findDirectorByName d (a Director) checkForFilm
Option 7 -- high level if (uc == 7) // adding a film
Finding a director... int capacity int count … Director[] dirs dirs[0] dirs[1] dirs[2] addDirector displayAllDirectors // inside class DirectorDB public Director findDirectorByName(String fname, String lname)
Getting a Director’s name String fname FilmDB filmDB String lname … getFullName getFilmDB // inside class Director public String getFullName()
Printing a director’s films int count … dirs[0] dirs[1] dirs[2] Director[] dirs addDirector displayAllDirectors // inside class DirectorDB public void displayFilmsByDirector(String fname, String lname)
Other methods... // inside class DirectorDB public void displayFilmsByDirector(String fname, String lname)
int … films[0] films[1] films[2] Film[] type FilmDB int … dirs[0] dirs[1] dirs[2] Director[] type DirectorDB
Visualizing Objects count films … addFilm displayAllFilms FDB name count dirs addDirector displayAllDirectors DDB name
Visualizing Objects dir rating title review year display getTitle f name fname filmDB lname … getFullName getFilmDB d name
Visualizing Objects Director String String double int type Film String FilmDB String type Director
Finding a director... // inside class DirectorDB public Director findDirectorByName(String fname, String lname)
int count … dirs[0] dirs[1] dirs[2] Director[] dirs addDirector displayAllDirectors String fname FilmDB filmDB String lname … getFullName getFilmDB int count … dirs[0] dirs[1] dirs[2] Director[] dirs addDirector displayAllDirectors
Printing a director... // inside class Director public String getFullName()
Printing a director’s films // inside class DirectorDB public void displayFilmsByDirector(String fname, String lname)
Homework 14 Sun., 12/9 ( MT sections ) • Due at midnight Mon., 12/10 ( WTh sections ) • Problems http://www.cs.hmc.edu/courses/2001/fall/cs5/week_14/homework.html • Tutors available Saturday afternoons Lac Lab Sunday afternoons Lac Lab and AC Sunday evenings Lac Lab and AC Monday evenings Lac Lab and AC Joanna Wu & Jenny Xu LAC Andrew Klose & Jessica Lee in AC M. Chase & Chris Lee - LAC W. Berriel & A. Klose - AC
Overview public static void main(String[] args) { // Create a FilmDB and a DirectorDB
Overview // create a FilmDB and a DirectorDB… // start a large while loop
Option 7 -- high level if (userchoice == 7) // adding a film
Option 7 -- high level if (userchoice == 7) // adding a film (1) get title (2) check if film is already there! (3) get director’s first and last name (4) check if director is already there! (5) create and add director, if needed d (6) get year, rating, and review (7) create new film f to DDB d to (8) ADD FDB f to d’s filmDB f
Method Matching addFilm FDB (a FilmDB) addDirector getFullName displayAllFilms DDB (a DirectorDB) getFilmDB displayFilmsByDirector f (a Film) displayAllDirectors getTitle findDirectorByName d (a Director) findFilmByTitle
Option 7 -- code if (userchoice == 7) // adding a film