CSCI Homework Assignment 1 - Improving the Circle

Due Tues Sep 4 at 11:59pm

Introduction

This assignment will give you a chance to practice working with BlueJ and the shape classes in more detail. You can also become more familiar with the "code/compile/test" cycle for developing software. This assignment requires modifying and extending existing Java source code, but all of the exercises can be solved by copying and pasting from code we've already looked at.

The Assignment

In this assignment, we'll be modifying the Circle class from the Shapes project to allow it to do more things.

Start by downloading a copy of Homework1.zip. This project is virtually the same as the Shapes project you have seen before. I have modified it a little for this assignment, so be sure to use the version linked to above. Extract Homework1 from the compressed directory, open the project in BlueJ, and double-click the Circle class to open the source-code editor.

  1. 20 pixels is a small amount to move. Modify the moveUp(), moveDown(), moveLeft(), and moveRight() methods so that they each move the circle 30 pixels instead of 20.
  2. Add a new method called moveNorthWest(). When invoked, it should move the circle up by 30 pixels and to the left by 30 pixels. Make sure you add a comment to the code to describe your new method!
  3. Add a new method called shuffleHorizontal() that takes a single integer as its argument. When invoked, the method causes the circle to do a slow shuffle to the right by the specified number of pixels, and then a slow shuffle to the left (assuming your input is positive--if the input is negative, the circle will shuffle left and then right). Add a comment describing your new method. HINT: If your solution is more than a few lines long, you're making this more difficult than it needs to be!
  4. Modify the Java code so that new circles are green instead of blue by default.
  5. Optional: Modify the code so that the circles are visible (on the screen) when they are first created. No extra credit for this, but it'll make the rest of the assignment much more pleasant. In fact, I recommend you do this step before the others!

Submitting

Submit your solution through BlueJ, following the same submission directions as presented in Lab A. However make sure to select "Hwk1" instead of "LabA".

Submitter will accept the Circle.java file.

Grading

This assignment will be graded on the following criteria: