#include #include #include #include "item.h" using namespace std; item::item(const string & item_name, double item_price) { name = item_name; price = item_price; } const string & item::get_name() const { return name; } double item::get_price() const { return price; } string item::to_string() const { ostringstream out; out << name << " ($" << price << ")"; return out.str(); } void item::discount(double percent) { price *= (1 - percent / 100.0); price = round(price * 100) / 100.0; } ostream & operator<<(ostream & out, const item & i) { out << i.to_string(); return out; } bool operator<(const item & lhs, const item & rhs) { return lhs.get_price() < rhs.get_price(); }