CSC 210 Program #2

Drawable Shapes

Logistics

Go...

  •  Worth 4 points, or 4% of your class grade
  •  Assigned Saturday April 8, 2006
  •  Due Saturday April 22, 2006 by the end of the day... 2 weeks!
  •  Covers a sweet combo of Chapter 3's inheritance and such along with some Chapter 4 list stuff

We'll continue on the GUI theme with swing and let's do an applet, shall we. I'll show you how to use your North Central College web page as well. Oh, you didn't know you had one? Stay tuned.

Description

Pick up your text... page 164... go ahead, I'll wait.

In Program #2, we're going to complete and extend the "Drawable Shapes" project described  on pages 164-185. [ Bill note: why is my spell-checker complaining about "drawable"? The online dictionary has it: http://dictionary.reference.com/search?q=drawable ]

So, there's a bunch of code already written for you. A copy of the code from the book is already on the k: drive in the common_area; it's also at the book's web site.

OK, so we've got that covered, now what. Please add the following to make your program run:

  •  Complete any missing Java code not given by the textbook
  •  Write the Circle and RtTriangle classes... use the book's Rectangle class as your guide
  •  Add a new DrawableShape of your own... it has to be something you can draw, like a line (probably the easiest), a square (which would be a subclass of Rectangle), text, or even a recursive tree (excellent!)
  •  Create an applet the runs your program and place it on your W: drive
  •  Create a new test class; mine is TestShapes. Your new main() function for this test class should be a combination of the main()'s from the TestDrawFigures (TDF) and ComputeAreaAndPerim (CAAP) classes. The pseudo-code for this main() will look like this:
do
   get new shape from user    // ala getShape() in CAAP
   add it to a list of shapes    // replace the array in TDF
while not done
add this TestShapes to the Frame   // update your paintComponent()
  •  I placed my user-requested objects at random (x,y) locations. It's more fun, and I didn't have the tedium of typing them in each time.
  •  Also, add an option when adding shapes in getShape() to quit. I'll have this in a handout that will probably be a lot clearer.

That's about all I can think of for now. Stay tuned.

Implementation

Print out the book's code and digest it. Also, the book has some nice URL diagrams that should help. I believe that the implementation of Rectangle is complete, so you can use it as a guide. This is a test of your ability to "get" inheritance and interfaces and all that. Add your classes and run!

The W: drive at North Central college behave like any other drive... copy files to it and such. However, once you get web-readable files, like index.htm, they are visible as web pages on the WWW. The URL or address of your web page will be <first_name>.<last_name>.students.noctrl.edu.

We tried it for Kim and here's her "Hello, World page: http://kim.opalka.students.noctrl.edu/

You'll need to create an index.htm that calls your applet and then copy all the necessary *.class files over to the W: drive. This should be a last step... get your program running as an application first.

Grading

The same as Program #1, pretty much.

By the due date, please place your work for Program #2 in your folder on the k: drive. I'll be looking for:

  •  A README file describing the state of your program... what works, what doesn't, etc.
  •  All your *.java Java source code files
  •  All your *.class files... please compile your Java
  •  A javadoc folder with the nifty auto-magic documentation of your classes
  •  And, new for Program #2, please create an applet on your W: drive folder, so that your program runs on the WWW.

Of course, your code must be beautiful and follow the class coding guidelines. Code that does not meet this metric will be served a harsh brand of grading justice.

Etc

I'll post hints and such (like correcting instructor errata) here as the week goes by.

Remember to do a toString() method for each of your classes.

I had some problems getting jGRASP to do packages. If you have similar problems, then just comment out the package statement at the top of each file. That worked for me. Try it with the package statement first though.

Hey, if you want to add a button to the top of your JFrame to add shapes, go for it. Get it?

Apr 10, 2006... If you get this error:

 Note: Recompile with -Xlint:deprecation for details"

Then, comment out the call to method show() for a JFrame. It's no longer necessary, and your error should go away. BTW, if you want to re-compile with some option in jGRASP, like the message recommends, then

  1. Select menu Settings/Compiler Settings/Workspace
  2. Then, select the Flags/Args/Main tab
  3. Then, select the black dot next to compile and enter your option(s)

Phew.

thanks... yow, bill

...

william.krieger.faculty.noctrl.edu

wtkrieger@noctrl.edu