-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransaction.java
More file actions
81 lines (72 loc) · 2.04 KB
/
Transaction.java
File metadata and controls
81 lines (72 loc) · 2.04 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
import java.io.Serializable;
import java.util.Date;
/**
* This class represents a transaction in the Hardware Store Software.
* @author Tory Brewer
*/
public class Transaction implements Serializable {
private final String itemID;
private final Date saleDate;
private final int saleQuantity;
private final int customerId;
private final int employeeId;
/**
* Constructor initializes a SaleTransaction object with the provided values.
* @param itemID
* @param saleDate
* @param saleQuantity
* @param customerId
* @param employeeId
*/
public Transaction(String itemID, Date saleDate, int saleQuantity, int customerId, int employeeId) {
this.itemID = itemID;
this.saleDate = saleDate;
this.saleQuantity = saleQuantity;
this.customerId = customerId;
this.employeeId = employeeId;
}
/**
* Get the item ID of this transaction.
* @return itemID
*/
public String getItemID() {
return itemID;
}
/**
* Get the sale date of this transaction.
* @return saleDate
*/
public Date getsaleDate() {
return saleDate;
}
/**
* Get the sale quantity of this transaction.
* @return saleQuantity
*/
public int getSaleQuantity() {
return saleQuantity;
}
/**
* Get the customer ID of this transaction.
* @return customerId
*/
public int getCustomerId() {
return customerId;
}
/**
* Get the employee ID of this transaction.
* @return
*/
public int getEmployeeId() {
return employeeId;
}
public String getFormattedText() {
return String.format("| %-10s| %-30s| %-10s| %-12s| %-12s|%n",
itemID, saleDate, saleQuantity, customerId, employeeId);
}
@Override
public String toString() {
return "Transaction{" + "itemID=" + itemID + ", saleDate=" + saleDate + ", saleQuantity=" + saleQuantity
+ ", customerId=" + customerId + ", employeeId=" + employeeId + '}';
}
}