a5_ProblemSet - Assignment A5 CS100J Spring 2008 See CMS...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Assignment A5 CS100J Spring 2008 See CMS for deadline This assignment introduces you to graphics. You will write procedures that draw interesting designs, bouncing balls, and a recursive design in a JFrame. You may work with one other person. If you do so, form your group on the CMS WELL BEFORE YOU SUBMIT YOUR FILES. Remember, partners should work together and not independently. You need not use a JUnit testing class. You will (partly) be looking at visual output (graphics) to determine correctnesss. Please keep track of the time you spend on this assignment. You will be asked to put it in a comment at the top of file A5.java. To save time and effort, we give you complete specifications of most of the methods you write. Please study them carefully. Note how precise and thorough they are. You should aim for this quality of specification when you write your own specifications. At the end of this document, we tell you what to submit. Download file A5.zip , unzip it, and put everything in it into a new directory. It contains: 1. A file A5.java , which extends class Turtle . 2. Several .class files. These are machine language versions of .java files. Do NOT load them into DrJava. The only thing you should load into DrJava is file A5.java . It will automatically use the .class files. 3. A directory doc , which contains specifications of class Turtle . You will use these specs when writing method calls to make turtles do what you want. A Turtle is a pen of a certain color at a pixel (x, y) that is pointing in some direction given by an angle (0 degrees is to the right, or east; 90 degrees, north; 180 degrees, west; and 270 degrees, south). When the turtle is moved to another spot using procedure moveAhead or moveBack , a line is drawn if its pen is currently "down" and nothing is drawn if its pen is "up". The pen is initially black, but its color, of class java.awt.Color , can be changed. A footnote on page 1.5 of the ProgramLive CD contains information about class Color . Open doc/index.html in your favorite browser and study the specifications of methods in class Turtle (the javadoc files). Here are some important points: Class Turtle uses the Graphics object that is attached to a JPanel . It builds on class Graphics by maintaining the "turtle", which has a position and an angle and holds a pen of a color; the pen is up or down. You can use many turtles at the same time; they all use the same JPanel . The coordinates and angle of the turtle are maintained using type double. This is needed for maximum accuracy. If we used int , errors might crop up after many calculations. However, whenever a point is to be placed in the window, its x- and y-coordinates are rounded to the nearest integer because the graphics space works with int s. Function
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This homework help was uploaded on 02/20/2009 for the course CS 100 taught by Professor Fan/vanloan during the Spring '07 term at Cornell.

Page1 / 6

a5_ProblemSet - Assignment A5 CS100J Spring 2008 See CMS...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online