Concept explainers
You are contributing to a system that will help an ice cream shop to keep track of their product line and calculate the price of customer orders.
In a Python file called icecream.py, write a class called IceCream that matches the following docstring:
Part A:
'''
Class -- IceCream
Represents a type of ice cream.
Attributes:
flavor -- The name of the flavor, a string e.g. "chocolate" or "cookies and cream"
price_per_scoop -- The price per scoop, a float.
Method:
...See part B...
'''
Part B
Add a method called get_cost to the IceCream class that will be used to calculate the cost of a customer's order. The method should take a float parameter, the number of scoops the customer wants, and return the total cost for that amount of ice cream. Here are the rules for calculating the ice cream cost:
- The cost of the ice cream is the number of scoops multiplied by the price per scoop.
- For less than 2 scoops, the cost is calculated as the price per scoop multiplied by 2. This means that an order for less than 2 scoops of ice cream costs the same as 2 scoops.
- For large orders, defined as more than 10 scoops, the company takes $2 off the cost.
Write a test file to test the class you wrote for icecream.py . Be sure to test the constructor as well as the method you wrote in part B.
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images
- !! E! 4 2 You are in process of writing a class definition for the class Book. It has three data attributes: book title, book author, and book publisher. The data attributes should be private. In Python, write an initializer method that will be part of your class definition. The attributes will be initialized with parameters that are passed to the method from the main program. Note: You do not need to write the entire class definition, only the initializer method lili lilıarrow_forwardPlease help me with the question using Java. Please use compliment to explain each line of code.arrow_forwardCreate a C# program named ConferencesDemo for a hotel that hosts business conferences. Allows a user to enter data about five Conference objects and then displays them in order of attendance from smallest to largest. The Conference class contains fields for the following: group - The group name (as a string) date - The starting date (as a string) attendees - The number of attendees (as an int) Include properties for each field. Also, include an IComparable.CompareTo() method so that Conference objects can be sorted in order from least to greatest attendees. Your output for each conference should match the following: NAME Conference starts on DATE and has ATTENDEES attendeesarrow_forward
- Project: Two Formulas in Separate Class Write two formulas your choice in separate file and you call it in some manner from your from main program. In Java the pic for examplearrow_forwardjava a. You want to create a Java main class. You create the source code file, declare the package, and write the class header. Now you must create the main method that starts the program. Write the entire method header, including the opening brace for the method. b. Assume that price is an integer variable whose value is the price (in US currency) in cents of an item. Write a statement that calculates the whole dollars in the amount and saves it in a new integer variable named dollars. Note: The Java style guide states that one space is used on either side of binary operators.arrow_forwardThis is for C++ only, and I will be using visual studio as a compiler. You can use dummy variables that I will change later Write a class named Student that has member variables for the following data: First name, middle name, last name Address, city, state, and ZIP code Email address Student ID# Major The Student class should have a constructor that accepts an argument for each member variable and include accessors and mutators for each member variable. Next, write a class named Course that represents a course the student will take. The Course class should have member variables for the following data: Course ID number Name of the course Name of the instructor Grade earned Number of units The Course class should have a constructor that accepts an argument for each member variable. The Course class should also have accessor and mutator functions for each member variable. write a program that creates an instance of the Student class, initialized with sample data.…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education