Question: JAVA Tutorial 5 - Polymorphism (part 1) Topics: Demonstrating Polymorphism Use direct and indirect superclass reference to subclass object Use array of superclass reference to

JAVA  JAVA Tutorial 5 - Polymorphism (part 1) Topics: Demonstrating Polymorphism Use
direct and indirect superclass reference to subclass object Use array of superclass

Tutorial 5 - Polymorphism (part 1) Topics: Demonstrating Polymorphism Use direct and indirect superclass reference to subclass object Use array of superclass reference to subclass objects Send a subclass object to a method that receives a superclass reference Exercise 1 Consider the 7 classes provided with this exercise which are: Shape, TwoDimensionalShape, Circle, Rectangle, Square, Triangle, and Point. Analyze the definition of these classes and draw a simple class diagram (with only class names). Note: Expressions used to compute the areas and the circumferences are: Shape Circle Rectangle Square Triangle Area radius length width side- (base * height)/2 Perimeter 2*1* radius 2 (length + width) 4 side side a + base + side o Problem (Homework) Consider the following UML class diagram. Shape TwoDimensionalShape Three DimensionalShape Circle Square Triangle Sphere Cube Tetrahedron Fig. 9.3 Inheritance hierarchy UML class diagram for Shapes 1. Identify which classes are not yet implemented in Tutorial s. 2. Create the missing classes starting by the abstract classes, then the concrete classes. 3. We need to define a method called get Volume to compute the volume of the 3D objects. Place this method in the most appropriate class and, when needed, declare it as abstract or concrete method. 4. Write a program to test your newly added shapes. 5. Update the Drawing Test program to test the specifities of the newly added classes and their methods. Note: To compute the areas and volumes use the following expressions: Shape Area Volume Sphere 4* * radius Cube 6 * side side! Tetrahedron V3 a? a 672

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!