/* CSE 333 Su12 lecture 14 demo: stocks_virtual/DividendStock.cc */
/* Gribble/Perkins */

// Implementation of class DividendStock

#include <iostream>
#include <iomanip>

#include "./DividendStock.h"

using namespace std;

// Construct a new dividend stock with the given symbol and initial price
// per share and no shares initially held.
DividendStock::DividendStock(string symbol, double share_price)
  : Stock(symbol, share_price) {
  dividends_ = 0.0;
}

// Return the profit earned on this stock, which is the change in
// market value plus any earned dividends
double DividendStock::GetProfit() const {
  return Stock::GetProfit() + GetDividends();
}

// Return the total amount of dividends paid on this stock.
double DividendStock::GetDividends() const {
  return dividends_;
}

// Record a dividend of the given amount per share.
void DividendStock::PayDividend(double amount_per_share) {
  dividends_ += amount_per_share * get_shares();
}

// Print out the Dividendstock information to cout.
void DividendStock::Print() const {
  cout << "DividendStock (" << get_symbol() << "):" << endl;
  cout << "    value: $" << setw(7) << GetMarketValue() << endl;
  cout << "     cost: $" << setw(7) << GetCost() << endl;
  cout << "dividends: $" << setw(7) << GetDividends() << endl;
  cout << "   profit: $" << setw(7) << GetProfit() << endl;
}