-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCustomer.cpp
More file actions
148 lines (122 loc) · 3.52 KB
/
Customer.cpp
File metadata and controls
148 lines (122 loc) · 3.52 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
// Preprocessor directives required for the Customer.cpp file
#include "Customer.h"
#include <iostream>
#include <iomanip>
using namespace std;
Customer::Customer()
{
}
Customer::Customer(string first, string last, string address, string city, string state, int zip, string invoice)
{
First = first; // sets parameter to private variable
Last = last; // sets parameter to private variable
Address = address; // sets parameter to private variable
City = city; // sets parameter to private variable
State = state; // sets parameter to private variable
zipCode = zip;; // sets parameter to private variable
invoiceFile = invoice; // sets parameter to private variable
}
// PRINTCART -- Goes through and prints the current items in the cart
void Customer::printCart(LinkedList *shoppingCart)
{
Inventory *current = shoppingCart->getHead();
// While loop that goes through and prints the itemNumber, itemName, itemCost, and quantity
while (current != NULL)
{
cout << current->getItemNumber() << "\t"; // Outputs the itemNumber
cout << current->getItemName() << "\t"; // Outputs the itemName
cout << "$" << fixed << setprecision(2) << current->getItemCost() << "\t"; // Outputs the itemCost
cout << current->getQuantity() << endl; // Outputs the quantity
current = current->next; // Traverses to the next node
}
}
// SEARCHITEM -- Goes through searching to see if the user input matches with values within the file
Inventory * Customer::searchItem(LinkedList *shoppingCart, int targetItemNumber)
{
Inventory *lastofCart = shoppingCart->getHead();
// While loop that goes through and prints the itemNumber, itemName, itemCost, and quantity
while (lastofCart != NULL)
{
// IF statement, that displays item number, name, and quantity upon the item input being valid
if (lastofCart->getItemNumber() == targetItemNumber)
{
cout << lastofCart->getItemNumber() << "\t"; // Outputs the itemNumber
cout << lastofCart->getItemName() << "\t"; // Outputs the itemName
cout << "$" << fixed << setprecision(2) << lastofCart->getItemCost() << "\t"; // Outputs the itemCost
cout << lastofCart->getQuantity() << endl; // Outputs the quantity
return lastofCart; // Returns the item if found
}
lastofCart = lastofCart->next; // Traverses to the next node
}
return lastofCart; // If not found returns lastofCart
}
// Gets the first name
string Customer::getFirst()
{
return First;
}
// Gets the last name
string Customer::getLast()
{
return Last;
}
// gets the address
string Customer::getAddress()
{
return Address;
}
// gets the city
string Customer::getCity()
{
return City;
}
// gets state
string Customer::getState()
{
return State;
}
// gets zip code
int Customer::getZipCode()
{
return zipCode;
}
// gets invoice
string Customer::getInvoiceFile()
{
return invoiceFile;
}
// set first name
void Customer::setFirst(string F)
{
First= F;
}
// set last name
void Customer::setLast(string L)
{
Last = L;
}
// set address
void Customer::setAddress(string A)
{
Address = A;
}
// set city
void Customer::setCity(string c)
{
City = c;
}
// set state
void Customer::setState(string s)
{
State = s;
}
// set zip code
void Customer::setZipCode(int z)
{
zipCode = z;
}
// set invoice
void Customer::setInvoiceFile(string invoice)
{
invoiceFile = invoice;
}