Question: write in java Questions: 1. A coffee shop called DrCoffeeCup needs your support by writing a Java program that helps DrCoffeeCup to sell its coffee

write in java

write in java Questions: 1. A coffee shop called "DrCoffeeCup" needs your

support by writing a Java program that helps DrCoffeeCup to sell its

coffee according to the following requirements: a. DrCoffeeCup sells different types of

Questions: 1. A coffee shop called "DrCoffeeCup" needs your support by writing a Java program that helps DrCoffeeCup to sell its coffee according to the following requirements: a. DrCoffeeCup sells different types of coffee as the following: b. DrCoffeeCup has three sizes of cups: small, medium, and large. - The medium size increases the cup price by 0.3. - The large size increases the cup price by 0.5. Use OOP concepts to write a program that helps DrCoffeeCup to sell the above items. You need to start with a super class called SuperCoffeeClass. The SuperCoffeeClass should have: - setSize (...) which changes the cups size. - getPrice() which return the price of the cup based on its size. - other appropriate fields and methods that you need. For example (the parameters are hidden for the constructor and the method setPrice): public class CoffeeTestClass \{ public static void main(String[] args) \{ EspressoCup espressoCupVariable = new EspressoCup( espressoCupVariable.setSize ( espressoCupVariable.getPrice(); ); \} 2. Write a method that counts the number of instances that are created. For example: public class CoffeetestClass \{ public static void main(String[] args) \{ EspressoCup espressoCupVariable = new EspressoCupl CappuccinoCup cappuccinoCupVariable_ 1= new CappuccinoCup( CappuccinoCup cappuccinoCupVariable_2 2 new CappuccinoCupl )i int espressoCupVariableByespressoCupVariable = espressoCupVariable. getCountCup(); int espressoCupVariableCappuccinoCupVariable_ 1= cappuccinoCupVariable 1. getCountCup(): int espressoCupVariableCappuccinoCupVariable_ 2= cappuccinoCupVariable 2.getCountCup(); System.out.printin("Total number of cups: "+espressoCupVariableByespressoCupVariable); System.out. printin("Total number of cups: "+espressoCupVariableByespressoCupVariable); System.out.printin("Total number of cups: "+espressoCupVariableByespressoCupVariable); 3 3 The method is found in all coffee classes, and it increases the total when a coffee cu is defined. The above code will result in the following: Total number of cups: 3 Total number of cups: 3 Total number of cups: 3 3. Improve the SuperCoffeeClass to allow customer to buy other items: All SuperCoffeeClass's items including coffee cups have getPrice(). For example, Majeed has ordered three items and the total price is 24 Riyals: public static void main(String[] args) \{ item1; item 2; item3; //The order of Majeed: item1 = new EspressoCup ( ) ); item2 = new CheeseCake( item3 = new Croissant( double total = item 1.getPrice()+item3.getPrice()+item3.getPrice(); System.out.println("The order of Majed is "+total +" R.S."); The green box refers to the same type for all the three items. So, its not possible to define the type of iteml as EspressoCup and the type of item 2 as CheeseCake. The above code will result in the following: The order of Majed is 24.0 R.S. Bonus: Improve your code by implementing a discount method that has the following: a. The default discount is 0 . b. When customer buys three cups of coffee, the discount is 5 R.S. c. The discount will be applied to any multiple of 3 such as

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!