Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 0 : 5 3 5 G c Computer Science 2 CPSC 1 3 0 2 K Syllabi Calendars Misc. Project 2 : FrozenYogurt class

10:53
5Gc
Computer Science 2
CPSC 1302K
Syllabi
Calendars
Misc.
Project 2: FrozenYogurt class
Previous
Next
Objectives:
Design and write a Java c lass
Write and use fields (instance variables)
Write multiple constructors
Write accessor methods
Write mutator methods
Use the this keyword
Use string concatenation
Use a (single) Scanner object
Getting Help
This project sometimes takes students many, many hours. Please promise yourself that you will reach out to the CS Tutors or your instructor for help if you have already spent 10 or more hours on the project or if you have been stuck for more than 1 hour.
Description
For this project, you get to design and write a FrozenYogurt c lass that represents a frozen yogurt dessert. You also get to write FrozenYogurtDriver class, a driver c lass for your FrozenYogurt class.
FrozenYogurt class
Design and write your FrozenYogurt class to store the following:
Name of dessert (String
Price (double)
Base yogurt flavor (String)
Topping (String)
Additionally, include both a constructor without any parameters and one with parameters for the name, price, base flavor and topping (in that order). For the constructor without parameters, set the Strings to an empty string and the price to 0.0. Include appropriate accessor and mutator methods (and label them with comments including the terms "accessor" or "mutator"). So that the test cases compile, name the accessor methods:
getName ()
getPrice()
getYogurtFlavor()
getTopping()
Additionally, name the mutator methods:
setName()
setPrice()
setYogurtFlavor()
setTopping()
Note, a single letter not capitalized will prevent a test case from compiling and running correctly. Double check these method names in your code.
Include, appropriately, the this keyword in your code. Do not use it when it is not required. You may need to create a situation where it is required.
Additionally, include a method named description () that returns a String that describes each of the four fields for the class. Format it as shown at the bottom of the examples below. Note, there should be no parameters to description ().
Lastly, write your own custom method with either 1) one or more parameters, 2) a return value or 3) both parameter(s) and a return value.
The role of the FrozenYogurt class is to store the attributes of a frozen yogurt dessert. It could be used to store those values in an interactive session with a user at the keyboard or in a batch environment where other code is just setting values and using it (with no user at the keyboard). Consequently, your FrozenYogurt c lass should not use a Scanner object at all. Furthermore, you should not use System. out. print ()(nor System. out.print ln() statements in your FrozenYogurt class. Your Scanner object and calls to System. out.print() and System. out.print ln() should all be in the FrozenYogurtDriver class.
FrozenYogurtDriver class
Design and write a FrozenYogurtDriver class to be a driver for your FrozenYogurt class. Have your driver class welcome the user. Additionally, have the driver c lass request input to be used to populate two different FrozenYogurt objects then call each of the object's description () method. Additionally, call the custom method that you added on each object. If you want to get additional input from the user (that codePost was not expecting), be sure to do that after displaying everything that's in the examples (thereby passing the tests). Otherwise, your code will stall at that point in the code and time out. To simplify your code, you can assume that all strings for this project (but not later projects) will be just one word.
Each of the methods (which includes your constructors) in your FrozenYogurt c lass will be tested using unit tests in codePost. Additionally, the output of your entire program will be tested with various inputs.
codePost does not support the package statement. If your IDE inserted one, I configured codePost to automatically remove it.
Examples
Note, user input is in bold face blue and the text that is underlined is required for the test cases.
Example A
Welcome to the Frozen Yogurt Selector
Please enter the name of the first frozen yogurt: Chocolatey
You entered: Chocolatey
Please enter the name of the second frozen yogurt: SassyStrawberry
Not Secure -
csc.columbusstate.edu
image text in transcribed

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

Students also viewed these Databases questions

Question

Describe the metadata associated with the physical ERD.

Answered: 1 week ago