-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdomain.cpp
105 lines (85 loc) · 1.47 KB
/
domain.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
/*
* domain.cpp
*
* Created on: Apr 5, 2015
* Author: Dutzi
*/
#include "domain.h"
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
Offer::Offer()
{
this->destination = "";
this->type = "";
this->price = 0;
}
Offer::~Offer()
{
// delete this;
}
Offer::Offer(string destination, string type, float price)
{
this->destination = destination;
this->type = type;
this->price = price;
}
void Offer::setDest(string dest)
{
this->destination = dest;
}
string Offer::getDest()
{
return this->destination;
}
int Offer::getId()
{
return (this->id);
}
void Offer::setType(string type)
{
this->type = type;
}
string Offer::getType()
{
return this->type;
}
void Offer::setPrice(float price)
{
this->price = price;
}
float Offer::getPrice()
{
return this->price;
}
void Offer::operator=(Offer other)
{
this->destination = other.getDest();
this->type = other.getType();
this->price = other.getPrice();
}
bool Offer::operator==(Offer& other)
{
if (this->destination == other.getDest() &&
this->type == other.getType() &&
this->price == other.getPrice())
return (true);
return (false);
}
ostream& operator <<(ostream& os, const Offer& o) {
os << o.destination << " " << o.type << " " << o.price << "\n";
return os;
}
/*
* Reads an offer
*/
istream& operator >>(istream &is, Offer& o) {
string destination, type;
float price;
is >> destination >> type >> price;
o.setDest(destination);
o.setType(type);
o.setPrice(price);
return is;
}