Introduction to Java Programming and Data Structures, Comprehensive Version, Student Value Edition (11th Edition)
11th Edition
ISBN: 9780134671604
Author: Y. Daniel Liang
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 13.2, Problem 13.2.2CP
The getArea() and getPerimeter() methods may be removed from the GeometricObject class. What are the benefits of defining getArea() and getPerimeter() as abstract methods in the GeometricObject class?
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Design and implement a Java class named Book with two data members: title and price. The class should have suitable constructors, get/set methods, and the toString method. Design and implement another Java class named BookShelf which has an ArrayList data member named bookList to store books. The class should have suitable constructors, get/set methods, and the toString method, as well as methods for people to add a book (prototype: addBook(Book book)), remove a book (prototype: removeBook(Book book)), and search for a book (prototype: findBook(Book book)). Test the two classes by creating a Bookshelf object and five Book objects. Add the books to the bookshelf. Display the contents of the bookshelf. Test the removeBook and findBook methods as well. Take screenshots of your tests and submit them with your Java code (not the whole project)
Two methods are not defined in the AbstractCollection class but must be defined in its subclasses for its other methods to function properly. Which methods are these?
*Python
Shape
-width: double
-length: double
+allmutatorMethods
Shapes2D
Shapes3D
-height:double
*calSize():double
+calVolume():double
1.
Define class Shape, 2DShape and 3DShape as per UML class diagram given.
2.
Define all mutator methods(set and get) for all classes.
3.
Define methods calArea() with formula area - width * length for 2DShapes.
4.
Define methods calArea() with formula calvolume, volume = width*length*height for 3DShapes.
In the main program, declare and set data in 1 object of 3DShapes. Create an array OR ArrayList of 2DShapes, set and display the info of all
objects as shown in the output.
5.
Chapter 13 Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version, Student Value Edition (11th Edition)
Ch. 13.2 - Prob. 13.2.1CPCh. 13.2 - The getArea() and getPerimeter() methods may be...Ch. 13.2 - True or false? a.An abstract class can be used...Ch. 13.3 - Prob. 13.3.1CPCh. 13.3 - Prob. 13.3.2CPCh. 13.3 - Prob. 13.3.3CPCh. 13.3 - What is wrong in the following code? (Note the...Ch. 13.3 - What is wrong in the following code? public class...Ch. 13.4 - Can you create a Calendar object using the...Ch. 13.4 - Prob. 13.4.2CP
Ch. 13.4 - How do you create a Calendar object for the...Ch. 13.4 - For a Calendar object c, how do you get its year,...Ch. 13.5 - Prob. 13.5.1CPCh. 13.5 - Prob. 13.5.2CPCh. 13.5 - Prob. 13.5.3CPCh. 13.5 - Prob. 13.5.4CPCh. 13.6 - Prob. 13.6.1CPCh. 13.6 - Prob. 13.6.2CPCh. 13.6 - Can the following code be compiled? Why? Integer...Ch. 13.6 - Prob. 13.6.4CPCh. 13.6 - What is wrong in the following code? public class...Ch. 13.6 - Prob. 13.6.6CPCh. 13.6 - Listing 13.5 has an error. If you add list.add...Ch. 13.7 - Can a class invoke the super.clone() when...Ch. 13.7 - Prob. 13.7.2CPCh. 13.7 - Show the output of the following code:...Ch. 13.7 - Prob. 13.7.4CPCh. 13.7 - What is wrong in the following code? public class...Ch. 13.7 - Show the output of the following code: public...Ch. 13.8 - Prob. 13.8.1CPCh. 13.8 - Prob. 13.8.2CPCh. 13.8 - Prob. 13.8.3CPCh. 13.9 - Show the output of the following code: Rational r1...Ch. 13.9 - Prob. 13.9.2CPCh. 13.9 - Prob. 13.9.3CPCh. 13.9 - Simplify the code in lines 8285 in Listing 13.13...Ch. 13.9 - Prob. 13.9.5CPCh. 13.9 - The preceding question shows a bug in the toString...Ch. 13.10 - Describe class-design guidelines.Ch. 13 - (Triangle class) Design a new Triangle class that...Ch. 13 - (Shuffle ArrayList) Write the following method...Ch. 13 - (Sort ArrayList) Write the following method that...Ch. 13 - (Display calendars) Rewrite the PrintCalendar...Ch. 13 - (Enable GeometricObject comparable) Modify the...Ch. 13 - Prob. 13.6PECh. 13 - (The Colorable interface) Design an interface...Ch. 13 - (Revise the MyStack class) Rewrite the MyStack...Ch. 13 - Prob. 13.9PECh. 13 - Prob. 13.10PECh. 13 - (The Octagon class) Write a class named Octagon...Ch. 13 - Prob. 13.12PECh. 13 - Prob. 13.13PECh. 13 - (Demonstrate the benefits of encapsulation)...Ch. 13 - Prob. 13.15PECh. 13 - (Math: The Complex class) A complex number is a...Ch. 13 - (Use the Rational class) Write a program that...Ch. 13 - (Convert decimals to fractious) Write a program...Ch. 13 - (Algebra: solve quadratic equations) Rewrite...Ch. 13 - (Algebra: vertex form equations) The equation of a...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
When placed at the end of an IfThenElself statement, this provides default action when none of the ElseIf state...
Starting Out With Visual Basic (8th Edition)
The class Stuff has both a copy constructor and an overloaded - operator. Assume blob and clump are both instan...
Starting Out with C++ from Control Structures to Objects (9th Edition)
In what year was Plankalkl designed? In what year was that design published?
Concepts Of Programming Languages
Determine the slope of the simply supported beam at A. E = 200 GPa and I = 39.9(106) m4. F126
Mechanics of Materials (10th Edition)
What are the steps in chemical machining using photosensitive resists?
Degarmo's Materials And Processes In Manufacturing
Stadium Seating There are three seating categories at a stadium. Class A seats cost 20. Class B seats cost 15, ...
Starting Out with Python (4th Edition)
Knowledge Booster
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
- Question: Implement the following UML class diagrams and test their methods. Shape - dimension1 : double - dimension2 : double + Shape(d1: double, d2 : double) + setDimension1(d1: double) : void + setDimension2(d2 : double) : void + getDimension10 : double + getDimension20 : double + getName() : String + getArea) : double + toString() : String Circle Rectangle - circleld : int - circleCounter : int + Circle(radius : double) + setRadius(radius : double) : void + getRadius) : double + getCircleld) : int + getCircleCounter) : int + getName() : String + getArea() : double + toString) : String - rectangleld : int - rectangleCounter : int + Rectangle(side1 : double, side2 : double) + setSide1(side1 : double) : void + getSide10 : double + setSide2(side2 : double) : void + getSide20 : double + getRectangleld0 : int + getRectangleCounter0 : int + getName() : String + getArea() : double + toString) : Stringarrow_forwardMake sure you know the difference between an abstract class and an interface and constructors.arrow_forwardjava and can you do it on eclipse pleasearrow_forward
- Please write the code in Java eclipse.arrow_forwardDesign a new Triangle class that extends the abstract GeometricObject class:Draw the UML diagram for the classes Triangle and GeometricObject0arrow_forwardDefine a Polygon interface that has methods area() and perimeter(). Then implement classes for Triangle, Quadrilateral, Pentagon, Hexagon, and Octagon, which implement this interface, with the obvious meanings for the area() and perimeter() methods. Also implement classes, IsoscelesTriangle, Equilateral- Triangle, Rectangle, and Square, which have the appropriate inheritance relationships. Finally, write a simple user interface, which allows users to create polygons of the various types, input their geometric dimensions, and then out- put their area and perimeter. For extra effort, allow users to input polygons by specifying their vertex coordinates and be able to test if two such polygons are similar ORIGINAL WORKS ONLYarrow_forward
- Can we have static methods in an Interface?arrow_forwardWrite a constructor for the IceCreamCup class. The constructor takes the name, and a List of Flavor s (name it fList) as parameters. It initializes the instance variables with the parameters. Use shallow copy for initializing the list of Flavor s. (Throw an IllegalArgumentException if the name is null, or the Flavor list is null or empty.) Note that successful instantiation should increase nCups by 1.arrow_forwardShow me the ropes for creating a method that accepts both primitive and reference kinds of parameters.arrow_forward
- Classes – Write a class to represent a AlternativeEnergyCar. Select the fields and methods that fit the modeling of an alternative energy car. Make sure to include code for the constructors, set/get methods, a toString() method.arrow_forwardImplement the following parking permit class using java It has a dependency on the car class, no need to implement the car class. Use the diagram for refrencearrow_forwardPart 1: Abstract Classes 1. Copy the source files of Circle, Rectangle and GeometricObject classes (located in LabFiles folder) and paste them in the default package (You may need to fix any problems related to package declaration). 2. Open Circle, Rectangle and GeometricObject classes using NetBeans editor and go through the classes’ implementation. 3. In the GeometricObject class add two methods called respectively getArea() and getPerimeter(). Discuss: 1. Is the area formula of a circle similar to area formula of a rectangle? Since: GeometricObject is the superclass of Circle and Rectangle, and getArea() method is a common method in both Circle and Rectangle classes. Then: 2. Should you define the getArea() method in the superclass GeometricObject? Or in the subclasses Circle and Rectangle? 3. If yes, Should the getArea() method be declared as abstract method in the superclass GeometricObject? Or as instant method? 4. Is declaring getArea() as abstract, would solve…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Microsoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY