CS 202 - Computer Science II - Spring 2007
Project 4
Loyola College >
Department of Computer Science >
Dr. James Glenn >
CS 202 >
Projects >
Project 4
Due
Monday, April 30th at 11:59pm.
Projects submitted after the due date will be assessed a 20% penalty per day.
Projects will not be accepted more than four days late.
Objectives
- to use Java's List classes to implement efficient solutions
Introduction
Imagine a project aimed at understanding what makes Tipover puzzles hard.
Such a project may have use for a Tipover server that collects information
related to how much difficulty humans have when solving puzzles. For this
project, you will create a class that can maintain that information.
Assignment
Create a class called TipoverDatabase that keeps track of
players and puzzles, with the puzzles grouped by some initial estimate of their
difficulty (the data gathered will help determine if those initial estimates
were correct). For each player, the database
will store the player's password, the list of puzzles the player has
solved, the time taken to solve them, and puzzles attempted but not solved.
For each puzzle, the database will record the number of players who have
attempted the puzzle, the number of players who have solved the puzzle,
and the average time taken by all the players who have solved the puzzle.
TipoverDatabase must have the following methods and constructors.
- TipoverDatabase(), a constructor to initialize an
empty database;
- addPuzzle(String filename, int difficulty), which
adds the puzzle of the given difficulty in the file with the given name
to the database;
- boolean addPlayer(String name, String pass), which registers
a new player with the given username and password and returns
true or false according to whether the username
was available or not;
- boolean verifyPassword(String name, String pass), which
determines if there is a player registered with the given name
and, if so, whether the given password is correct for that player;
- void changePassword(String name, String pass), which
changes the password for the given existing player to the given
value;
- List< String > getPuzzles(String name, int difficulty),
which returns a list of filenames containing the puzzles of the
specified difficulty
that have not yet been attempted by the given player;
- void puzzleSolved(String username, String puzzleFile, int time),
which updates the database to reflect that the player with the given
username solved the given puzzle in the given amount of time
(in seconds);
- void puzzleAbandoned(String username, String puzzleFile),
which updates the database to reflect that the player with the
given name has given up on the given puzzle;
- List< String > getPlayerStatistics(String username), which
returns a list with one item for each puzzle giving the status
(not attempted, abandoned, or solved [and in what time])
of that puzzle for the given player; and
- List< Number > getPuzzleStatistics(String filename), which
returns a 3-item list containing the number of players who have
attempted the puzzle in the file with the given name, the number
of players who have solved it, and their average time (as a
Double) in that order.
You may add methods to the required classes, and you can create more classes
as you see fit. For example, if you decide you need a list of players and
the data for them, you may decide to create a Player object.
Similarly, you may wish to create a Puzzle object if you decide
you need a list of puzzles and the required information about those puzzles.
Grading
- Execution: 80% for correct execution of the required methods.
- Comments and Style: 10% for comments including a comment
describing each class and each method within each class. Comments
for methods should give an overall description of what the method
does and should explain the use of each argument as well as what
value is returned, if any. Use of Javadoc comments is encouraged
but not required. Variable names should be chosen wisely.
- Efficiency: 10% for efficient solutions and an explanation of
why you chose the data structures you did (or an explanation of
why it didn't matter which data structures you chose).
Advice
- You should think carefully about the other classes you will have to
create. What fields will they have to have in order to keep
the data that will be requested by the TipoverDatabase
methods? What methods will they have to update that data?
- Test those extra classes you created before working on
TipoverDatabase.
- Create TipoverDatabase last. You should write and
test the methods a few at a time. addPlayer, would be
a good place to start,
followed by verifyPassword and setPassword, and
after them
addPuzzle and getPuzzles.
Finally, write the puzzleSolved, puzzleAbandoned,
getPlayerStatistics, and getPuzzleStatistics methods.
Submissions
Submit through e-mail the source code (.java files) for any
classes you created (that should include TipoverDatabase).
Submit your defense of your data structures either on paper or in the body
of the e-mail message to which your code is attached.