CS 305J Assignment 7, While Loops
| Programming Assignment 7 | Pair Assignment. You may work with one other person (You
make work with one other person on this assignment using the pair
programming technique.. You may work with anyone in the class. They do not
have to be in the same discussion section as you or the same partner as on
previous assignments. One solution will be turned in for the pair. Once you start
working with one partner on an assignment you may not switch partners. If
you do not wish to work with a partner after starting on an assignment you
must both complete it individually. The intent here is you work on the
assignment together, at the same time, at the same computer. Do not simply
try to work on different parts independently and then try to put it
together. You may choose to work alone if you wish.) Placed online:
October 16 |
||||||
| Description | The purposes of this assignment are:
For this assignment you are limited to the language features in chapters 1
through 5 of the textbook. You will also use the Write a program that prompts the user for the size of a target square. The target size must be a minimum of 10 and a maximum of 100. You may assume the user will enter integers, but you must error check their response to ensure the value that enter is greater than or equal to 10 and less than or equal to 100. If not prompt the user again. You must repeatedly prompt the user until they enter a correct integer for the size of the target square. The program then creates a
In order to be able to
remember all of the information about the target you can have the method
that picks the location for the target and draw it, return a
By returning the Once the Rectangle is created the information can be accessed via
methods. Assume
To use the After creating the After picking the initial location perform a random walk The x coordinate for the next location can either be one less than the current x coordinate, the same as the current x coordinate, or one more than the current x coordinate. The next y coordinate can also be 1 more, the same, or less than the current y cooridnate. The one limit is that the resulting x and y must be in the window. In other words Neither x or y can be less than 0 nor can either be greater than or equal to 600. Note, it is possible that the next location will be the same as the current location. When the new location is picked draw a square of size 1 at the new location. This simulates a random walk around the window. Continue the random walk until it hits the edge of the target square. While outputs will vary you usually get something interesting such as this:
Tips:
When finished turn in your RandomWalk.java program using the turnin program. Do not turn in the class file. do not turn in a file with a tilde (~) in the file name. Doing either of these will result in a zero on the assignment. If you are working with another person, turn the assignment in to only one person's account, but ensure the header is filled in with both of your names and the unique class IDs for both of your sections. |
||||||
| Files |
|
||||||
| Checklist | Did you remember to:
|