Question: public class Rectangle implements Shape { public class Rectangle implements Shape { private int length; / / length units along x axis private int height;
public class Rectangle implements Shape public class Rectangle implements Shape
private int length; length units along x axis
private int height; height units along y axis
private Point position; position is the xy coordinates of lower left corner of the rectangle
Purpose: initializes this Rectangle with length and height of
and position to new Point at
Parameters: none
public Rectangle
this.length ;
this.height ;
this.position new Point;
Purpose: initializes this Rectangle with given length and height
and position to new Point at
Parameters: int length, int height
Precondition: given length and height
public Rectangleint length, int height
this.length length;
this.height height;
this.position new Point;
Purpose: initializes this Rectangle with given length, height and position
Parameters: int length, int height, Point position
Precondition: given length and height position is not null
public Rectangleint length, int height, Point position
this.length length;
this.height height;
this.position position;
Purpose: prints a message about the characteristics of this Rectangle
Parameters: none
Returns: void
public void printCharacteristics
if length height
System.out.printlnlong rectangle";
else if height length
System.out.printlntall rectangle";
else
System.out.printlnsquare;
public String toString
return "Rectangle of dimensions: length by height at Point: position;
private int length; length units along x axis
private int height; height units along y axis
private Point position; position is the xy coordinates of lower left corner of the rectangle
Purpose: initializes this Rectangle with length and height of
and position to new Point at
Parameters: none
public Rectangle
this.length ;
this.height ;
this.position new Point;
Purpose: initializes this Rectangle with given length and height
and position to new Point at
Parameters: int length, int height
Precondition: given length and height
public Rectangleint length, int height
this.length length;
this.height height;
this.position new Point;
Purpose: initializes this Rectangle with given length, height and position
Parameters: int length, int height, Point position
Precondition: given length and height position is not null
public Rectangleint length, int height, Point position
this.length length;
this.height height;
this.position position;
Purpose: prints a message about the characteristics of this Rectangle
Parameters: none
Returns: void
public void printCharacteristics
if length height
System.out.printlnlong rectangle";
else if height length
System.out.printlntall rectangle";
else
System.out.printlnsquare;
public String toString
return "Rectangle of dimensions: length by height at Point: position;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
