Question: Java Write a method testCoffeeDrinks that takes one parameter: - drinks, an non-empty array of CoffeeDrink objects The method finds and prints to the screen
Java
Write a method testCoffeeDrinks that takes one parameter:
- drinks, an non-empty array of CoffeeDrink objects
The method finds and prints to the screen the strongest drink (You must use the compareTo method for full credit). If more than one such drink occur in the array, pick the first one. The method also creates, populates and returns an array of integers containing the frequency of each possible coffee strength (1-5), in the drinks array. For example, if the information of the drinks in the array is given in the table below:
Coffee Drink Number Ingredient1 Ingredient2 0 coffee, 4 milk, 3 1 coffee, 2 milk, 3 2 coffee, 2 milk, 1 3 coffee, 4 milk, 1 4 coffee, 3 milk, 2 5 coffee, 4 milk, 4
The program will display: coffee strength:4 milk strength: 1
And return the array {0,2,1,3,0}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
