Smoothie constructor should accept a list of ingredients. • Should not be empty => throw ArgumentException error o Ingredients should not be repeated => throw ArgumentException error o Ingredients that doesn't exist (ingredients are CASE SENSITIVE) => throw ArgumentException error • Ingredients should not be null => throw Argument NullException error Implement Ingredients Property o Will return a list of all supplied ingredients in the constructor o Ingredients should be in alphabetical order A->Z o Users should NOT be able to set Ingredients explicitly smoothie. Ingredients = new List {"Bananana"}; X Implement Name Property gets the ingredients and puts them in alphabetical order into a nice descriptive sentence. If there are multiple ingredients, add the word "Fusion" to the end but otherwise, add "Smoothie". Remember to change "-berries" to "-berry". See the examples below. o Users should NOT be able to set Name explicitly smoothie.Name = "IllegalName"; X Implement GetCost method which calculates the total cost of the ingredients used to make the smoothie o Round to two decimal places. Implement GetPrice method which returns the number from GetCost plus the number from GetCost multiplied by 1.5. • Round to two decimal places. Ingredient Price Strawberries Banana $1.50 $0.50 Mango Blueberries $1.00 $2.50 Raspberries Apple Pineapple $3.50 $1.00 $1.75

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter4: More Object Concepts
Section: Chapter Questions
Problem 2RQ
icon
Related questions
Question

C# Programming
Please see the attached photo for the instructions
Complete this code:

namespace Smoothies
{
    public class Smoothie
    {
        // DO NOT MODIFY THIS FIELD
        private readonly Dictionary<string, string> _prices = new()
        {
            { "Strawberries", "$1.50" },
            { "Banana", "$0.50" },
            { "Mango", "$2.50" },
            { "Blueberries", "$1.00" },
            { "Raspberries", "$1.00" },
            { "Apple", "$1.75" },
            { "Pineapple", "$3.50" }
        };

        // TODO: Implement me!
        public Smoothie (IEnumerable<string> ingredients)
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Ingredients used for the smoothie
        /// TODO: Implement me!
        /// </summary>
        public IEnumerable<string> Ingredients 
        {
            get => throw new NotImplementedException();
            set => throw new NotImplementedException(); 
        }

        /// <summary>
        /// Name of the smoothie
        /// TODO: Implement me!
        /// </summary>
        public string Name
        {
            get => throw new NotImplementedException();
            set => throw new NotImplementedException();
        }

        /// <summary>
        /// Method which calculates the total cost of the ingredients used to make the smoothie.
        /// TODO: Implement me!
        /// </summary>
        public string GetCost()
        {
            throw new NotImplementedException();
        }

        /// <summary>
        /// Method which returns the number from <c>GetCost() + (GetCost() x 1.5)</c>. Round to two decimal places.
        /// TODO: Implement me!
        /// </summary>
        public string GetPrice()
        {
            throw new NotImplementedException();
        }
    }
}

• Smoothie constructor should accept a list of ingredients.
• Should not be empty => throw ArgumentException error
• Ingredients should not be repeated => throw ArgumentException error
o Ingredients that doesn't exist (ingredients are CASE SENSITIVE) => throw ArgumentException error
* Ingredients should not be null => throw ArgumentNullException error
• Implement Ingredients Property
o Will return a list of all supplied ingredients in the constructor
* Ingredients should be in alphabetical order A->Z
o Users should NOT be able to set Ingredients explicitly
smoothie. Ingredients = new List<string> {"Bananana"}; X
Implement Name Property gets the ingredients and puts them in alphabetical order into a nice descriptive
sentence.
If there are multiple ingredients, add the word "Fusion" to the end but otherwise, add "Smoothie".
Remember to change "-berries" to "-berry". See the examples below.
o Users should NOT be able to set Name explicitly
smoothie.Name = "IllegalName"; X
• Implement GetCost method which calculates the total cost of the ingredients used to make the smoothie
Round to two decimal places.
• Implement GetPrice method which returns the number from GetCost plus the number from GetCost
multiplied by 1.5.
• Round to two decimal places.
Sample
Single Ingredient
s1 new Smoothie(new List<string> { "Banana" });
s1. Ingredients
s1.Name
"Banana Smoothie"
s1.GetCost()
s1.GetPrice ()
Multiple Ingredients
"Banana" }
s2. Ingredients →
"$0.50"
s2.GetCost ()
s2.GetPrice ()
"$1.25"
52.Name → "Blueberry Raspberry Strawberry Fusion"
"Blueberries", "Raspberries", "Strawberries" }
s2 = new Smoothie (new List<string> { "Raspberries", "Strawberries", "Blueberries" });
"$3.50"
Ingredient Price
"$8.75"
Strawberries
Banana
$1.50
$0.50
Mango
Blueberries $1.00
$2.50
Raspberries
Apple
$1.75
Pineapple $3.50
$1.00
Transcribed Image Text:• Smoothie constructor should accept a list of ingredients. • Should not be empty => throw ArgumentException error • Ingredients should not be repeated => throw ArgumentException error o Ingredients that doesn't exist (ingredients are CASE SENSITIVE) => throw ArgumentException error * Ingredients should not be null => throw ArgumentNullException error • Implement Ingredients Property o Will return a list of all supplied ingredients in the constructor * Ingredients should be in alphabetical order A->Z o Users should NOT be able to set Ingredients explicitly smoothie. Ingredients = new List<string> {"Bananana"}; X Implement Name Property gets the ingredients and puts them in alphabetical order into a nice descriptive sentence. If there are multiple ingredients, add the word "Fusion" to the end but otherwise, add "Smoothie". Remember to change "-berries" to "-berry". See the examples below. o Users should NOT be able to set Name explicitly smoothie.Name = "IllegalName"; X • Implement GetCost method which calculates the total cost of the ingredients used to make the smoothie Round to two decimal places. • Implement GetPrice method which returns the number from GetCost plus the number from GetCost multiplied by 1.5. • Round to two decimal places. Sample Single Ingredient s1 new Smoothie(new List<string> { "Banana" }); s1. Ingredients s1.Name "Banana Smoothie" s1.GetCost() s1.GetPrice () Multiple Ingredients "Banana" } s2. Ingredients → "$0.50" s2.GetCost () s2.GetPrice () "$1.25" 52.Name → "Blueberry Raspberry Strawberry Fusion" "Blueberries", "Raspberries", "Strawberries" } s2 = new Smoothie (new List<string> { "Raspberries", "Strawberries", "Blueberries" }); "$3.50" Ingredient Price "$8.75" Strawberries Banana $1.50 $0.50 Mango Blueberries $1.00 $2.50 Raspberries Apple $1.75 Pineapple $3.50 $1.00
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning