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

  • SEARCH
  • Home
  • 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 7746431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T10:16:36+00:00 2026-06-01T10:16:36+00:00

What is the correct model for a retail store? e.g. Company sells Products from

  • 0

What is the correct model for a retail store? e.g. Company sells Products from Stores.

A company can have many stores and sell many products. The products aren’t necessarily tied to each store, or so I would’ve thought.

I have a basic assignment, which asks that I design a system that calculates the economic order quantity of a product. We are supposed to implement a structure that will be suitable for a later assignment (for which we have no details..), and the advised structure is as follows:

public class Company {
    private Store store;

    public static void main(String[] args)
    {
        Store storeOne = new Store();

        storeOne.setEOQRelevantValues(1, etc..);
    }
}

public class Store {
    private Product product;

    //..

    public setEOQRelevantValues(int eoqRelevantValues)
    {
        Product.setEOQRelevantValues(eoqRelevantValues);
    }
}

public class Product{
    private int eoqRelevantValues;

    //..

    public setEOQRelevantValues(int eoqRelevantValues)
    {
        this.eoqRelevantValues = eoqRelevantValues;
    }

    public int calculateEOQ()
    {
        //do stuff with this.eoqRelevantValues..
        return EOQ;
    }
}

This seems to violate all of the little I know about OOP. Methods that pass data down through the hierarchy – duplicating parameters between objects? What am I missing?

  • 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-01T10:16:37+00:00Added an answer on June 1, 2026 at 10:16 am

    You’re correct to be concerned in that it would be unusual to initialise a hierarchy of objects by passing in all the parameters from the top down.

    Your lecturer may be hinting that you implement something along the lines of the Composite pattern, whereby each class in the hierarchy shares a common method (e.g. getValue()). In the case of a Product (i.e. leaf node) this would simply return the product’s value, whereas in the case of a Store or Company it would iterate over the constituent Products (or Stores), calling getValue() and summing the result.

    The key difference between this and what you’ve written above is that you would typically initialise each Product individually via its constructor, rather than by passing in the data from another object. If the product is immutable you might choose to mark its fields as final. You might then choose to add utility methods to other classes in the hierarchy (e.g. moveProduct(Store store1, Store store1)); In other words the other classes would then exhibit behaviour rather than just being “data containers”.

    Example

    /**
     * Optional interface for uniting anything that can be valued.
     */
    public interface Valuable {
      double getValue();
    }
    
    /**
     * Company definition.  A company's value is assessed by summing
     * the value of each of its constituent Stores.
     */
    public class Company implements Valuable {
      private final Set<Store> stores = new HashSet<Store>();
    
      public void addStore(Store store) {
        this.stores.add(store);
      }
    
      public void removeStore(Store store) {
        this.stores.remove(store);
      }
    
      public double getValue() {
        double ret = 0.0;
    
        for (Store store : stores) {
          ret += store.getValue();
        }
    
        return ret;
      }
    }
    
    /**
     * Store definition.  A store's value is the sum of the Products contained within it.
     */
    public class Store implements Valuable {
      private final List<Product> products = new LinkedList<Product>();
    
      public void addProduct(Product product) {
        this.products.add(product);
      }
    
      public void removeProduct(Product product) {
        this.products.remove(product);
      }
    
      public double getValue() {
        double ret = 0.0;
    
        for (Product product : products) {
          ret += product.getValue();
        }
    
        return ret;
      }
    }
    
    /**
     * Product definition.  A product has a fixed inherent value.  However, you could
     * always model a product to depreciate in value over time based on a shelf-life, etc.
     * In this case you might wish to change the Valuable interface to accept a parameter;
     * e.g. depreciationStrategy.
     */
    public class Product implements Valuable {
      private final double value;
    
      public Product(double value) {
        this.value = value;
      }
    
      public double getValue() {
        return value;
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have html code in database. my model gets assign with correct data from
A client of mine has a dynamic changing business model, they sell products according
I've stuck with one quite tricky problem. I have list of products from different
What is a correct way to update model when view changed. Is it need
When posting back to my controller my model is populated with correct values and
I was wondering what the correct-way is when using a Linq to Sql-model in
Correct me If I am doing wrong, I have just started to check WCF
I have an edit view that is displaying some model properties as plain text
I have a set of models Day1, ... ,Day7 . How can I use
I changed my core data model to a to-many relationship. I believe this is

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.