Assume we have Dessert.java whcih private String flavor has private double sweetness in it. Store.java This will be the class that stores the data for the dessert store. We are assuming that a store can sell all kinds of dessert. Variables: String name – name of the store. ArrayList desserts – an ArrayList of type Dessert Constructor(s): • A constructor that only takes in name and creates an empty ArrayList of type Dessert. Methods: • addDessert o This method should take in a valid Dessert object and add it to the back of the ArrayList. o This method should not return anything. o This method should run in O(1) time. • removeDessert o This method should take in a valid Dessert object and remove the first instance of it from the ArrayList. o Return the object that is being removed or null if the dessert is not found. o Use equals when identifying if the object in the ArrayList is the same as the passed in Dessert object. o This method should run in O(n) time. • findDessert o This method should take in a valid Dessert object and find/return the dessert that has the same sweetness and flavor. o If a dessert with the same sweetness and flavor is not found in the Store, return null. o This method should run in O(log n) time. o Assume the ArrayList has unique dessert items and is sorted in ascending order based on sweetness and flavor. • sortStore o This method should sort the ArrayList in ascending order based on sweetness and flavor. o This method should run in O(n2) time worst and best case. • checkStore o This method should take in a valid Dessert object and return the number of desserts in the store that is greater or equal to the Dessert passed in. o This method should run in O(n) time. • If necessary, add getters and setters for the variables in the class.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Assume we have Dessert.java whcih  private String flavor has private double sweetness in it.

 

Store.java

This will be the class that stores the data for the dessert store. We are assuming that a store can sell all kinds of dessert.

Variables:

  • String name – name of the store.

  • ArrayList desserts – an ArrayList of type Dessert

    Constructor(s):

• A constructor that only takes in name and creates an empty ArrayList of type Dessert. Methods:

• addDessert
o This method should take in a valid Dessert object and add it to the back of the ArrayList. o This method should not return anything.
o This method should run in O(1) time.

• removeDessert
o This method should take in a valid Dessert object and remove the first instance of it from the ArrayList.

o Return the object that is being removed or null if the dessert is not found.

o Use equals when identifying if the object in the ArrayList is the same as the passed in Dessert object.

o This method should run in O(n) time.

• findDessert

o This method should take in a valid Dessert object and find/return the dessert that has the same sweetness and flavor.

o If a dessert with the same sweetness and flavor is not found in the Store, return null. o This method should run in O(log n) time.
o Assume the ArrayList has unique dessert items and is sorted in ascending order based

on sweetness and flavor.

• sortStore
o This method should sort the ArrayList in ascending order based on sweetness and

flavor.
o This method should run in O(n2) time worst and best case.

• checkStore
o This method should take in a valid Dessert object and return the number of desserts in

the store that is greater or equal to the Dessert passed in. o This method should run in O(n) time.

• If necessary, add getters and setters for the variables in the class.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY