aspose file tools*
The moose likes Java in General and the fly likes Please help - Need advice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Please help - Need advice" Watch "Please help - Need advice" New topic
Author

Please help - Need advice

Rob Shan Lone
Greenhorn

Joined: Jan 03, 2004
Posts: 8
Hi ya, at the bottom I have listed the criteria. I need to create a basic graphics package. However I need advice on the most effective and efficient simple way of doing this?
I am very keen to start off with a switch statement, is this the right thing to do for this occassion? Please take a look at my code and help me come up with a working model. The coffee is brewing guys I got the notes and the books out but I'm kinda stumped. By the way I am only a student so please constuctive critism if any.
My first question is what should the next step be and what layout should work?
Rob

===============================================================
Hello I have been given this task to do:
Develop a basic graphics package.
Use the Shape class inheritance hierarchy shown below.
a. Limit yourself to two dimensional shapes such as squares, rectangles, triangles and circles.
b. Interaction with the user must be demonstrated.
c. Let the user specify the position, size and shape to be used in drawing each shape.
d. The user can specify many items of the same shape.
e. As you create each shape, place a Shape reference to each new shape object into an array.
f. Each class has its own draw method. Write a polymorphic screen manager that walks through the array sending draw messages to each object in the array to form a screen image.
g. Redraw the screen image each time the user specifies an additional shape. Investigate the methods of class Graphics to help draw each shape.
Shape
/ \
TwoDimensionalShape ThreeDimensionalShape
/ | \ / | \
Circle Square Triangle Sphere Cube Tetrahedron
====================================================================
[ January 03, 2004: Message edited by: Michael Ernest ]
[ January 03, 2004: Message edited by: Tony Alicea ]
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

Edited code for readability.


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Tony Alicea
Desperado
Sheriff

Joined: Jan 30, 2000
Posts: 3222
    
    5
Added imports...
Rob Shan Lone
Greenhorn

Joined: Jan 03, 2004
Posts: 8
Does this look better?

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Shape extends JFrame
{
public class TwoDimensionalShape
{
public class Circle
{
}
public class Square
{
}
public class Triangle
{
}
}

public class ThreeDimensionalShape
{
public class Sphere
{
}
public class Cube
{
}
public class Tetrahedron
{
}
}

public Shape( )
{
super( "Drawing lines, rectangles and ovals" );
setSize( 400, 165 );
show( );
}

public void main( String args[] )
{
Shape Shape = new Shape();
}
}
Jessica Sant
Sheriff

Joined: Oct 17, 2001
Posts: 4313

Originally posted by Rob Shan Lone:
Does this look better?

Rob, try using [CODE] tags to surround your source code, that will preserve the whitespace and make it more readible. (same goes for your little Shape / TwoDimensionalShape diagram) Good Luck


- Jess
Blog:KnitClimbJava | Twitter: jsant | Ravelry: wingedsheep
Rob Shan Lone
Greenhorn

Joined: Jan 03, 2004
Posts: 8
Hey guys if the Shape class inheritance hierarchy
is this what my code should look like?
===================shape
==================/-----\
=========2 dimension shape-----------3 dimension shape
=======/--------|------\----------/-----|----\
====circle--square--triangle===sphere--Cube--Tetrahedron

I got to
1) Develop a basic graphics package.
Use the Shape class inheritance hierarchy shown below.
a. Limit yourself to two dimensional shapes such as squares, rectangles, triangles and circles.
b. Interaction with the user must be demonstrated.
c. Let the user specify the position, size and shape to be used in drawing each shape.
d. The user can specify many items of the same shape.
e. As you create each shape, place a Shape reference to each new shape object into an array.
f. Each class has its own draw method. Write a polymorphic screen manager that walks through the array sending draw messages to each object in the array to form a screen image.
g. Redraw the screen image each time the user specifies an additional shape. Investigate the methods of class Graphics to help draw each shape.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Please help - Need advice