CS 112 Project 1: Test-Driven Development
Objectives:
- Practice using TDD.
- Practice building methods.
- Practice using C++.
Introduction
This week's project is to use test-driven development (TDD) to finish the MovieCollectionproject for our friend Phil.
To do so, you are to use TDD to test and build the following methods:
-
a Movie::operator==(const Movie& movie2) const
method that returns true if the Movie to which this
message is sent is the same as movie2; and
returns false otherwise.
-
a MovieCollection::searchByYear(int year) method that
returns all movies produced in the given year.
Your test-method should check for the years 1939, 1981, and 1919.
-
a MovieCollection::searchByTitlePhrase(const string&
phrase) method that returns all movies with phrase
anywhere in their title.
Use what you have learned in this week's lab
to write a strong test-method.
-
a MovieCollection::addMovie(const Movie& newMovie) method
that appends newMovie to the collection.
-
a MovieCollection::removeMovie(const Movie& aMovie) method
that removes aMovie from the collection.
You may want to use the same test-method for this and
addMovie() -- since they are inverse operations,
they can be used in combination to leave the collection
in its original state.
-
a MovieCollection::save() const method that writes
the collection back to the text file used to construct the
collection.
Think carefully about how you can write a good test method for this
operation -- it takes some work, but it can be done.
You should use test-driven development for these methods:
- create test-methods for each of these operations,
and then
- write the methods to pass the tests.
A significant portion of your score will be based on the
effectiveness and thoroughness of your test-methods.
You are also to design and build an application that provides a
textual, menu-driven user-interface that runs in a console or
Terminal window, which Phil can use to search his collection for
movies, directors, and/or years, add movies to his collection,
remove movies from his collection, and save the collection.
For example, your application might display:
Welcome to Phil's Movie Collection Manager!
Please enter:
1 - to search the collection for movies by a given director
2 - to search the collection for movies made in a given year
3 - to search the collection for movies with a given phrase in their title
4 - to add a new movie to the collection
// ... other options ...
0 - to quit
--->
Alternatively, you might have the user enter characters ('a', 'b', 'c', ...).
Your program should use a loop that displays the menu,
reads the user's choice, and performs the corresponding function,
until the user chooses to quit.
As in the lab exercise, you should design this application using
object-oriented design
(hint: the word application is a noun!).
Each file should contain an opening comment communicating
who, where, when, what, and why for that file.
Your should use good programming style and make your code
self-documenting in terms of identifier names,
vertical and horizontal white space, etc.
Submit
-
A fully functional electronic copy of your project (including test classes),
in a folder named
/home/cs/112/current/yourUserName/proj1
(replacing yourUserName with your actual user-name).
-
A hard copy of this
grade sheet, attached to a hard copy of a
script file, in which you list the files of your project,
show that they compile and link correctly, and show that the run and
solve the problem completely and correctly.
CS >
112 >
Projects >
01
This page maintained by
Joel Adams.