-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvoice.cpp
More file actions
68 lines (58 loc) · 1.57 KB
/
Invoice.cpp
File metadata and controls
68 lines (58 loc) · 1.57 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
// Invoice class interface implementation.
#include <iostream>
#include <string>
#include "Invoice.h"
using namespace std;
// class constructor implementation
Invoice::Invoice(string partNum, string partDesc, int partQuan, int pricePerIt){
setPartNumber(partNum);
setPartDescription(partDesc);
setPartQuantity(partQuan);
setPricePerItem(pricePerIt);
}
// get function for partNumber
string Invoice::getPartNumber(){
return partNumber;
}
// set function for partNumber
void Invoice::setPartNumber(string partNum){
partNumber = partNum;
}
// get function for partDescription
string Invoice::getPartDescription(){
return partDescription;
}
// set function for partDescription
void Invoice::setPartDescription(string partDesc){
partDescription = partDesc;
}
// get function for partQuantity
int Invoice::getPartQuantity(){
return partQuantity;
}
// set function for partQuantity
void Invoice::setPartQuantity(int partQuan){
if (partQuan <= 0){
cerr << "Invalid part quantity. Setting to 0." << endl;
partQuantity = 0;
}else {
partQuantity = partQuan;
}
}
// get function for pricePerItem
int Invoice::getPricePerItem(){
return pricePerItem;
}
// set function for pricePerItem
void Invoice::setPricePerItem(int pricePerIt){
if (pricePerIt <= 0){
cerr << "Invalid price per item. Setting to 0." << endl;
pricePerItem = 0;
}else {
pricePerItem = pricePerIt;
}
}
// function to compute the invoice amount
int Invoice::getInvoiceAmount(){
return getPartQuantity() * getPricePerItem();
}