cis22c/07-heaps/Customer.h
Iurii Tatishchev 4dbe12e593
10.10 Lab*: Heap ADT
Refactor Customer.h slightly
2024-06-08 14:37:32 -07:00

47 lines
999 B
C++

/* *~*~*
Specification file for the Customer class
Written By: Iurii Tatishchev
Changed by: Iurii Tatishchev
IDE: CLion
*~**/
#ifndef CUSTOMER_H_
#define CUSTOMER_H_
#include <utility>
using std::string, std::ostream;
class Customer; // Forward Declaration
class Customer {
private:
int year;
int mileage;
int seq;
string name;
int priority;
int serial;
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 = calcPriority();
serial = calcSerial();
};
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;
}
};
#endif