Class Market

java.lang.Object
org.episteme.social.economics.Market
All Implemented Interfaces:
Named

public class Market extends Object implements Named
Represents a market where goods are traded.
Since:
1.0
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Constructor Details

  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in interface Named
    • getCurrency

      public Currency getCurrency()
    • setPrice

      public void setPrice(String good, Money price)
      Sets the price for a specific good.
    • getPrice

      public Money getPrice(String good)
      Gets the price of a good.
    • addStock

      public void addStock(String good, int quantity)
      Adds stock to the market.
    • getStock

      public int getStock(String good)
      Checks stock level.
    • buy

      public Money buy(String good, int quantity)
      Buys a good from the market. Decreases inventory.
      Parameters:
      good - to buy
      quantity - amount to buy
      Returns:
      Total cost
      Throws:
      IllegalStateException - if insufficient stock
    • sell

      public Money sell(String good, int quantity)
      Sells a good to the market. Increases inventory.
      Parameters:
      good - to sell
      quantity - amount to sell
      Returns:
      Total earnings