-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDonor.java
More file actions
48 lines (40 loc) · 908 Bytes
/
Donor.java
File metadata and controls
48 lines (40 loc) · 908 Bytes
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
import java.util.ArrayList;
/**Java class to hold information for a Donor of a political campaign.
*
* @author logan
* @version 1.0
*/
public class Donor {
//data variables
private String name;
private ArrayList<Double> donations = new ArrayList<Double>();
//constructors
public Donor() {
name = "";
}
public Donor(String name) {
this.name = name;
}
public Donor(String name, double donation) {
this.name = name;
donations.add(donation);
}
//methods
public String getName() {
return name;
}
public double getTotalDonations() {
double total = 0;
for(int i = 0; i < donations.size(); i++) {
total += donations.get(i);
}
return total;
}
@Override
public String toString() {
return "The name of the donor is " + name + " and the amount donated is $" + getTotalDonations();
}
public void addDonation(double donation) {
donations.add(donation);
}
}