Код: Выделить всё
class Burger extends Food { private int numberofPatty; public Burger(){ } public Burger(String name, String[] ingredients, double price,float calories, int numberofPatty){ super(name,ingredients,price,calories); this.numberofPatty= numberofPatty; } public void setNP(int numberofPatty){ this.numberofPatty= numberofPatty; } public int getNP(){ return numberofPatty; } public void showdetails(){ System.out.println("Name="+getName()); System.out.println("In="+ getIn()); System.out.println("Price="+getPrice()); System.out.println("Calories="+getCalories()); System.out.println("NP="+numberofPatty); }
'
Код: Выделить всё
public class Main { public static void main(String[] args) { String[] burgerIngredients = new String[2]; burgerIngredients[0]= new String("alu"); burgerIngredients[1]= new String("Potato"); Burger burger1 = new Burger("Classic Burger", burgerIngredients, 5.99, 550, 1); burger1.showdetails(); } }
i tried array concept. what should i do to get the output with ingredients name?
Источник: https://stackoverflow.com/questions/781 ... ngredients