Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8918121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:40:26+00:00 2026-06-15T05:40:26+00:00

I have a class that is abstract, which also has 4 child classes, I

  • 0

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);

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T05:40:27+00:00Added an answer on June 15, 2026 at 5:40 am

    I assume your abstract class is Order. Something like

    abstract class Order {
       public abstract void getSomething();
       public abstract void setSomething();
    }
    
    class Burger extends Order {
      // implement getSomething() and setSomething()
    }
    
    ...
    List<Order> orders = new ArrayList<Order>();
    ...
    Burger b = new Burger();
    b.setSomething(0);
    orders.add(b);
    ...
    for (Order o : orders) {
       o.getSomething();
    }
    

    is likely what you’re looking for.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an abstract base class that holds a Dictionary. I'd like inherited classes
I have an abstract immutable base class that defines enforces child classes to be
I have an abstract class that implements IDisposable, like so: public abstract class ConnectionAccessor
I have an abstract class that has a virtual method. The method is virtual
I have a abstract base class that I have many inherited classes coming off
I have a abstract base C# class with a couple of methods that has
For example, I have a class that has two strings, one of which must
So i have the abstract class Worker , which has the abstract function computePay
I have a abstract class which represents an immutable value. Like strings, the immutable
I have an interface HTTPSequence . I also have an abstract class AbstractHTTPFactory which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.