Question: To start, let's create a class to represent items in a Bakery. Item Class Write a class named Item to represent an item in a
To start, let's create a class to represent items in a Bakery.
Item Class
Write a class named Item to represent an item in a bakery. Our bakery is very simple, so all we need to keep track of
at this time, is the flavor of the item and its price. To that end, include the following attributes:
flavor
price
Include a getter and setter for the price attribute and only a getter for the flavor you can't really change the
flavor of something that's been baked already
Include a constructor with parameters to assign values to both the price and flavor attributes.
You can create a driver if you'd like to test your Item class, but it is not required at this time.
Include documentation comments for the class itself, the constructor, and the getters and setter.
Testing
For ease of use, there are automatic tests that will run when you upload your file. To ensure they run properly, please
do the following:
name the class Item and only Item, nothing else
put the attributes in the constructor in the order that they're listed above flavor followed by price
make sure that your getters and setters adhere to this exact naming policy setAttributeName or
getAttributeName, so for example, the getter for flavor will be named getFlavor
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
