Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

drawRect method !!!

 
fatima zohra
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello everyone

if anyone can help me solve this problem,it would be of great help: " i have to write an applet that allows the iser to input the four arguments required by method draw.Rect, then draw a rectangle using the four input values"

thank you guuuuys
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How much of it have you written?
 
fatima zohra
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
here is the code i have:

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


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());
}
}
 
memati bas
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try to examine my code.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic