subject

Inheritance/Overriding in Java This is from the parent Coffee class, and this code was provided to me:

public int getPrice()
{
int price;
if (size. equals("extra large"))
price = 470;
else if (size. equals("large"))
price = 440;
else if (size. equals("medium"))
price = 360;
else
price = 330;
price += shots*30;
return price;
}
}

I have to override this in the child class, Speciality Coffee. It should return the price given by Coffee, plus an extra charge. 70 cents for size large or extra large, and 50 cents otherwise. This is my attempt, but no matter what edits I make to it it still gives me an error. How can I fix this, and if I’m totally off base what should it be instead?

public Float getPrice(){
this. price = this. getPrice();
if(this. size == “large” || this. size == “extra large”){
this. price = this. price + .7;
}
else{
this. price + .5;
}
return this. price;
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 09:40
Sarah is having a hard time finding a template for her advertising business that she may be able to use at a later date and also make it available to her colleagues
Answers: 1
question
Computers and Technology, 22.06.2019 13:00
Write a program which asks you to enter a name in the form of first middle initial last. so you might enter for example samuel p. clemens. use getline to read in the string because it contains spaces. also, apparently the shift key on your keyboard doesn’t work, because you enter it all lower case. pass the string to a function which uses .find to locate the letters which need to be upper case and use toupper to convert those characters to uppercase. the revised string should then be returned to main in the form last, first mi where it will be displayed.
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
What side length would you specify if you were required to create a regular hexagonal plate that was composed of 33 cm(squared) of sheet metal? dimension the side length to 0.1 cm
Answers: 2
question
Computers and Technology, 23.06.2019 16:30
If i wanted to include a built-in calendar in a document, what option could i select? draw table insert table insert chart quick tables
Answers: 1
You know the right answer?
Inheritance/Overriding in Java This is from the parent Coffee class, and this code was provided to...
Questions