Computer Science 252
Problem Solving with Java

Fall 2013, The College of Saint Rose

Programming Project 2: Scary Spiders
Due: 11:59 PM, Thursday, November 7, 2013

For this project, in the spirit of the season, you are to develop a Java program to simulate spiders on a web. The project comes in two distinct and essentially independent parts: the first is to draw a picture of a spider web on the canvas, the second is to animate spiders hanging from a thread.

Ground Rules

You must work individually on this project. You may consult only Prof. Teresco for help. You may not discuss the programs with anyone else including your classmates and the computer science tutors until after everyone has submitted their programs. You may consult your own graded or ungraded lab submissions, your own class notes, and any class examples or notes available from the course web page. Think of this as an open-book lab exam. Any collaboration or consultation of unauthorized sources will be considered a breach of academic integrity and will be dealt with according to the course policies outlined on the syllabus.

While no written design will be graded for these programs, coming up with a written design is likely to be a beneficial first step.

Note that a significant portion of the credit for the project is for style, program design, documentation, and efficiency. While everyone should strive to earn all of the correctness points, you may find that a well-designed, thoroughly-commented program that makes appropriate use of variables and constants but does not quite implement all functionality will earn a higher grade than a perfectly-functioning program that uses poor variable names, does not use named constants, is uncommented, or is poorly formatted.

Have fun and good luck!

Requirements

The program will draw a spider web initially. Each time the mouse is pressed, a new spider is drawn at the mouse location. As long as the mouse is held down, the spider will move downward along a thread, which extends from the press point to the spider at all times. When the mouse is released, the spider stops moving and remains at its final location.

Your program will ultimately consist of three classes: SpiderWeb will extend WindowController and will be responsible initially for drawing the spider web and later to handle the mouse events that are involved in creating and animating spiders. Spider is a custom class that does not extend anything, which is responsible for drawing a movable spider object. MovingSpider will extend ActiveObject and is responsible for creating a Spider and animating it.

It is strongly recommended that you take the "slow and steady" approach to this. Aim to have at least the spider web drawn and perhaps your spider object done a week before the due date, so you can use the time up to the deadline to get your active object working properly.

Part 1: The Web

The spider web is drawn on the canvas when the program begins. It should be more "realistic" than the one in the demo below. The primary requirement is that you must use one or more loops in an appropriate way to aid in drawing your web. You can earn most of the credit for this part of the assignment by creating a fairly simple web (either along the lines of the one in the demo or entirely of your own design). The last few points will be awarded for a more interesting and realistic web image.

Part 2: The Animated Spider

The second major part of the program is to use an active object to animate a spider. Your MovingSpider active object is only responsible for the animation - the actual ObjectDraw components of the spider are created and managed by the Spider class.

When the mouse is pressed, a new spider is created centered on the mouse location. It should immediately begin to animate. It does so by moving downward at a constant rate, leaving a "string" (OK, a Line) connecting the spider's current location to the initial mouse press point. The spider's animation should continue while the mouse button is being held down. When the mouse is released, the spider should stop moving but remain on the canvas in its final position.

For the spider itself, you may use the provided Spider class (available here) as a starting point and make some improvements, or come up with your own. For the basic requirement, you may choose to add a head and/or eyes, some more realistic legs, pincers, or some body markings. This is only worth a few points, so you do not need to go overboard (unless you want to do so - see extra credit below).

Demo

A working solution for the program will appear below. Click inside the applet to interact with it.



Extra Credit Opportunties

Up to 5 total points of extra credit is available for creating an especially interesting or realistic spider web, for a more elaborate animation of the spider (though the basic required functionality must be preserved), or for creating a significantly more detailed spider object.

Separation of Concerns

A major point of emphasis on this project is separation of concerns. Your program will consist of three classes, each of which is responsible for specific parts of the functionality. Be sure you think carefully about what each class should do and have it do only those things.

Submitting Your Work

Before 11:59 PM, Thursday, November 7, 2013, submit your Java program for grading. There are three things you need to do to complete the submission: (i) upload a copy of your Java program (the .java files only; submit each file separately) using Submission Box under assignment "Spiders", (ii) print a copy of your program and hand it to your instructor, and (iii) demonstrate the execution of your program for your instructor (2-day grace period for demos).

Don't forget to check your programs for compliance with the Style Guide for CSC 252 Programs

Grading

This assignment is worth 100 points, which are distributed as follows:

> FeatureValueScore
Style, Design, and Efficiency
Appropriate comments 6
Good variable names 4
Appropriate variable declarations 6
Good use of constants 6
Appropriate formatting 2
Efficiency 6
Good overall design and methods 8
Correctness
Basic spider web using at least one loop 10
More interesting/realistic web 2
Enhanced spider object 5
Basic active object behavior 10
Moving spider created centered at mouse press point 5
Spider immediately begins to move down 7
Spider moves down at a constant rate 5
"Web strand" connects spider's current position to original press point 6
Spider stops moving when mouse is released 7
Spider remains at final position 5
Extra Credit (up to 5 points total)
Total 100