Make a class "shape" that stores two values: the name of a shape and its area. Initially the name of the shape is declared by the user and the area can be set later using a mutator method setArea The class has a function named "printing that prints on the screen "ssssssss is a shape with area xxX.XX where "ssssssss" is the name of the shape and "xxx.xx" is the area of the given shape object in 2 decimal places. Implement an accessor method to enable accessing the name of the shape.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
Need code in java PLZZ quick..i will give positive feedback.
Make a class "Shape that stores two values: the name of a shape and its area.
Initially the name of the shape is declared by the user and the area can be set
later using a mutator method setArea The class has a function named
"printing that prints on the screen "ssssssss is a shape with area xxx.xx ";
where "ssssssss" is the name of the shape and "xxx.xx" is the area of the given
shape object in 2 decimal places. Implement an accessor method to enable
accessing the name of the shape.
Shape
Polygon
Create another class named "Polygon" inheriting the "Shape" class with the same
"printing function that prints information of a polygon object as shown in the output sample
in Figure 2 below. A "Polygon stores values of two sides of the defined shape object. This
class also computes and updates the area value of the given shape; whilst constructing a
polygon object; as follows:
• For "Triangle" shape with two sides presenting height and base of a triangle:
area of Triangle = height x base
• For "Rectangle" shape with two sides presenting width and length of a rectangle:
area of Rectangle = length x width
Given the following code of the main tester program and the corresponding sample output; write the implementation of the
two classes "Shape" and "Polygon".
Main Tester Code (Figure 1):
public class FormATester (
3 8
public static void main (Stringt] args) (
Shape[] shapes = new Shape [3]:
public class FormATester
public statie void main(String[] args)
2
4.
Shape() shapes - new Shape[3]:
shapes (0] - new Polygon ("Triangle", 12.0, 8.0):
shapes (11 - new Polygon ("Rectangle", 3.5, 4.5):
shapes (2] - new Shape ("Circle"):
shapes[2].setArea (256.57):
5.
10
for (Shape s: shapes)
/display intormation of each shape object
s.printing ():
System.out.printin ():
11
12
13
14
15
) //end of main
1//end of FormATester
17
Sample output run (Figure 2):
runt
Triangle is a shape with area 48.00 and two sides: 12.0, 8.0
Rectangle is a shape with area 15.75 and two sident 3.5, 4.5
Circle in a shape with area 256,57
BUILD SUCCESSFUL (total time: 0 neconds)
E Peragraph- BIEE
Shape" class implementation:
"Połygon" class implementation:
Transcribed Image Text:Make a class "Shape that stores two values: the name of a shape and its area. Initially the name of the shape is declared by the user and the area can be set later using a mutator method setArea The class has a function named "printing that prints on the screen "ssssssss is a shape with area xxx.xx "; where "ssssssss" is the name of the shape and "xxx.xx" is the area of the given shape object in 2 decimal places. Implement an accessor method to enable accessing the name of the shape. Shape Polygon Create another class named "Polygon" inheriting the "Shape" class with the same "printing function that prints information of a polygon object as shown in the output sample in Figure 2 below. A "Polygon stores values of two sides of the defined shape object. This class also computes and updates the area value of the given shape; whilst constructing a polygon object; as follows: • For "Triangle" shape with two sides presenting height and base of a triangle: area of Triangle = height x base • For "Rectangle" shape with two sides presenting width and length of a rectangle: area of Rectangle = length x width Given the following code of the main tester program and the corresponding sample output; write the implementation of the two classes "Shape" and "Polygon". Main Tester Code (Figure 1): public class FormATester ( 3 8 public static void main (Stringt] args) ( Shape[] shapes = new Shape [3]: public class FormATester public statie void main(String[] args) 2 4. Shape() shapes - new Shape[3]: shapes (0] - new Polygon ("Triangle", 12.0, 8.0): shapes (11 - new Polygon ("Rectangle", 3.5, 4.5): shapes (2] - new Shape ("Circle"): shapes[2].setArea (256.57): 5. 10 for (Shape s: shapes) /display intormation of each shape object s.printing (): System.out.printin (): 11 12 13 14 15 ) //end of main 1//end of FormATester 17 Sample output run (Figure 2): runt Triangle is a shape with area 48.00 and two sides: 12.0, 8.0 Rectangle is a shape with area 15.75 and two sident 3.5, 4.5 Circle in a shape with area 256,57 BUILD SUCCESSFUL (total time: 0 neconds) E Peragraph- BIEE Shape" class implementation: "Połygon" class implementation:
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY