In this exercise you will return to your SpecialityCoffee class which you created for the last...

50.1K

Verified Solution

Question

Physics

In this exercise you will return to your SpecialityCoffee classwhich you created for the last coding activity (a sample solutionto this exercise will be shown below the entire question if you donot have yours). This time you will override the Coffee methodgetPrice which returns the price in cents for a given coffee.

The SpecialityCoffee method getPrice should return the pricegiven by the Coffee method for that object, plus an extra chargefor the flavored syrup. This extra charge is 70 cents if the coffeesize is \"large\" or \"extra large\", and 50 cents otherwise.

Remember, to submit a solution you should paste your entireSpecialityCoffee class into the coderunner, which uses its ownversion of the Coffee class.

sample code from the last coding activitypublic class SpecialityCoffee extends Coffee{  // Additional member variable private String flavor;  public SpecialityCoffee(){  // Calls super-constructor to create default coffee then sets flavor  super();  flavor = \"vanilla\"; }  public SpecialityCoffee(String size, String type, String flavor){    // Calls constructor below with a mix of parameters and default values  this(size, false, 1, type, flavor); }  public SpecialityCoffee(String size, boolean isSkinny, int shots, String type, String flavor){    // Calls super-constructor tos set first 4 variables then sets flavor  super(size, isSkinny, shots, type);  this.flavor = flavor; }  public String toString(){  // Calls Coffee toString and appends flavor to end  return super.toString() + \" with \" + flavor; }}

Answer & Explanation Solved by verified expert
4.5 Ratings (799 Votes)
public class SpecialityCoffee extends Coffee Additional member variable private String flavor public SpecialityCoffee Calls superconstructor to create default coffee then sets flavor super    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