Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

rectangles

 
yassire SANIE
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
can anyone help please, i've been working on this code but it all the times generates errors: " write an applet that draws a variety of rectangles of different sizes and locations."
thanx
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is your code, and what errors do you get?
 
yassire SANIE
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is the code ( the problem is that i didn't get the idea of different locations)


class Rectangle extends Shape {
private int width;
private int height;

// constructor
Rectangle(int newx, int newy, int newwidth, int newheight) {
super(newx, newy);
setWidth(newwidth);
setHeight(newheight);
}

// accessors for the width & height
int getWidth() { return width; }
int getHeight() { return height; }
void setWidth(int newwidth) { width = newwidth; }
void setHeight(int newheight) { height = newheight; }

// draw the rectangle
void draw() {
System.out.println("Drawing a Rectangle at " + getX() + ", " + getY() +
"), width " + getWidth() + ", height " + getHeight());
}
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic