Win a copy of Spring in Action (5th edition) this week in the Spring forum!

Rob Shan Lone

Greenhorn
+ Follow
since Jan 03, 2004
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rob Shan Lone

14 years ago
Hey thank you for your advice. What exactly did you mean by instead of Altershape(shape); have it shape.Altershape(); what does this actually do. I can only guss that Altershape(shape) passes on the variables to the Altershape method. Whereas shape.Altershape(); invokes Altershape method in the Shape class? err is that right. Forgive the other postings, they looked like dead ends and I was unsure if people would check all forums etc. It was suggested to use the interface model, having said that I have no examples to work from.
I've been struggling with this for days. I have come up with the shape classes through help on the net. I am aware that passing in the variables will change the size of the shape, its implementing all of the tasks in the one program I am having problems with. It is invoking the correct methods, in the simplest way at the right time, with the right variables whilst trying to get it to compile! I've been doing JAVA like this for less than a year and even then we started with "Hello World"
Here are those other files


AND


AND
14 years ago
Hello,
I would like the user to choose a shape, alter the size and coordinates of the shape as well as add new shapes. I have devised this program but I am stumped passed the static and non static methods. Also confused as to how to carry out the above statements. I have separate java files for the shapes that are called apon. What would you guys recommend? I have made it into a switch statement, however I think a screen manager may work best for this, what is it and how would you do such a thing?
14 years ago
Ok , I'm really struggling with this...
this is the Shape class inheritance hierarchy I have to stick too. Am I on the right tracks or not I do not know?

I was unsure how to include twodimensionshape for is there any point? The instructions here state I only need to concentrate on two dimensional shapes so I won't even need a Threedimensionalshape class?
INSTRUCTIONS
========================================================================
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.
================================================================
Here is the java code I got for each java file.
Showshapes class - interaction with the user

Square class


Shape class

Poly class
[ edited to improve code layout, making it narrower -ds ]
[ January 05, 2004: Message edited by: Dirk Schreckmann ]
14 years ago
Ok , I'm really struggling with this...
this is the Shape class inheritance hierarchy I have to stick too. Am I on the right tracks or not I do not know?
//-------------------------------Shape
//---------------------------/----------\
//--------TwoDimensionalShape------------ThreeDimensionalShape
//-------/-------|----------\-------------/--------|---------\
//Circle------Square-----Triangle------Sphere-----Cube-------Tetrahedron
I was unsure how to include twodimensionshape for is there any point? The instructions here state I only need to concentrate on two dimensional shapes so I won't even need a Threedimensionalshape class?
INSTRUCTIONS
========================================================================
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.
================================================================
Here is the java code I got for each java file.
Showshapes class - interaction with the user

Square class


Shape class

Poly class
14 years ago
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.

14 years ago
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();
}
}
14 years ago
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 ]
14 years ago