i got it all under control - i figured it out and turned it in today...here it is if anybody wants to see it
import apcslib.*;
public class Rectangle2
{
// variable declaration
private double myX;
private double myY;
private double myWidth;
private double myHeight;
private static DrawingTool pen = new DrawingTool(new SketchPad(500, 500));
private double myDirection;
// constructors
public Rectangle2()
{
pen.move(0,0);
}
public Rectangle2(double x, double y, double width, double height)
{
myX = x;
myY = y;
myWidth = width;
myHeight = height;
}
// methods
public double getPerimeter()
{
return (2 * myWidth) + (2 * myHeight);
}
public double getArea()
{
return (myWidth * myHeight);
}
public void setDirection(double direction)
{
myDirection = direction;
}
public void setWidth(double w)
{
myWidth = w;
}
public double getDirection()
{
return myDirection;
}
public void setXPos(double x)
{
myX = x;
}
public void setYPos(double y)
{
myY = y;
}
public void draw()
{
pen.up();
pen.move(myX,myY);
pen.down();
pen.setDirection(myDirection);
pen.forward(myHeight);
pen.turnLeft(90);
pen.forward(myWidth);
pen.turnLeft(90);
pen.forward(myHeight);
pen.turnLeft(90);
pen.forward(myWidth);
}
public void drawString(String str, double x, double y)
{
pen.up();
pen.move(x,y);
pen.drawString(str);
}
public double getX()
{
return myX;
}
public double getY()
{
return myY;
}
public double getWidth()
{
return myWidth;
}
public double getHeight()
{
return myHeight;
}
}
import apcslib.*;
public class MethodsRect
{
public static void main(String[] args)
{
Rectangle2 rect = new Rectangle2(-50,160,200,50);
rect.setDirection(90);
rect.draw();
rect.drawString("Area = " + rect.getArea(),-225,175);
rect.drawString("Perimeter = " + rect.getPerimeter(),-225,195);
rect.drawString("Width = " +rect.getWidth(),-200,145);
rect.drawString("Height = " +rect.getHeight(),-35,185);
Rectangle2 rectA = new Rectangle2 (-10,0,200,50);
double turnInc = 30;
double widthDec = 10;
rectA.setDirection(270);
rectA.setDirection(rectA.getDirection());
rectA.setWidth(rectA.getWidth());
rectA.draw();
rectA.setDirection(rectA.getDirection() - turnInc);
rectA.setWidth(rectA.getWidth() - widthDec);
rectA.draw();
rectA.setDirection(rectA.getDirection() - turnInc);
rectA.setWidth(rectA.getWidth() - widthDec);
rectA.draw();
rectA.setDirection(rectA.getDirection() - turnInc);
rectA.setWidth(rectA.getWidth() - widthDec);
rectA.draw();
rectA.setDirection(rectA.getDirection() - turnInc);
rectA.setWidth(rectA.getWidth() - widthDec);
rectA.draw();
rectA.setDirection(rectA.getDirection() - turnInc);
rectA.setWidth(rectA.getWidth() - widthDec);
rectA.draw();
rectA.setDirection(rectA.getDirection() - turnInc);
rectA.setWidth(rectA.getWidth() - widthDec);
rectA.draw();
rectA.setDirection(rectA.getDirection() - turnInc);
rectA.setWidth(rectA.getWidth() - widthDec);
rectA.draw();
rectA.setDirection(rectA.getDirection() - turnInc);
rectA.setWidth(rectA.getWidth() - widthDec);
rectA.draw();
rectA.setDirection(rectA.getDirection() - turnInc);
rectA.setWidth(rectA.getWidth() - widthDec);
rectA.draw();
rectA.setDirection(rectA.getDirection() - turnInc);
rectA.setWidth(rectA.getWidth() - widthDec);
rectA.draw();
}
}