View the step-by-step solution to:

Question

Screen Shot 2019-10-02 at 11.52.14 AM.png

src="/qa/attachment/10701307/" alt="Screen Shot 2019-10-02 at 11.52.24 AM.png" />

hello!


I am in working on a java program that is required to create an 3 different programs. I have completed the first part of project but I am confused on how to set up the second part. (IceCreamConeList.java part)


I have the fields and constructors set up but I am not sure if they are correct.

Screen Shot 2019-10-02 at 11.52.14 AM.png

Project: Ice Cream Cone List App
Page 2 of 7
. IceCreamCone.java (assuming that you successfully created this class in Project 4, just copy
the file to your new Project 5 folder and go on to IceCreamConeList.java on page 4.
Otherwise, you will need to create IceCreamCone.java as part of this project.)
Requirements: Create an IceCreamCone class that stores the label, radius, and height. The
radius and height must be greater than zero. The IceCreamCone class also includes methods to set
and get each of these fields, as well as methods to calculate the surface area and volume of the
cone, hemisphere, and the IceCreamCone object, and a method to provide a String value of an
IceCreamCone object (i.e., a class instance).
Design: The IceCreamCone class has fields, a constructor, and methods as outlined below.
(1) Fields (instance variables): label of type String, radius of type double, and height of type
double. Initialize the String to "" and the double to 0 in their respective declarations. These
instance variables should be private so that they are not directly accessible from outside of the
IceCreamCone class, and these should be the only instance variables in the class.
2) Constructor: Your IceCreamCone class must contain a public constructor that accepts three
parameters (see types of above) representing the label, radius, and height. Instead of
assigning the parameters directly to the fields, the respective set method for each field
(described below) should be called. For example, instead of the statement label =
labelIn; use the statement setLabel (labelIn) ; Below are examples of how the
constructor could be used to create IceCreamCone 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.
IceCreamCone exl = new IceCreamCone ("Ex 1", 1, 2) ;
IceCreamCone ex2 = new IceCreamCone (" Ex 2 ", 12.3, 25.5) ;
IceCreamCone ex3 = new IceCreamCone ("Ex 3", 123.4, 900) ;
(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 IceCreamCone, which should each be public, are described below. See formulas
in Code and Test below.
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 label field is set to the "trimmed" String and the method returns true.
Otherwise, the method returns false and the label field is not set.
o
getRadius: Accepts no parameters and returns a double representing the radius field.
setRadius: Accepts a double parameter and returns a boolean as follows. If the
double is greater than zero, sets the radius field to the double passed in and returns true.
Otherwise, the method returns false and does not set the radius field.
o getHeight: Accepts no parameters and returns a double representing the height field.
Page 2 of 7

Screen Shot 2019-10-02 at 11.52.24 AM.png

Project: Ice Cream Cone List App Page 3 of 7 o setHeight: Accepts a double parameter and returns a boolean as follows. If the double is greater than zero, sets the height field to the double passed in and returns true.
Otherwise, the method returns false and does not set the height field. 0 surfaceArea: Accepts no parameters and returns the double value for the total
surface area calculated using formula above and the values of the radius and height fields. 0 volume: Accepts no parameters and returns the double value for the volume calculated
using formula above and the values of the radius and height fields. 0 toString: Returns a String containing the information about the lceCreamCone object
formatted as shown below, including decimal formatting ('1, H0 . Otttttt“) for the
double values. Newline and tab esmpe sequences should be used to achieve the proper
layout. In addition to the field values (or corresponding “g ” methods), the following
methods should be used to compute appropriate values in the toString method:
surfaceArea () and volume U — Each line should have no trailing spaces (e.g., there
should be no spaces before a newline (\n) character). The tostring value for exl, 9x2,
and ex3 respectively are shown below (the blank lines are not part of the toString values). IceCreamCone "Ex 1“ with radius = 1.0 and height = 2.0 units has:
surface area = 13.303 square units
volume = 4.1887902 cubic units IceCreamCone "Ex 2" with radius = 12.3 and height = 25.5 units has:
surface area = 2,044.583765? square units
volume = ?,93?.36892?B cubic units Icecreamcane "Ex 3“ with radius = 123.4 and height = 900.0 units has:
surface area = 447,847.205692? square units
volume = 18,287,115.030?615 cubic units Code and Test: As you implement your IccCreamCone class, you should compile it and then test
it using interactions. For example, as soon you have implemented and successfully compiled the
constructor, you should create instances of IceCreamCone in interactions (e. g., copy/paste the
examples above). Remember that when you have an instance on the workbench, you can unfold
it to see its values. You can also open a viewer canvas window and drag the instance fiom the
Workbench tab to the canvas window. After you have implemented and compiled one or more
methods, create an IceCreaniCone object in interactions and invoke each of your methods on the
object to make sure the methods are working as intended. You may find it useful to create a
separate class with a main method that creates an instance of [ceCreamCone then prints it out
This would be similar to the IceCreamConeApp class you will create below, except that in the
IceCreamConeApp class you will read in the values and then create and print the object. Page 3 of 7

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes