Question: Create a class called Dessert ( you ll need to create a new file and add it to Git ) inside of the src /

Create a class called Dessert (youll need to create a new file and add it to Git) inside of the src/ folder. This class should have the following characteristics:
Two instance variables: int flavor and int price.
A constructor that takes two parameters int flavor and int price and sets the instance variables accordingly.
One static variable int numDesserts that keeps track of the number of desserts created so far.
A method public void printDessert() that prints the flavor and price of the dessert, along with the total number of desserts created so far, separated by a space.
For example, if we create a dessert with flavor 1 and price 2, and then call its printDessert() method, it should print 121.
If we then create a dessert with flavor 3 and price 4, and then call its printDessert() method, it should print 342.
Lastly, a method public static void main(String[] args) that only prints the line I love dessert! when executed.
Be sure to implement the above behavior exactly, otherwise you may not pass the tests!
When you have completed Dessert.java, uncomment the appropriate lines in tests/DessertTest and run the test.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!