CS 280 Spring 2009 Assignment 9 – Addendum
Background Knowledge:
- Valid values related
to Scores were given in the original assignment handout:
- Month – 1-12
- Date – 1-31
- Year – 1995-2010
- Score – 0-30000
- Level Reached – 0-10
- The partial Player
class that I gave you has constants for the min and max handicaps: 0-10.
Names cannot be validated.
- It is not necessary to
know what game we are talking about. With changes in constants (valid
scores, number of levels), this could be used for any game.
- Random PlayerIDs can
be generated. In fact the default is that it is (8 long). Notice the
initialization of the instance variable in the Player class.
- The setting of a
handicap via “Auto-Handicap” is intentionally up to you, to allow some
creativity. Note that high handicap is BAD – they need a lot of help, and
low handicap is GOOD. Other than that, you can consider how much they’ve
played, what their high score is, levels that they’ve reached, average
scores, etc
- With such freedom, it
is beyond suspicious if any two people come up with the exact same
algorithm.
Miscellaneous Details:
- Documentation should
be available on the Player and Score classes. It is provided as Javadoc
documents, which are html files that can be found inside the project
folder included in the zip. The javadoc includes methods that I’ve
written, methods I’m asking you to write, and perhaps some that I was
going to ask you to write but decided to skip.
- Unfortunately, I did
not generate Javadoc for the ID class. However, you can generate it from
within NetBeans.
- In general, you would
make your GUI class in a different project than the Score and Player
project, because the Score and Player classes might be useful in a lot of
projects besides yours. (Score and Player fit well in the same project
because of the strong relationship (aggregation and dependency) between
Score and Player). ID is natural in its own project because it is useful
for very many projects. However, as beginners, you may well be better off
taking the expedient path and just including all classes in one project
and package. It’s not what you will be wanting to do for later bigger
projects, but for getting started …If you do, you might have to change
some package and some import statements.
- We’re no longer going
to assume that the clerk enters valid and reasonable values. Note that
the info on mutators for the Score class included valid ranges for the
instance variables. Player and Score mutator methods should ensure that
valid values are passed and return a Boolean. The GUI class can, if
appropriate, call the appropriate mutator and check the return (true or
false) as part of checking user inputs. It is the GUI class’s
responsibility to give the user a message! (Player and Score should be
general enough that we don’t know that a message is always the right thing
to do). In an event-driven world – you (the GUI class) can display a
one-time message and give control back to the user. Note the next point
though!
- Don’t try to calculate
anything if the inputs are bad – only display a message and let the user
back into control.
- If the user enters
letters instead of numbers in numeric text fields, the parse commands will
crash. We’re still going to ignore these types of problems. (No need to
catch and complain about this). (NOTE also that no entry in a text field
is like having non-numeric).
- However, we have
talked about exceptions; if you want the extra challenge, you can handle
these exceptions.
- The GUI class is
showing and not showing various components (controls) based on what makes
sense at a given time. The easiest way to do this is to put these
components on a jPanel. Then the jPanel can be made visible or not all at
once using one statement. (jPanels help to make the GUI neater anyway).
- The dialog box for “See
totals” in the initial assignment had a few flaws:
- The handicap was
wrong – the wrong run of the program was captured
- Redundant info is
included – the GUI code included info (max score, ave score) that is also
provided in toString
- It would be nice if
the average score was formatted to limit the number of decimal places.