-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFundraiser.java
More file actions
57 lines (48 loc) · 1.26 KB
/
Fundraiser.java
File metadata and controls
57 lines (48 loc) · 1.26 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
import java.util.Random;
public class Fundraiser
{
private String location = "DEFAULT";
private Candidate candidate = null;
private int donors;
private Random rand = new Random();
public Fundraiser(String inLoc, Candidate inCandidate)
{
setLocation(inLoc);
setCandidate(inCandidate);
donors = rand.nextInt(201);
}
public String toString()
{
return candidate.getName() + "'s fundraiser takes place in: " + getLocation() + " and has " + getDonors() + " donors attending.\n";
}
public void setLocation(String inLoc)
{
location = inLoc;
}
public String getLocation()
{
return location;
}
public void setCandidate(Candidate inCandidate)
{
candidate = inCandidate;
}
public Candidate getCandidate()
{
return candidate;
}
public int getDonors()
{
return donors;
}
public int raiseMoney()
{
int total = 0;
for (int x = 0; x < donors; x++)
{
total += rand.nextInt(151);
}
candidate.addMoney((int)(total * candidate.getMoneyMod()));
return total;
}
}