The primary focus of this assignment is the use of interfaces. In programming, an interface is a public avenue by which data can be accessed and/or manipulated. five Java classes called Point, Circle, Square, Rectangle, and TestAll, as well as a Java interface called FigureGeometry. The TestAll class should implement the main method which tests all of the other files    Point.java Description: Instance Variables: private int width;//stores the width of a Point object private private int height;//stores the height of a Point object  Constructor: Point() Parameters: int theWidth, int theHeight Purpose: initializes the width and height of a Point object in the following manner: width = theWidth; height = theHeight; Methods: public int getWidth(){//returns the width of a Point object in the following manner return width;} public int getHeight(){//returns the height of a Point object in the following manner: return height;} public void setWidth(int theWidth){//assigns the width of a Point object as follows: width = theWidth;} public void setHeight(int theHeight{//assigns the height of a Point object as follows: height = theHeight;   }   FigureGeometry.java Description: public interface FigureGeometry{final float PI = 3.14f; //Classes that implement the FigureGeometry interface MUST override this method which should return the geometric area of a figure: //In an interface, methods are always public and abstract. Using these unnecessary modifiers is redundant, and future versions of //Java may not support them. float getArea (); //Classes that implement the FigureGeometry interface MUST also override this method which should return the geometric perimeter of a //figure: float getPerimeter ();}   Circle.java Description: Instance Variables: private float radius;//stores the radius of a Circle object Constructor: Circle() Parameters: float theRadius; Purpose:initializes the radius of a Circle in the following manner: radius = theRadius; Methods: 1-public float getRadius(){//returns the radius of a Circle object as follows: return radius; } 2-public float getArea(){//returns the area of a Circle object as follows: return getRadius() * getRadius() * PI; 3-public float getPerimeter(){//returns the perimeter of a Circle object as follows: return getRadius() * 2 * PI; } 4-public void setRadius(float theRadius){//assigns the radius of a Circle object as follows: radius = theRadius; }   The following coding example illustrates a version of the Circle class: public class Circle implements FigureGeometry{//Stores the radius of this figure: private float radius; //Returns the radius of this figure: public float getRadius (){return  radius;} //Returns the area of this figure: public float getArea (){ return getRadius() * getRadius() * PI;} //Returns the perimeter of this figure: public float getPerimeter (){ return getRadius() * 2 * PI;} //Assigns the radius of this figure: public void setRadius (float theRadius){radius = theRadius; } }   Square.java Description: Instance Variables: private Point point; //stores the Point of a Square object Constructor: Square() Parameters: Point p; Purpose:initializes the object point of the Square object in the following manner: point= p; Methods: 1-public float getSideLength(){//returns the length of the side of the square as follows: return point.getWidth();} 2-public float getArea(){//returns the area of a Square object as follows: return getSideLength() *getSideLength();} 3-public float getPerimeter(){//returns the perimeter of a Square object as follows: return getSideLength() * 4;} 4-public void setPoint(Point p){//assigns the point of a Square  object as follows: point= p;}   Rectangle.java Description:   Instance Variables: private Point point;//stores the point of the Rectangle object  Constructor: Rectangle() Parameters: Point p; Purpose: initializes the Point of a Rectangle object in the following manner: point = p; Methods: 1-public int getWidth() {//returns the width of a Rectangle object as follows: return point.getWidth();} 2-public int getHeight() {//returns the height of a Rectangle object as follows: return point.getHeight();} 3-public float getArea() {//returns the area of a Rectangle object as follows: return getWidth() * getHeight ();} 4-public float getPerimeter() {//returns the perimeter of a Rectangle object as follows: return (getWidth+getHeight()) * 2;} 5-public void setPoint(Point p) {//assigns the point of a Rectangle object as follows: point = p;}   TestAll.java Description:   the main method must perform the following tasks: an instance of Circle, called c1, with a radius of 5.  an instance of a Point, called p1, with a side length of 5.  an instance of a Point, called p2, with a side length of 5 and a side height of 7.  an instance of a Square, called s1, with a parameter p1.  an instance of Rectangle, called r1, with a parameter p2. Print the radius of c1. Print the area of c1. Print the perimeter of c1. Print the side length of s1. Print the area of s1. Print the perimeter of s1, Print the width of r1. Print the height of r1. Print the area of r1. Print the perimeter of r1.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

The primary focus of this assignment is the use of interfaces. In programming, an interface is a public avenue by which data can be accessed and/or manipulated.

five Java classes called Point, Circle, Square, Rectangle, and TestAll, as well as a Java interface called FigureGeometry. The TestAll class should implement the main method which tests all of the other files 

 

Point.java Description:

Instance Variables:

private int width;//stores the width of a Point object private

private int height;//stores the height of a Point object 

Constructor: Point()

Parameters:

int theWidth,

int theHeight

Purpose: initializes the width and height of a Point object in the following manner:

width = theWidth;

height = theHeight;

Methods:

public int getWidth(){//returns the width of a Point object in the following manner

return width;}

public int getHeight(){//returns the height of a Point object in the following manner:

return height;}

public void setWidth(int theWidth){//assigns the width of a Point object as follows:

width = theWidth;}

public void setHeight(int theHeight{//assigns the height of a Point object as follows:

height = theHeight;

 

}

 

FigureGeometry.java Description:

public interface FigureGeometry{final float PI = 3.14f;

//Classes that implement the FigureGeometry interface MUST override this method which should return the geometric area of a figure:

//In an interface, methods are always public and abstract. Using these unnecessary modifiers is redundant, and future versions of

//Java may not support them.

float getArea ();

//Classes that implement the FigureGeometry interface MUST also override this method which should return the geometric perimeter of a //figure:

float getPerimeter ();}

 

Circle.java Description:

Instance Variables:

private float radius;//stores the radius of a Circle object

Constructor: Circle()

Parameters:

float theRadius;

Purpose:initializes the radius of a Circle in the following manner:

radius = theRadius;

Methods:

1-public float getRadius(){//returns the radius of a Circle object as follows:

return radius;

}

2-public float getArea(){//returns the area of a Circle object as follows:

return getRadius() * getRadius() * PI;

3-public float getPerimeter(){//returns the perimeter of a Circle object as follows:

return getRadius() * 2 * PI;

}

4-public void setRadius(float theRadius){//assigns the radius of a Circle object as follows:

radius = theRadius;

}

 

The following coding example illustrates a version of the Circle class:

public class Circle implements FigureGeometry{//Stores the radius of this figure:

private float radius;

//Returns the radius of this figure:

public float getRadius (){return  radius;}

//Returns the area of this figure:

public float getArea (){

return getRadius() * getRadius() * PI;}

//Returns the perimeter of this figure:

public float getPerimeter (){ return getRadius() * 2 * PI;}

//Assigns the radius of this figure:

public void setRadius (float theRadius){radius = theRadius;

}

}

 

Square.java Description:

Instance Variables:

private Point point; //stores the Point of a Square object

Constructor: Square()

Parameters:

Point p;

Purpose:initializes the object point of the Square object in the following manner:

point= p;

Methods:

1-public float getSideLength(){//returns the length of the side of the square as follows:

return point.getWidth();}

2-public float getArea(){//returns the area of a Square object as follows:

return getSideLength() *getSideLength();}

3-public float getPerimeter(){//returns the perimeter of a Square object as follows:

return getSideLength() * 4;}

4-public void setPoint(Point p){//assigns the point of a Square  object as follows:

point= p;}

 

Rectangle.java Description:
 

Instance Variables:

private Point point;//stores the point of the Rectangle object 

Constructor: Rectangle()

Parameters:

Point p;

Purpose: initializes the Point of a Rectangle object in the following manner:

point = p;

Methods:

1-public int getWidth()

{//returns the width of a Rectangle object as follows:

return point.getWidth();}

2-public int getHeight()

{//returns the height of a Rectangle object as follows:

return point.getHeight();}

3-public float getArea()

{//returns the area of a Rectangle object as follows:

return getWidth() * getHeight ();}

4-public float getPerimeter()

{//returns the perimeter of a Rectangle object as follows:

return (getWidth+getHeight()) * 2;}

5-public void setPoint(Point p)

{//assigns the point of a Rectangle object as follows:

point = p;}

 

TestAll.java Description:

 

the main method must perform the following tasks:

  1. an instance of Circle, called c1, with a radius of 5.
  2.  an instance of a Point, called p1, with a side length of 5.
  3.  an instance of a Point, called p2, with a side length of 5 and a side height of 7.
  4.  an instance of a Square, called s1, with a parameter p1.
  5.  an instance of Rectangle, called r1, with a parameter p2.
  6. Print the radius of c1.
  7. Print the area of c1.
  8. Print the perimeter of c1.
  9. Print the side length of s1.
  10. Print the area of s1.
  11. Print the perimeter of s1,
  12. Print the width of r1.
  13. Print the height of r1.
  14. Print the area of r1.
  15. Print the perimeter of r1.
 
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 6 images

Blurred answer
Knowledge Booster
Developing computer interface
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education