/* * This files contains some of the low level details of the Car class * implementation. * * THERE IS NO REASON FOR YOU TO READ OR EDIT THIS FILE */ #include "Car.h" #include using namespace std; Car::Car(string color, int doors, string dealerName) : valid(true), broken(false), color(color), numDoors(doors), dealer(dealerName) { } Car::Car(const Car& other) { // NOT ALLOWED TO COPY A CAR cout << "ERROR. A request has been made to copy a car," << endl; cout << " however cars cannot be modeled off another car." << endl; valid = false; } Car& Car::operator=(const Car& other) { // NOT ALLOWED TO ASSIGN ONE CAR TO ANOTHER if (this!=&other) { cout << "ERROR. A request has been made to assign a car," << endl; cout << " however cars cannot be modeled off another car." << endl; valid = false; } return *this; } string Car::toString() const { stringstream result; if (valid) result << color << " "<< numDoors << "-door car " << (broken ? "(broken)" : "(good condition)") << endl << " Purchased at " << dealer; else result << "INVALID CAR"; return result.str(); } string Car::getDealerName() const { return dealer; } void Car::fixIt() { broken = false; } void Car::breakIt() { broken = true; } ostream& operator<<(ostream& out, const Car& c) { out << c.toString(); return out; }