-
Notifications
You must be signed in to change notification settings - Fork 0
/
Order.cpp
82 lines (70 loc) · 1.36 KB
/
Order.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
#include "Order.h"
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
ostream& operator<<(ostream& osObject, const Order& order)
{
osObject << setw(20) << left << "Title:";
osObject << setw(30) << right << order.bookTitle << endl;
osObject << setw(20) << left << "Unit Price: $";
osObject << setw(30) << right << fixed << setprecision(2) << order.unitPrice << endl;
osObject << setw(20) << left << "Number:";
osObject << setw(30) << right << setprecision(0) << order.number << endl;
return osObject;
}
Order::Order()
{
bookTitle = "";
unitPrice = 0.0;
number = 0;
}
Order::Order(string _title, double _price, int _number)
{
bookTitle = _title;
unitPrice = _price;
number = _number;
}
bool Order::checkTitle(string name)
{
if (name == bookTitle)
return true;
else
return false;
}
double Order::CalculateCost()
{
double cost = unitPrice * number;
return cost;
}
void Order::setNumber(int _number)
{
number = _number;
}
string Order::getTitle()
{
return bookTitle;
}
double Order::getPrice()
{
return unitPrice;
}
int Order::getNumber()
{
return number;
}
bool Order::operator==(const Order& compare) const
{
if (bookTitle == compare.bookTitle)
return true;
else
return false;
}
bool Order::operator!=(const Order& compare) const
{
if (bookTitle != compare.bookTitle)
return true;
else
return false;
}