Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started