-
Notifications
You must be signed in to change notification settings - Fork 0
/
Transaction.java
80 lines (70 loc) · 1.74 KB
/
Transaction.java
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
/**
* Program Name: Transaction.java
* Purpose: an aggregate class whose objects will be instantiated in the two subclasses and stored
* in an ArrayList structure in order to keep track of the monthly transactions against each account object.
* Coder: Dianne Corpuz Section B
* Date: February 26, 2020
*/
import java.util.ArrayList;
public class Transaction {
private String month;
private int day;
private String transaction;
private double amount;
private double balance;
//make a constuctor with no args, and sets its values to null or zero
Transaction()
{
this.month=null;
this.day=0;
this.transaction=null;
this.amount=0;
this.balance=0;
}
//place getters for month, day, transaction,amount, balance
public String getMonth() {
return month;
}
public int getDay() {
return day;
}
public String getTransaction() {
return transaction;
}
public double getAmount() {
return amount;
}
public double getBalance() {
return balance;
}
/**
* Method Name: set()
* Purpose: sets the dates, transaction and balance to its values
* Accepts:String month,int day,String transaction,double amount, double balance
* Returns: NOTHING
*
*/
public void set(String month,int day,String transaction,double amount, double balance)
{
this.month=month;
this.day=day;
this.transaction=transaction;
this.amount=amount;
this.balance=balance;
}
/**
* Method Name: toString
* Purpose: to output all variables
* Accepts: NOTHING.
* Returns: String
*
*/
public String toString()
{
String output = "";
output=month+"\t"+ day+ "\t"+ String.format("%-12s",transaction)+ "\t"+
String.format("$%-7s",String.format("%.2f",amount))+"\t"
+ "Balance: $"+ String.format("%.2f",balance)+"\n";
return output;
}
}