Help with Grow/Shrink Methods!

Hi,

1. I am trying to create a program that will include four methods that will grow a diamond shape horizontally and vertically and shrink the diamond horizontally and vertically.

2. Write a loop in main() that repeatedly shrinks the diamond vertically while horizontally growing it.

I have made this code so far:

package animax;

import java.awt.*;

publicclass GrafixPolygon

{

protectedint [ ] X ={300, 350, 250} ;//positions the diamond

protectedint [ ] Y ={100, 200, 200} ;//positions the diamond

protectedint n = 4 ;//number of points

protectedboolean fill;

protected Color fillColor = Color.cyan;

protected Color lineColor = Color.blue;

public GrafixPolygon;

}

I just don't know how or where to implement the four methods.

Any help would be much appreciated.

[1629 byte] By [helloworld2007a] at [2007-11-26 22:51:38]
# 1
1) Create some state (a set of object fields) that expresses the shape of the diamond.2) Write methods that draw the diamond based on that state.3) Write methods that change the state.That's it!
paulcwa at 2007-7-10 12:13:48 > top of Java-index,Java Essentials,Java Programming...
# 2
Any ideas what sort of code would be needed?
helloworld2007a at 2007-7-10 12:13:48 > top of Java-index,Java Essentials,Java Programming...
# 3
> Any ideas what sort of code would be needed?java code ought to do it
georgemca at 2007-7-10 12:13:48 > top of Java-index,Java Essentials,Java Programming...
# 4

You should stop looking for code snippets and start thinking about solving the problem. This is much easier than you think.

You already have some code that maintains some state. There would be more like that.

But here's an example:

private int aNumber = 15;

That wasn't so hard, was it?

Drawing based on the state depends on how you want to draw (on a Canvas with Java 2d stuff? Or with ascii graphics, or what?)

Changing the state is so trivial it's hardly worth mentioning either, but what the hell:

aNumber = 20;

paulcwa at 2007-7-10 12:13:48 > top of Java-index,Java Essentials,Java Programming...