-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVehicle.cpp
More file actions
95 lines (92 loc) · 1.82 KB
/
Vehicle.cpp
File metadata and controls
95 lines (92 loc) · 1.82 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
#include "Vehicle.h"
#include <string>
using std::string;
#include "List.h"
//constructor setting identity, model year, color and mileage
Vehicle::Vehicle(
const int identity, const int theyear, const string &colorful, const int miles ) : id(identity), year(theyear), mileage(miles)
{
setcolor(colorful);
//mallocs tasklist
tasklist = new List();
}
//destructor
Vehicle::~Vehicle()
{
delete tasklist;
tasklist = NULL;
}
//sets unique id
void Vehicle::setid(const int identity)
{
id = identity;
}
//returnd unique id
int Vehicle::getid() const
{
return id;
}
//sets model year
void Vehicle::setyear(const int theyear)
{
year = theyear;
}
//returns model year
int Vehicle::getyear() const
{
return year;
}
//sets color
void Vehicle::setcolor(const string &colorful)
{
color = colorful;
}
//returns color string
string Vehicle::getcolor() const
{
return color;
}
//sets mileage
void Vehicle::setmileage(const int miles)
{
mileage = miles;
}
//returns mileage
int Vehicle::getmileage() const
{
return mileage;
}
//prints id, year, color mileage and current firsttask
void Vehicle::print() const
{
cout << "ID: "<< getid() << endl;
cout << "Year: "<< getyear() << endl;
cout << "Color: "<< getcolor() << endl;
cout << "Mileage "<< getmileage() << endl;
cout << "Current task: " << endl;
tasklist->printfirst();
}
//adds new task by calling list's method
void Vehicle::add(std::string &tname, const int i, const int j)
{
tasklist->insert(tname, i, j);
}
//operator overloading
ostream &operator<<(ostream &output, const Vehicle &v)
{
v.print();
}
//gets total charge
int Vehicle::getcost() const
{
return tasklist->getbill();
}
//printsbill in task
void Vehicle::printbill() const
{
tasklist->print();
}