-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransactionLogEntry.h
More file actions
112 lines (88 loc) · 4.88 KB
/
Copy pathTransactionLogEntry.h
File metadata and controls
112 lines (88 loc) · 4.88 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
// Blake Berry
// 03/08/2022
// Homework 4
// This file is an interface for the TransactionLogEntry class. The
// TransactionLogEntry class is a sortable class that sorts based upon the
// customer name. The TransactionLogEntry class couples a customer with a list
// of transactions made by that customer. These transactions are stored in
// chronlogical order
//-----------------------------------------------------------------------------
#pragma once
#include "Comparable.h"
#include "Collectible.h"
#include "Customer.h"
#include <vector>
#include "Transaction.h"
class TransactionLogEntry: public Comparable
{
private:
const Customer* customer_; // the customer making the transaction
mutable std::vector<Transaction*> transactionLog_; // a chronological order of
// the customers transactions
public:
//-------------------------- Default Constructor ---------------------------
// Creates an empty entry filled with a null customer and empty transition
// log
// Postconditions: Creates an empty entry filled with a null customer and empty
// transition log
TransactionLogEntry();
//-------------------------- Constructor -----------------------------------
// Creates a log entry given a customer and an initial transaction
// Postconditions: Creates an entry for a given customer and logs the
// transaction
TransactionLogEntry(const Customer*& cust, Transaction*& initialTransaction);
//-------------------------- Constructor -----------------------------------
// Creates a dummy transitionLogEntry for a given customer
// Postconditions: Creates an entry for a given customer
TransactionLogEntry(const Customer*& cust);
//------------------------- Destructor -------------------------------------
// Frees the transaction of any dynamic memory, the transaction does not
// own the item data -- it does not own the customer, that is to be freed
// by the customer Manager
// Postconditions: frees any deynamic memory associated with the
// transactionLogEntry
virtual ~TransactionLogEntry();
//-------------------------- operator== ------------------------------------
// Checks if two transactionLogEntries are equivilent. Equivilance is
// defined by the customer name the object stores
// Postconditions: Returns true if both objects are equivilent
// Returns false if the objects are not equivilent.
virtual bool operator==(const Comparable& right) const;
//-------------------------- operator!= ------------------------------------
// Checks if two transactionLogEntries are not equivilent. Equivilance is
// quivilance is defined by the customer name the object stores
// Postconditions: Returns true if both objects are not equivilent
// Returns false if the objects are equivilent.
virtual bool operator!=(const Comparable& right) const;
//-------------------------- operator> -------------------------------------
// Checks if two TransactionLogEntries have a greater than relationship.
// Value is determined by the customer name associated with the entry
// Postconditions: Returns true if the right hand side is smaller
// than the left hand side. Otherwise, false is returned
virtual bool operator>(const Comparable& right) const;
//-------------------------- operator< -------------------------------------
// Checks if two TransactionLogEntries have a less than relationship.
// Value is determined by the customer name associated with the entry
// Postconditions: Returns false if the right hand side is smaller
// than the left hand side. Otherwise, true is returned
virtual bool operator<(const Comparable& right) const;
//-------------------------- print --------------------------------------
// Prints the customer name on one line then each transaction in chrono
// order one tab under the customer name
// Postconditions: prints to the console a representation of the object
virtual void print() const;
//-------------------------- addTransaction --------------------------------
// Adds a transaction for a given customer to their transactionLog
// Preconditions: Assumes that the transaction is valid and that the
// customer is valid
// Postconditions: adds the transaction to the end of the customers log
bool addTransaction(Transaction* toAdd) const;
//-------------------------- copy ------------------------------------------
// creates a deep copy of the current entry and returns a non-modifyable
// pointer to it
// preconditions : The caller must means to deallocate the memory
// associated
// Postconditions: returns a constant pointer deep copy of the current
// entry
virtual const Comparable* copy() const;
};