I have a class that is abstract, which also has 4 child classes, I would like to know how could I create a object array so when the program runs, it will ask the user if they want to place another order and store the first order in the object array and so on till the user does not want to place anymore orders.
double TP = b1.getTotal() + s1.getTotal() + d1.getTotal() + dr.getTotal();
System.out.print("Would you like to place another order?");
user = scan.nextInt();
scan.nextLine();
}
}while(user == 1);
//here is where I would like to create the object array and store these variables in them,
b1.display();
s1.display();
d1.display();
dr.display();
here is the abstract class
import java.util.*;
public abstract class Order
{
protected String meal;
protected double price, total;
protected int amount;
public Order()
{
setItem(meal);
}
public String getItem()
{
return meal;
}
public void setItem(String i)
{
meal = i;
}
public double getPrice()
{
return price;
}
public void setPrice(double p)
{
price = p;
}
public int getAmt()
{
return amount;
}
public void setAmt(int a)
{
amount = a;
}
public double getTotal()
{
return total;
}
public abstract void display();
public abstract void setTotal(double p, int a);
}
abstractclass?