Write an Abstract Class With a Concrete Label Method
mediumQuestion 547Write the abstract class Beverage from scratch. It knows the name of a drink, but only a subclass knows the price, so price() is abstract. label() is a finished method that still calls price(): whichever subclass the object really is supplies the number.
Requirements:
1. A private String field name, set by a public constructor Beverage(String name).
2. getName() returns the name.
3. price() is a public abstract method that takes no parameters and returns a double.
4. label() returns the name, a colon, a space, a dollar sign and the price with exactly two decimals, for example Mocha: $4.10. String.format("%.2f", ...) gives two decimals.
5. The tests bring their own subclasses, Latte and Tea. Each calls your constructor with super(...) and overrides price().
Do NOT write a main method.
Expected output
Latte Latte: $5.00
= newline. The output ends with a newline, so print one after the last line.
Your output
Run your code to see the output here...