Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

OO Concepts to be implemented . Packages . Interface . Inheritance . Exception handling . Factory design pattern NOTE: JavaDoc, UML and Testplan are NOT

image text in transcribedimage text in transcribed
OO Concepts to be implemented . Packages . Interface . Inheritance . Exception handling . Factory design pattern NOTE: JavaDoc, UML and Testplan are NOT required for this Lab exam. Requirements Open Eclipse IDE and create a project folder named Fname_Lname_312.zip. Inside of this you will create a short well formatted Java application that implements the above OO concepts to compute and display the Surface Area of a cylinder and cuboid (See Sample output). Note: You will create calculateSurfaceArea() method instead of calculateVolume() that is shown in the UML. As per the above UML, your completed program will comprise the following interfaces and classes: 1. Shape interface . CalculateSurfaceArea(): You will define this method in the interface to compute the Surface Area of a shape. . Package name: 'Factory' to host the Shape interface. 2. Cylinder class . Provides required implementation of interface Shape that represents a cylinder. . Private fields: radius, height - both can hold decimal values. . Package name: PossibleObjects . Methods: getRadius(), getHeight(), and calculateSurfaceArea(), a parameterized constructor that takes two parameters. . Note: Surface Area of a cylinder is given by 2(rrh + mr2 ) where it is 3.14 and h represents the height of the cylinder. 3. Cuboid class . Provides required implementation of interface Shape that represents a cuboid. . Private fields: length, width, height - all of them can hold decimal values. . Package name: PossibleObjects . Methods: getLength(), getWidth(), getHeight() and calculateSurfaceArea(), a parameterized constructor that takes three parameters. . Note: Surface Area of a cuboid is given by 2(L*w + (*h + w*h) where L is length, w is width and h is the height of the cuboid.4. ShapeFactory class The shape factory class will create the shape objects based on user input . Scanner: scanner will handle user input . Package name: Factory . Methods: createShape():Shape - a static method that takes an int parameter and returns the Shape created based on user input. The method needs a scanner to handle user input. It also uses a switch statement to ask the user to enter radius and height if the user selects 1, or the length, width, and height if the user selects 2. ShapeFactory class will create either a Cylinder or a Cuboid object based on the user input. . Hint: Below is a possible way to implement part of the createShape method: switch (choice) { case 1: System. out . println ("Create Cylinder") ; System. out . print ("Enter radius: ") ; double radius = input . nextDouble () ; System. out . print ("Enter height: ") ; double height = input . nextDouble () ; return new Cylinder (radius, height) ; 5. Shape Test class . Hosts the main method used to run the program. . Uses ShapeFactory class to create shape objects and compute the Surface Area based on user input. . A switch-based menu allows a user to select the shape and enter data values for its fields. The program then computes the Surface Area of the cylinder and prints it. . Package name: TestDriver 6. Create headers in all classes

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions