The design for class and  inheritance 1. Inheritance  progrmming (1).Create class Point, with two private instance variables x and y that representd for the coodinates of a point. Provide  constructor for initializing two instance variables. Provide  set and get methods for each instance variable, Provide toString method to return formatted string for a point coodinates.   (2). Create class Circle,it inheritance from Point. Provide  a integer private redius instance variable. Provide constructor to initialize the center coodinates and redius for a circle,.In the constructor  it must calls its supperclass constructor by using super(x,y); Provide  set  and get  for  redius instance variable. Provide two methods for calculating its area and perimeter. Provide toString method to return a formatted string  for a circle features.In the method, it must calls its supperclass toString method by using super.toString().   (3)Similar to the above class Circle definitionto,Design Rectangle class.   (4)Similar to the above class Rectangle definition ,Design Cube class, It has a hight instance variable. Calculate the surface area and volumn for a Cube.   (5)Design a test-class to test above four classes functionality. It creates four objects for these classes and call the corresponding methods to test entire functionality for each class.                             Complete the following code:                         ……       class GeometricTest {     public static void main (String[] args)     {                System.out.println(new Point(1,1));                  Circle circle = new Circle(3,-1,6);         System.out.println(circle.toString());         System.out.printf("Area of Circle = %.2f\n",circle.getArea());             Rectangle r = new Rectangle(1,2,4,5);         System.out.println(r.toString());         System.out.printf("Area of Rectangle = %.2f\n",r.getArea());             Cube c = new Cube(4,5,2);           System.out.println(c.toString());         System.out.printf("Area of cube = %.2f\n",c.getArea());         System.out.printf("Volume of cube = %.2f\n",c.getVolume());       } }     The running output: Point: 1,1 Circle : Center:3,-1 radius:6 Area of Circle = 113.04 Rectangle : Top left 1,2 length:4 width:5 Area of Rectangle = 20.00 Cube : Top left Point:4,5 depth :2 Area of cube = 24.00 Volume of cube = 8.00

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

5.The design for class and  inheritance

  1. 1. Inheritance  progrmming

(1).Create class Point, with two private instance variables x and y that representd for the coodinates of a point.

Provide  constructor for initializing two instance variables.

Provide  set and get methods for each instance variable,

Provide toString method to return formatted string for a point coodinates.

 

(2). Create class Circle,it inheritance from Point.

Provide  a integer private redius instance variable.

Provide constructor to initialize the center coodinates and redius for a circle,.In the constructor  it must calls its supperclass constructor by using super(x,y);

Provide  set  and get  for  redius instance variable.

Provide two methods for calculating its area and perimeter.

Provide toString method to return a formatted string  for a circle features.In the method, it must calls its supperclass toString method by using super.toString().

 

(3)Similar to the above class Circle definitionto,Design Rectangle class.

 

(4)Similar to the above class Rectangle definition ,Design Cube class,

It has a hight instance variable.

Calculate the surface area and volumn for a Cube.

 

(5)Design a test-class to test above four classes functionality.

It creates four objects for these classes and call the corresponding methods to test entire functionality for each class.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Complete the following code:

           

           

……

 

 

 

class GeometricTest

{

    public static void main (String[] args)

    {

      

        System.out.println(new Point(1,1));

        

        Circle circle = new Circle(3,-1,6);

        System.out.println(circle.toString());

        System.out.printf("Area of Circle = %.2f\n",circle.getArea());

 

 

        Rectangle r = new Rectangle(1,2,4,5);

        System.out.println(r.toString());

        System.out.printf("Area of Rectangle = %.2f\n",r.getArea());

 

 

        Cube c = new Cube(4,5,2);

 

        System.out.println(c.toString());

        System.out.printf("Area of cube = %.2f\n",c.getArea());

        System.out.printf("Volume of cube = %.2f\n",c.getVolume());

 

    }

}

 

 

The running output:

Point: 1,1

Circle : Center:3,-1 radius:6

Area of Circle = 113.04

Rectangle : Top left 1,2 length:4 width:5

Area of Rectangle = 20.00

Cube : Top left Point:4,5 depth :2

Area of cube = 24.00

Volume of cube = 8.00

 

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Class
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
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