Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help needed! Design: The ConicalFrustum class has fields, a constructor, and methods as outlined below (1) Fields (instance variables): label of type String, radiusl of

Help needed! image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Design: The ConicalFrustum class has fields, a constructor, and methods as outlined below (1) Fields (instance variables): label of type String, radiusl of type double, radius2 of type double, and height of type double. Initialize the String to "and the double variables to 0 in their respective declarations. These instance variables should be private so that they are not directly accessible from outside of the ConicalFrustum class, and these (2) Constructor: Your ConicalFrustum class must contain a public constructor that accepts four parameters (see types of above) representing the label, radius, radius2, and height. Instead of assigning the parameters directly to the fields, the respective set method for each field (described below) should be called since they are checking the validity of the parameter. For example, instead of using the statement label labelIn: use the statement setLabel (labelIn) Below are examples of how the constructor could be used to create Conical Frustum objects. Note that although String and numeric literals are used for the actual parameters (or arguments) in these examples, variables of the required type could have been used instead of the literals -Small", 0.50.750.25)i ConicalFrustum example2 = new conica!Frustum ("Medium", 5.1, 10.2, 15.9); ConicalFrustum example3-new ConicalFrustum("Large, 98.32, 199.0, 250.0) (3) Methods: Usually a class provides methods to access and modify each of its instance variables (known as get and set methods) along with any other required methods. The methods for ConicalFrustum, which should each be public, are described below. See the formulas in the figure above and the Code and Test section below for information on constructing these methods. o getLabel: Accepts no parameters and returns a String representing the label field. o setLabel: Takes a String parameter and returns a boolean. If the String parameter is not null, then the trimmed" String is set to the label field and the method returns true. Otherwise, the method returns false and the label is not set o getRadiusl: Accepts no parameters and returms a double representing the radiusl o setRadiusl: Takes a double parameter and returns a boolean. If the double field parameter is non-negative, then the parameter is set to the radius1 field and the method returns true. Otherwise, the method returns false and the radiusl field is not set. o getRadius2: Accepts no parameters and returns a double representing the radius2 field. setRadius2: Takes a double parameter and returns a boolean. If the double parameter is non-negative, then the parameter is set to the radius2 field and the method returns true. Otherwise, the method returns falseand the radius2 field is not set. o o getHeight: Accepts no parameters and returns a double representing the height field

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

Step: 3

blur-text-image

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

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions