-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPart.h
More file actions
79 lines (57 loc) · 2.26 KB
/
Part.h
File metadata and controls
79 lines (57 loc) · 2.26 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
/*
* Part.h
*
* Created on: 27 Nov 2011
* Author: Max Foster
*/
#ifndef PART_H_
#define PART_H_
#include <fstream>
#include "Record.h"
class Part : public Record {
public:
static const std::string databaseFilename;
static const int
minNameLength, maxNameLength,
minNumberLength, maxNumberLength;
static int size();
bool pending; // Used when the part has been created successfully, but hasn't been added to the database yet
Part(const int jobId = -1, const char *name = "", const char *number = "", const double price = 0.0,
const double vatRate = -1.0, const int quantity = 1);
Part(const Part &part);
~Part();
void operator =(const Part &part);
void writeToFile(std::fstream &file) const;
void readFromFile(std::fstream &file);
bool hasMatchingField(const std::string &fieldName, const int searchTerm) const;
bool hasMatchingField(const std::string &fieldName, const char *searchTerm) const;
bool hasMatchingField(const std::string &fieldName, const double searchTerm) const;
bool fieldCompare(const Part &rhs) const;
bool completeCompare(const Part &rhs) const;
int getJobId() const;
void setJobId(const int newJobId);
static bool isValidJobId(const int value, std::string &errorMessage);
const char * getName() const;
void setName(const char *newName);
static bool isValidName(const char *value, std::string &errorMessage);
const char * getNumber() const;
void setNumber(const char *newNumber);
static bool isValidNumber(const char *value, std::string &errorMessage);
double getPrice() const;
void setPrice(const double newPrice);
static bool isValidPrice(const double value, std::string &errorMessage);
double getVatRate() const;
void setVatRate(const double newVatRate);
static bool isValidVatRate(const double value, std::string &errorMessage);
int getQuantity() const;
void setQuantity(const int newQuantity);
static bool isValidQuantity(const int value, std::string &errorMessage);
void validate() const;
double getTotalPrice() const;
private:
int jobId, quantity;
char *name, *number;
double price, vatRate;
};
std::ostream & operator <<(std::ostream &stream, const Part &part);
#endif /* PART_H_ */