29
Homework 14 • Due ( MT sections ) ( WTh sections ) at midnight Sun., 12/7 Mon., 12/8 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

Homework 14

  • Upload
    lis

  • View
    23

  • Download
    0

Embed Size (px)

DESCRIPTION

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 - PowerPoint PPT Presentation

Citation preview

Page 1: Homework 14

Homework 14

• Due ( MT sections )

( WTh sections )

at midnightSun., 12/7

Mon., 12/8

• Problemshttp://www.cs.hmc.edu/courses/2003/fall/cs5/week_14/homework.html

• Tutors availableSaturday afternoons Parsons Lab only (maybe)

Sunday afternoons Lac Lab and Parsons

Sunday evenings Lac Lab and Parsons

Monday evenings Lac Lab and Parsons

Page 2: Homework 14

• Tutors available -- contact information

Page 3: Homework 14

• Tutors available -- lab places and times

You may also seek out tutors away from the labs, by phone, in the dorms, etc.

Available in the LAC Lab (Linde Activities Center)

Available in Parsons PC Labs (the CIS classrooms)

Page 4: Homework 14

Visualizing Objects

FilmDBallFilms

type

name

addFilm displayAllFilms

int countFilm[] films

films[0] films[1] films[2]

DirectorDBallDirs

type

name

addDirector displayAllDirectors

int countDirector[] dirs dirs[1] dirs[2]

…dirs[0]

int capacity

int capacity

Page 5: Homework 14

Visualizing Objects

Filmf

type

name

display getTitle

String title int year

Directord

type

name

getFullName getFilmDB

String fname

String lname

String rating

double review

Director dir

FilmDB filmDB

Page 6: Homework 14

Overview

public static void main(String[] args){ // create a FilmDB and a DirectorDB… // start a large while loop

Page 7: Homework 14

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!

(6) get year, rating, and review

(7) create new film

(5) create and add director, if needed

(8) ADD

f

d

f tof to

allFilms

d’s filmDB

Page 8: Homework 14

Method Matching

allFilms (a FilmDB)addFilm

allDirs (a DirectorDB)

addDirector

f (a Film)

getFullName

displayAllFilms

getFilmDB

displayFilmsByDirector

d (a Director)

displayAllDirectors

getTitle

findDirectorByName

checkForFilm

Page 9: Homework 14

Option 7 -- high level

if (uc == 7) // adding a film

Page 10: Homework 14

This space for rent... cheap!

Page 11: Homework 14

Finding a director...

public Director findDirectorByName(String fname, String lname)// inside class DirectorDB

addDirector displayAllDirectors

int countDirector[] dirs dirs[1] dirs[2] …dirs[0]

int capacity

Page 12: Homework 14

Getting a Director’s name

public String getFullName()// inside class Director

getFullName getFilmDB

String fname

String lname

FilmDB filmDB

Page 13: Homework 14

Printing a director’s films

public void displayFilmsByDirector(String fname, String lname)// inside class DirectorDB

addDirector displayAllDirectors

int count

Director[] dirs dirs[1] dirs[2] …dirs[0]

Page 14: Homework 14

Other methods...

public void displayFilmsByDirector(String fname, String lname)// inside class DirectorDB

Page 15: Homework 14

films[0] films[1] films[2]

dirs[1] dirs[2]

…dirs[0]

FilmDBtype

int

Film[]

DirectorDBtype

int

Director[]

Page 16: Homework 14

Visualizing Objects

FDBname

addFilm displayAllFilms

count

films

DDBname

addDirector displayAllDirectors

count

dirs

Page 17: Homework 14

Visualizing Objects

fname

display getTitle

title year

dname

getFullName getFilmDB

fname

lname

rating

review

dir

filmDB

Page 18: Homework 14

Visualizing Objects

Filmtype

String int

Directortype

String

String

String

double

Director

FilmDB

Page 19: Homework 14

Finding a director...

public Director findDirectorByName(String fname, String lname)// inside class DirectorDB

Page 20: Homework 14

addDirector displayAllDirectors

int count

Director[] dirs dirs[1] dirs[2] …dirs[0]

getFullName getFilmDB

String fname

String lname

FilmDB filmDB

addDirector displayAllDirectors

int count

Director[] dirs dirs[1] dirs[2] …dirs[0]

Page 21: Homework 14

Printing a director...

public String getFullName()// inside class Director

Page 22: Homework 14

Printing a director’s films

public void displayFilmsByDirector(String fname, String lname)// inside class DirectorDB

Page 23: Homework 14

Homework 14

• Due ( MT sections )

( WTh sections )

at midnightSun., 12/9

Mon., 12/10

• Problemshttp://www.cs.hmc.edu/courses/2001/fall/cs5/week_14/homework.html

• Tutors availableSaturday 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 LACAndrew Klose & Jessica Lee in AC

M. Chase & Chris Lee - LACW. Berriel & A. Klose - AC

Page 24: Homework 14

Overview

public static void main(String[] args){ // Create a FilmDB and a DirectorDB

Page 25: Homework 14

Overview

// create a FilmDB and a DirectorDB… // start a large while loop

Page 26: Homework 14

Option 7 -- high level

if (userchoice == 7) // adding a film

Page 27: Homework 14

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!

(6) get year, rating, and review

(7) create new film

(5) create and add director, if needed

(8) ADD

f

d

d tof tof to

DDB

FDB

d’s filmDB

Page 28: Homework 14

Method Matching

FDB (a FilmDB)addFilm

DDB (a DirectorDB)

addDirector

f (a Film)

getFullName

displayAllFilms

getFilmDB

displayFilmsByDirector

d (a Director)

displayAllDirectors

getTitle

findDirectorByName

findFilmByTitle

Page 29: Homework 14

Option 7 -- code

if (userchoice == 7) // adding a film