Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

JAVA

A company needs to develop an object-oriented library with a few Java classes for
the following task. Overall, they want the classes to model the geometric shapes and calculate
their areas. These geometric shapes include Square, Rectangle, Circle, and Triangle.
The above four shapes share common attributes such as name and color. The area of a shape
can be calculated by using a method area( ) which can be implemented only until the exact
shape is known. Different shapes need a different area( ) method.
1) Design a Java abstract class called Shape to model this situation, which will serve as a parent
class. Write its code;
2). All the above shapes should be drawable by the users by calling the draw( ) method.
Different shapes are drawn differently. You should design a Java interface named Drawable
to provide this method for the shape classes to implement in their own ways. Write its code;
3). Write the code for the four classes: Square, Rectangle, Circle, and Triangle.
Note:
• You should decide what data members you should have for each class based on
mathematical concepts;
• You should determine the relationship between the four classes and Drawable and Shape;
• You should provide all constructors, get/set methods, the draw( ) method, the area( )
method, and toString() methods.
• Use the following formulas for calculating areas of the four shapes:
o Area of Square = side x side;
o Area of Rectangle = length x width;
o Area of Circle = PI x radius x radius;
o Area of Triangle = 0.5 x base x height;
• In the test driver code, create an object of each of the four classes with some dimension
data, put the objects in an array, and pass the object array to a method called
displayShapeAreas(Shape[ ] shapeArray) and have their areas displayed.

Expert Solution
Check Mark
Knowledge Booster
Background pattern image
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
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education