Java Basics Track for A290/A590 Spring 2008
Reference: Cay Horstmann's Core Java volume I (Fundamentals)
For additional references available on-line for free from Books24x7 please see the Intro track


Thu Apr 10 10:27:52 EDT 2008 Problem Two:

Write a program that

The descriptions are for circles and rectangles at least.

Here's how a circle is requested:

circle <x-coordinate> <y-coordinate> radius <radius-size>

Here's how a rectangle is requested:

rectangle <x-coordinate> <y-coordinate> size <width-size> <height-size>

Here's how my program works (see actual examples of data):

-bash-3.1$ java Five
Welcome, please define your first object: circle 2 3 radius 10
Adding Circle at (2.0, 3.0) radius 10 and area 314.1592653589793
Please enter another object or done if finished: rectangle -1 2 size 2 4
Adding Rectangle at (-1.0, 2.0) width: 2.0, height: 4.0, and area 8.0
Please enter another object or done if finished: circle 9 1 radius 8
Adding Circle at (9.0, 1.0) radius 8 and area 201.06192982974676
Please enter another object or done if finished: rectangle 2 8 size 12 8
Adding Rectangle at (2.0, 8.0) width: 12.0, height: 8.0, and area 96.0
Please enter another object or done if finished: circle 0 0 radius 12
Adding Circle at (0.0, 0.0) radius 12 and area 452.3893421169302
Please enter another object or done if finished: done
Rectangle at (-1.0, 2.0) width: 2.0, height: 4.0, and area 8.0
Rectangle at (2.0, 8.0) width: 12.0, height: 8.0, and area 96.0
Circle at (9.0, 1.0) radius 8 and area 201.06192982974676
Circle at (2.0, 3.0) radius 10 and area 314.1592653589793
Circle at (0.0, 0.0) radius 12 and area 452.3893421169302
-bash-3.1$

You have complete freedom on how you approach this.

For maximum credit you would:

Best of luck, let me know if you need any help.


Last updated by Adrian German for A290/A590 on Sun Apr 06 14:39:38 EST 2008