From 4dbe12e59351ad2694d6275509ce83c6734394a9 Mon Sep 17 00:00:00 2001 From: Iurii Tatishchev Date: Sat, 8 Jun 2024 14:37:32 -0700 Subject: [PATCH] 10.10 Lab*: Heap ADT Refactor Customer.h slightly --- 07-heaps/Customer.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/07-heaps/Customer.h b/07-heaps/Customer.h index b186886..a70e117 100644 --- a/07-heaps/Customer.h +++ b/07-heaps/Customer.h @@ -27,14 +27,16 @@ public: Customer() : year(0), mileage(0), seq(0), name("") {}; Customer(int y, int m, int s, string n) : year(y), mileage(m), seq(s), name(std::move(n)) { - priority = mileage / 1000 + year - seq; - serial = priority * 100 + (100 - seq); + priority = calcPriority(); + serial = calcSerial(); }; - int getPriority() const { return priority; } + int calcPriority() { return mileage / 1000 + year - seq; } int getSerial() const { return serial; } + int calcSerial() { return priority * 100 + (100 - seq); } + friend ostream &operator<<(ostream &os, const Customer &c) { os << c.year << " " << c.mileage << " (" << c.getSerial() << ") [" << c.name << "]"; return os;