# Rectangle

Desiree Luciane
Rectangle
1 Answer(s)      6 years and 7 months ago
Posted in : Java Beginners

Could anybody help me on this problem, Write two Rectangle objects with the following properties:

Rectangle1: Height 15 width 53 Y 25 X 15

Rectangle2: height 47 Width 60 Y 12 X 0

It's to be used four-argument constructor, toString(), getWidth(), getHeight(), Println()

January 14, 2011 at 12:27 PM

Hi Friend,

Try the following code:

```class Rectangle{
private int width;
private int height;
int x;
int y;
Rectangle(int newx, int newy, int newwidth, int newheight) {
this.x=newx;
this.y=newy;
this.width=newwidth;
this.height=newheight;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public int getX() {
return x;
}
public int getY() {
return y;
}
void Println() {
System.out.println(toString());
}

public String toString(){
return "Rectangle(" + getX() + ", " + getY() +"), width " + getWidth() + ", height " + getHeight();
}
public static void main(String[]args){
Rectangle Rectangle1=new Rectangle(15,25,53,15);
Rectangle1.Println();
Rectangle Rectangle2=new Rectangle(0,12,60,47);
Rectangle2.Println();
}
}
```

Thanks

Rectangle
Rectangle  Could anybody help me on this problem, Write two Rectangle objects with the following properties: Rectangle1: Height 15 width 53 Y 25 X 15 Rectangle2: height 47 Width 60 Y 12 X 0 It's to be used four-argument
plotting of points inside a rectangle
plotting of points inside a rectangle  I want to plot various points inside a rectangle such that any two points are at a distance of at least 3... example ,if I have a Rectangle of 20m by 14m then one possible placement of points
print rectangle pattern in java
print rectangle pattern in java  * * * * * * * how to generate this pattern in java??   Hi friend try this code may this will helpful for you public class PrintRectangle { public static void main
print a rectangle - Java Beginners
print a rectangle  how do I print a rectangleof stars in java using simple while loop?Assuming that the length n width of the rectangle is given.  Hi friend, I am sending running code. import java.io.
By using Applet display a circle in a rectangle
By using Applet display a circle in a rectangle  Write a java applet to display a circle in a rectangle
How to calculate area of rectangle
How to Calculate Area of Rectangle   ... of rectangle. The area of rectangle is specifies an area in a coordinate space that is enclosed by the rectangle object. In the program coordinate of space its
print rectangle triangle with ?*? using loops
print rectangle triangle with ?*? using loops   * * * * * * i want print like this.what is the code?   import java.lang.*; class Traingles { public static void main(String args[]) { for(int i=1;i<=5
drawing rectangle in java/Creating a draw rectangle filled with black color function in Java for a grid
drawing rectangle in java/Creating a draw rectangle filled with black color function in Java for a grid  drawing rectangle in java/Creating a draw rectangle (filled with black color) function in Java for a grid
Java gui program for drawing rectangle and circle
Java gui program for drawing rectangle and circle   how to write java gui program for drawing rectangle and circle? there shoud be circle and rectangle button, check box for bold and italic, and radio button red,green and blue
Rectangle Canvas MIDlet Example
Rectangle Canvas MIDlet Example   ... of rectangle in J2ME. We have created CanvasRectangle class in this example that extends to the Canvas class to draw the given types of rectangle. In this figure
Draw Ellipse in Rectangle
Draw Ellipse in Rectangle     ... the rectangle. To draw an Ellipse inside the rectangle, we have defined two classes... a rectangle and a circle respectively.  By using draw() method of class
Program to draw rectangle on each mouse click and erase priviouse rectangles
Program to draw rectangle on each mouse click and erase priviouse rectangles  Program to draw rectangle on each mouse click and erase previous rectangle on next mouse click
How to make a Rectangle type pdf
How to make a Rectangle type pdf   ... make a pdf file in the rectangle shape irrespective of the fact whether... rectangle. The code of the program is given below
J2ME Draw Triangle, Rectangle, Arc, Line Round Rectangle Example
J2ME Draw Triangle, Rectangle, Arc, Line Round Rectangle Example... tutorial, we are going to describe how to draw a triangle, rectangle, arc, line or a round rectangle in one small application. Although we have already explained
Rectangle Image in Java
Rectangle Image in Java       Introduction In this section, you will learn how to create rectangle... , rectangle Drawing , curve drawing and Circle. All types of Geometry classes parts
Java Swing: Draw rectangle on mouse click
Java Swing: Draw rectangle on mouse click In this tutorial, you will learn how to draw a rectangle on mouse click. Sometimes, there is a need of mouse clicks.... In the given example, we are going to draw a rectangle by clicking the mouse
four rectangle/image of the shape of the button.then Draw these on some x and y co-ordinated in j2me then how to draw ?
four rectangle/image of the shape of the button.then Draw these on some x and y co-ordinated in j2me then how to draw ?  hi, i have button use in j2me. then use a imaga for lick a button. then process is four rectangle/image
Draw Rectangle in J2ME
Draw Rectangle in J2ME      ... are used to draw a rectangle using J2ME language: g.setColor (255, ... it to create rectangle and to set the color of canvas and draw line or box.
A Program to find area and perimeter of Rectangle
A Program to find area and perimeter of Rectangle In this section we...; a rectangle. To find area and perimeter of a rectangle is a simple program... and perimeter of a rectangle in java. Code Description : Using this example
MySQL Area
MySQL Area  This example illustrates how to find the area of rectangle in MySQL. In this example we create a procedure to find the area of rectangle. In the query below we declare two integer type variable w and h with default
MySQL Area
; This example illustrates how to find the area of rectangle in MySQL. In this example we create a procedure to find the area of rectangle. In the query below we take... of the rectangle.         Create Stored Procedure
Write a program for calculating area and perimeter of a rectangle
Write a program for calculating area and perimeter of a rectangle... of a rectangle.  First of all create a class named RecArea under Java.io.... Now use parseInt for both length and width of the rectangle
Change the user input to integer
of a rectangle by using two classes named Rectangle and EnterValuesFromKeyboard...() calculates the area of a rectangle. In the second class which is also our main... will create a object of a Rectangle class. Now we ask the user to input two values