The Drink.java class is the super class. It has set and get methods for the attributes name, brand, calories. The Soda and FruitJuice classes inherit the Drink class. The soda class has attributes caffeine percentage. The FruitJuice has attributes vitaminPercentage and fruit. Add a printInfo method in the Drink class and then override that method in the subclasses.
The DrinkList.java will contain your main method, which is where you will declare your array of Drink items, and control execution. In addition, the DrinkList class has 2 methods:
1) printDrinkWithLowestCalories (Drink[] drink) searches the array for the drink with Lowest calories and prints it's name and brand.
2) printAll(Drink[] drink prints the information of all (this includes Soda and FruitJuice information) drinks stored in the array.
here is the sample output:
Please enter the number of drinks to be read: 2
Data For Drink 1:
Type of Drink (Soda/Fruit)? Soda
Enter Soda's name: Sierra Mist
Enter Sierra Mist's brand: Pepsi Co
Enter calories for Sierra Mist: 150
Enter percentage caffeine for Sierra Mist : 0
Data For Drink 2:
Type of Drink (Soda/Fruit)? Fruit
Enter Name: Orange juice
Enter the brand name of Orange Juice: Tropicana
Enter calories of Tropicana: 240
Enter Tropicana's fruit: Orange
Enter Tropicana's percentage vitamin (Daily value): 100
Enter choice ("Low Calorie" or "PrintAll" or "exit" ): Low Calorie
Sierra Mist
Enter choice ("Low Calorie" or "Brand" or "exit" ): exit
Thank you for using the program.
HINT: declare printAll(Drink[] drink) as static method in DrinkList class like this:
public static void/String printAll(Drink[] drink)
NOTE: submit your program before 4:00pm to espiggy@gmail.com. NO late submittion accepted!!
No comments:
Post a Comment