-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransaction.cpp
More file actions
104 lines (79 loc) · 2.64 KB
/
transaction.cpp
File metadata and controls
104 lines (79 loc) · 2.64 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
#include"transaction.h"
#include"color.h"
transaction :: transaction() {
// here in initlize oll of them
item= new char *[50];
for (int i = 0; i < 50; i++)
{
item[i] = new char[15];
}
price = new double [40];
total = new double [40];
selected = 0;
quantity=0;
}
// ye fucntion sirf bill generate karta ha bas
transaction::transaction(char **items, int selected, int quantity, double *price) {
ofstream transactionFile("transactions.txt", ios::app);
if (!transactionFile.fail()) {
transactionFile << "\t\tItem: " << items[selected] << "\n";
transactionFile << "\t\tQuantity: " << quantity << "\n";
transactionFile << "\t\tTotal Price: " << quantity * price[selected] << "\n\n";
// Display the generated transaction on the console
cout << "\t\t\033[48;5;196m****************************************************\033[0m\n";
cout << "\t\t\033[48;5;30m** digital transaction bill **\033[0m\n";
cout << "\t\t\033[48;5;21m****************************************************\033[0m\n\n";
cout << "\t\tItem: \033[1;32m" << items[selected] << "\033[0m\n";
cout << "\t\tQuantity: \033[1;34m" << quantity << "\033[0m\n";
cout << "\t\tTotal Price: \033[1;33mR.S " << quantity * price[selected] << "\033[0m\n\n";
cout << "\t\t\033[48;5;196m************ Thanks for Choosing us! ************\033[0m\n";
cout << "\t\t\033[48;5;30m************ We Wish to See You Again! *********\033[0m\n\n";
// Display some stars for khubsurti only
for (int i = 0; i < 50; ++i) {
cout << "*";
}
cout << endl;
// Close the file
transactionFile.close();
} else {
markRed();
cout << "Error opening transactions file.\n";
resetColor();
}
}
// now define setters here
void transaction::setItem(char **items) {
item = items;
}
void transaction::setQuantity(int q) {
quantity = q;
}
void transaction::setPrice(double *p) {
price = p;
}
void transaction::setTotal(double *t) {
total = t;
}
void transaction::setSelected(int s) {
selected = s;
}
char ** transaction::getItem() {
return item;
}
int transaction::getQuantity() {
return quantity;
}
double * transaction::getPrice() {
return price;
}
double * transaction::getTotal() {
return total;
}
int transaction::getSelected() {
return selected;
}
transaction::~transaction(){
delete [] item;
delete [] price;
delete [] total;
}