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, 21.06.2019 19:50
Python write an expression that executes the loop body as long as the user enters a non-negative number. note: if the submitted code has an infinite loop, the system will stop running the code after a few seconds and report "program end never reached." the system doesn't print the test case that caused the reported message. sample outputs with inputs: 9 5 2 -1
Answers: 3
question
Computers and Technology, 23.06.2019 09:10
Effective character encoding requires standardized code. compatible browsers. common languages. identical operating systems.
Answers: 1
question
Computers and Technology, 23.06.2019 19:30
Anul 2017 tocmai s-a încheiat, suntem trişti deoarece era număr prim, însă avem şi o veste bună, anul 2018 este produs de două numere prime, 2 şi 1009. dorel, un adevărat colecţionar de numere prime, şi-a pus întrebarea: “câte numere dintr-un interval [a,b] se pot scrie ca produs de două numere prime? “.
Answers: 1
question
Computers and Technology, 23.06.2019 23:30
A. in packet tracer, only the server-pt device can act as a server. desktop or laptop pcs cannot act as a server. based on your studies so far, explain the client-server model.
Answers: 2
You know the right answer?
Inheritance/Overriding in Java This is from the parent Coffee class, and this code was provided to...
Questions
question
Mathematics, 07.04.2020 04:17
question
Mathematics, 07.04.2020 04:18
question
English, 07.04.2020 04:18
question
Mathematics, 07.04.2020 04:18
Questions on the website: 13722363