#Create a class called FrapOrder. FrapOrder should #have two attributes (instance variables): size and #extra_shots. Make sure...

50.1K

Verified Solution

Question

Programming

#Create a class called FrapOrder. FrapOrder should
#have two attributes (instance variables): size and
#extra_shots. Make sure the variable names match those
#words. size will be a character, either \"S\", \"M\", or \"L\".
#extra_shots will be an integer.
#
#FrapOrder should have a constructor with two required
#parameters, one for each of those attributes (size and
#extra_shots, in that order).
#
#FrapOrder should also have a method called get_total.
#get_total should calculate the total cost of the order.
#If size is \"S\", the base cost is 2.50. If the size is \"M\",
#the base cost is 3.50. If the size is \"L\", the base cost is
#4.50. Then, each extra shot costs $0.35.
#
#For example, if size is \"M\" and extra_shots is 2, then
#get_total would return 4.2: 3.50 + 0.70 = 4.20 (and Python
#drops trailing 0s).
#
#total should NOT be an attribute of the class; instead,
#total should be calculated and returned live when the method
#get_total is called.
#
#The get_total method should have NO parameters besides self.
#Instead, it should calculate the total based on the current
#values for the size and extra_shots attributes.


#Write your class here!

#The code below will test your function. If it works, it
#should print \"M\" (without the quotes), 2, and 4.2 in that
#order.
test_order = FrapOrder(\"M\", 2)
print(test_order.size)
print(test_order.extra_shots)
print(test_order.get_total())

Answer & Explanation Solved by verified expert
3.8 Ratings (628 Votes)
Create a class called FrapOrder FrapOrder should have two attributes instance variables size and extrashots Make sure the variable names match those words size will be a character either S M or L extrashots will be an integer FrapOrder should have a constructor with two required    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students