/*
* Copyright ©2026 Soham Pardeshi. All rights reserved.
* Permission is hereby granted to students registered for University of
* Washington CSE 333 for use solely during Summer Quarter 2026 for
* purposes of the course. No other use, copying, distribution, or
* modification is permitted without prior written consent. Copyrights
* for third-party components of this work must be honored. Instructors
* interested in reusing these course materials should contact the author.
*/
#ifndef DIVIDENDSTOCK_H_
#define DIVIDENDSTOCK_H_
#include <string>
#include "Stock.h"
namespace cse333 {
// A stock that also pays cash dividends. DividendStock is-a Stock.
class DividendStock : public Stock {
public:
DividendStock(const std::string& symbol, int total_shares,
double total_cost, double current_price)
: Stock(symbol, total_shares, total_cost, current_price),
dividends_(0.0) {}
// Redefine behavior while keeping the same interface (slide 21).
// Google style: mark it `override`, not `virtual`, in the derived class.
double GetMarketValue() const override;
// New behavior the base class does not have.
void PayDividend(double amount) { dividends_ += amount; }
double dividends() const { return dividends_; }
private:
double dividends_; // new state added by the derived class
};
} // namespace cse333
#endif // DIVIDENDSTOCK_H_