-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCar.cpp
76 lines (70 loc) · 1.11 KB
/
Car.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//Joel Asante
#include"Car.h"
//default Constructor
Car::Car()
{
id = 0;
make = "";
model = "";
color = "";
}
//Overload Constructor
Car::Car(int id, string make, string model, string color)
{
this->id = id;
this->make = make;
this->model = model;
this->color = color;
}
//getters
int Car::getID()
{
return id;
}
string Car::getModel()
{
return model;
}
string Car::getMake()
{
return make;
}
string Car::getColor()
{
return color;
}
//setters
void Car::setID(int id)
{
this->id = id;
}
void Car::setModel(string model)
{
this->model = model;
}
void Car::setMake(string make)
{
this->make = make;
}
void Car::setColor(string color)
{
this->color = color;
}
//overload operator for input and outpur
ostream& operator << (ostream& out, const Car& c)
{
out << c.id << " " << c.make << " " << c.model << " " << c.color << endl;
return out;
}
istream& operator >> (istream& in, Car& c)
{
cout << "Enter Id: ";
in >> c.id;
cout << "Enter Make: ";
in >> c.make;
cout << "Enter Model: ";
in >> c.model;
cout << "Enter color: ";
in >> c.color;
return in;
}