Graderpractice for programmers

Back to 254275 OOP Lab 5-10

Q4. Add isSameNameMenu() method

Problem

Reuse your Starsbuck class from question 3. Add a method named isSameName that takes another Drink and returns true if they have the same name.

private static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
         StarbucksShop d1 = input();
         StarbucksShop d2 = input();

         if (d1.isSameName(d2)) {
             System.out.println("Drink 1 and Drink 2 is the same menu");
         }
         else {
             System.out.println("Not the same menu");
         }
     }

     private static StarbucksShop input() {
         String menu = sc.nextLine();
         String size = sc.nextLine();
         char container = sc.nextLine().charAt(0);
         return new StarbucksShop(menu, size, container);
     }

Examples

Input

Late
venti
s
Late
tall
n

Output

Drink 1 and Drink 2 is the same menu

Input

Smoked Butterscotch Frappuccino
tall
n
Manuka Honey Ginger Black Tea
venti
s

Output

Not the same menu

Submit your solution

java