-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransaction.cpp
43 lines (38 loc) · 971 Bytes
/
transaction.cpp
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
/*
* transaction.cpp is part of the Movie Store Simulator, a C++ program that
* offers the function of borrow, return, or stock with up to 10,000
* customers and 26 genres of movies
*
* @author Bill Zhao, Lucas Bradley
* @date March 12th
*/
#include "transaction.h"
// Constructs a transaction according to the input
// string
Transaction::Transaction(std::string Input) {
Action = Input[0];
int It = 2;
CustomerID = 0;
while (Input[It] != ' ') {
CustomerID *= 10;
CustomerID += Input[It] - '0';
It++;
}
It++;
MediaType = Input[It];
It += 2;
MovieType = Input[It];
It += 2;
while (Input[It] != '\0') {
SortingElement += Input[It];
It++;
}
}
// Reforms the original code from the transaction data
std::string Transaction::reformString() {
std::string Result;
Result += Action;
Result += " " + std::to_string(CustomerID) + " " + MediaType + " " +
MovieType + " " + SortingElement;
return Result;
}