#include "item.h" #include #include #include using namespace std; item::item(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(); } ostream & operator<<(ostream & out, item i) { out << i.to_string(); return out; } void item::discount(double percent) { price *= (1 - percent / 100.0); price = round(price * 100) / 100.0; } bool operator<(const item & lhs, const item & rhs) { return lhs.get_price() < rhs.get_price(); }