-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransaction.java
More file actions
77 lines (70 loc) · 1.87 KB
/
Copy pathTransaction.java
File metadata and controls
77 lines (70 loc) · 1.87 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
/**
* Represents a financial transaction with details such as amount, category, date, and type.
*/
public class Transaction {
private int id;
private double amount;
private String category;
private String date;
private String type;
/**
* Constructs a new Transaction with the specified details.
*
* @param id the unique identifier for this transaction
* @param amount the monetary amount of the transaction
* @param category the category of the transaction (e.g., "Food", "Salary")
* @param date the date of the transaction
* @param type the type of transaction ("INCOME" or "EXPENSE")
*/
public Transaction(int id, double amount, String category, String date, String type) {
this.id = id;
this.amount = amount;
this.category = category;
this.date = date;
this.type = type;
}
/**
* Returns the unique identifier of this transaction.
*
* @return the transaction ID
*/
public int getId() {
return id;
}
/**
* Returns the monetary amount of this transaction.
*
* @return the transaction amount
*/
public double getAmount() {
return amount;
}
/**
* Returns the category of this transaction.
*
* @return the transaction category
*/
public String getCategory() {
return category;
}
/**
* Returns the date of this transaction.
*
* @return the transaction date
*/
public String getDate() {
return date;
}
/**
* Returns the type of this transaction.
*
* @return the transaction type ("INCOME" or "EXPENSE")
*/
public String getType() {
return type;
}
@Override
public String toString() {
return String.format("[%s] %s: $%.2f (%s)", date, type, amount, category);
}
}