#include
using std::cout;
using std::endl;
using std::ostream;
#include
using std::string;
class Invoice {
public:
Invoice(int i, const string &d, int c, double p)
: id(i), description(d),
count(c), price(p)
{}
int get_id() const { return id; }
void set_id(int i) { id = i; }
string get_description() const { return description; }
void set_description(const string &d) { description = d; }
int get_count() const { return count; }
void set_count(int c) { count = c >0 ? c : 0; }
double get_price() const { return price; }
void set_price(double p) { price = p > 0.0 ? p : 0.0; }
double getInvoiceAmount() const { return price * count; }
private:
int id;
string description;
int count;
double price;
};
ostream & operator<< (ostream &out, const Invoice &invoice) {
out << "ID: " << invoice.get_id() << "\t"
<< "Description: " << invoice.get_description() << "\t"
<< "Count: " << invoice.get_count() << "\t"
<< "Price: " << invoice.get_price() << "\t"
<< "Amount: " << invoice.getInvoiceAmount();
return out;
}
int main() {
Invoice invoice(1, "abc", 2, 3.4);
cout << invoice << endl;
invoice.set_id(5);
invoice.set_description("def");
invoice.set_count(6);
invoice.set_price(7.8);
cout << invoice << endl;
return 0;
}