#include <iostream>

class Fruit{
public:
  virtual   float   totalCostPrice() const = 0;
  virtual   float totalSellPrice() const = 0;
  virtual float netProfit() const = 0;
};

class Fruit_PI : virtual public Fruit {
protected:
  int m_inventory;
public:
  Fruit_PI( int num) : m_inventory(num) {}

  virtual float netProfit() const { return totalSellPrice() - totalCostPrice(); }
};

class Apple : virtual public Fruit, private Fruit_PI {
private:
  float m_unitCostPrice;
  float m_unitSellPrice;
public:
  Apple(int num, float unitCostPrice, float unitSellPrice) : 
    Fruit_PI(num),
    m_unitCostPrice(unitCostPrice),
    m_unitSellPrice(unitSellPrice) {}

  virtual float totalCostPrice() const { return m_inventory * m_unitCostPrice; }

  virtual float totalSellPrice() const { return m_inventory * m_unitSellPrice;}
};

class Orange : virtual public Fruit, private Fruit_PI {
private:
  float m_unitCostPrice;
  float m_unitSellPrice;
public:
  Orange(int num, float unitCostPrice, float unitSellPrice) : 
    Fruit_PI(num),
    m_unitCostPrice(unitCostPrice),
    m_unitSellPrice(unitSellPrice) {}

  virtual float totalCostPrice() const { return m_inventory * m_unitCostPrice; }

  virtual float totalSellPrice() const { return m_inventory * m_unitSellPrice;}
};

void print_net_profit(const Fruit & fruit)
{
  std::cout << "Net profit at current prices = $ " << fruit.netProfit() << std::endl;
}

int main()
{
  Apple apple(100, 4.00, 4.25);
  Orange orange(50, 7.00, 7.25);
 
  print_net_profit(apple);
  print_net_profit(orange);
}
