-
Sat Nov 10 |
- Changed "must use a two dimensional array to represent the grid."
to
"must use a two (or higher) dimensional array to represent the grid."
- Added to "For Those Who Are Keen..." :
Write the program so that instead of hiding 4 lines of bones of lengths 4,3,3,2, the program
will hide an arbitrary number of lines of arbitrary length. Note that this is not possible: once
the size of the grid has been specified that puts limitations on the number and lengths of bonelines.
If you try this, you should restrict 'arbitrary' to sets of bonelines that will actually fit, or
write an algorithm to determine whether the set of bonelines can possibly fit. Otherwise, your
random placement algorithm might loop forever....
Recall that this is not required. If completed it will not be penalized nor rewarded.
|
Mon Nov 19 |
-
Added to requirements:
- You must read the guess from the user so that the user types an integer, presses 'return' and then types another integer and presses 'return'. The
row number should be input first and then the column number, but this order is not required.
- Users do odd things; in general when programming you should make sure
that nothing the user types
causes the program to behave errantly. However, for this assignment you
can assume that the user will type
nothing but integers when guessing grid positions. You should write the code so that the game is
still 'playable' even
if the user types an integer that is not within the bounds of the
grid. This means testing for this
situation, and taking some reasonable course of action (of your choice).
Possible reasonable actions might be: asking the user to try again, or throwing away the guess so that the user forfeits her turn.
-
Although we specified that lines of bones must be oriented randomly, we didn't specify the probability associated with each orientation.
When placing a line of bones, you must decide randomly whether the line should be NS or EW (vertical or horizontal). Your decision should
be made so that lines are oriented NS with probability .5 (50%) and are oriented EW with probability .5. This is equivalent to flipping a coin
and orienting the line one way if the result is heads and the other way if the result is tails. There is a class in Java which provides a method
which can be used to (randomly) return one of two possible values. This is Java's version of 'coin flipping'.
-
Lines of bones may form L or T shape or a long line such as xxxyyyy (i.e. bones from 2 different
lines may occupy adjacent positions in the grid) as long as they don't overlap.
-
You are not required to tell the user when they find a complete line
of bones.
You may do so if you choose to, however. If you do, you will neither be
penalized nor
rewarded with extra marks.
-
Your code should be well-designed, and there will be marks for
that. One thing that should be clear from the previous assignments and
lectures is that static methods and variables are used in one specific case:
when you are absolutely sure that there is no need for multiple instantiations (either no variables or only
one 'version' of the member variables is needed in the class). If there is any reasonable possibility that future
changes to the specifications might require multiple 'versions' of variables (i.e. the instantiation of multiple objects), then you should make
these non-static. That way, all you need to do later is to instantiate more objects. This is considered good design because it makes
your code easier to upgrade.
So if you have a ton of static methods and variables in A7, you
should re-think your design.
Consider, for example, what might happen if in the future you decided
to make your program into a 2-player game. It would be nice if only the
main program had to change, and not your existing helper classes. Using
static methods in those helper classes will probably not work for a
2-player game (Thought question: why?)
|
Wed Nov 28 |
- From Burying the Bones:
- "If horizontal, randomly choose the leftmost position of the line so that the line won't be too long for the grid
- If vertical, randomly choose the topmost position of the line so that the line won't be too long for the grid
This does not mean that you should use the leftmost (topmost) position in the grid.
What it does mean is this: we are giving you a suggestion on how to randomly position lines
of bones on the grid. So we want to randomly select a position on the grid.
However, the line of bones has a length which is more than one. So how should we deal with this?
Should we randomly select a grid position for each of the bones in a line of bones? No,
we can't do that, or the bones would be scattered all over the grid -- they wouldn't form a line.
So what we need to do is to select a grid position for one of the bones in a line
of bones, and then automatically place the rest of the bones within that line. If
we already know whether the line is to be horizontal (or vertical), and we've already randomly
selected the grid position where the leftmost (or topmost) bone of the line will rest, then
we should be able to automatically fill in the remaining bones in the line.
Of course, there are certain grid positions which will be bad choices as they will force the line
of bones to hang off the edge of the grid; these are to be avoided.
|