-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFundraiser.java
More file actions
79 lines (73 loc) · 1.66 KB
/
Fundraiser.java
File metadata and controls
79 lines (73 loc) · 1.66 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
/**
* Fuad Mohamoud
* Computer Science II
* 01/29/2106
*/
import java.util.Random;
public class Fundraiser
{
private String location = "DEFAULT";
private Candidate candidate = null;
private int donors;
private Random rand = new Random();
/**
* Fundraiser constructor, takes in a Fundraiser
* location along with a candidate
*/
public Fundraiser(String inLoc, Candidate inCandidate)
{
setLocation(inLoc);
setCandidate(inCandidate);
donors = rand.nextInt(201);
}
/**
* Sets location equal to location provided
*/
public void setLocation(String inLoc)
{
location = inLoc;
}
/**
* returns location
*/
public String getLocation()
{
return location;
}
/**
* Sets Candidate to candidate provided
*/
public void setCandidate(Candidate inCandidate)
{
candidate = inCandidate;
}
/**
*returns Candidate
*/
public Candidate getCandidate()
{
return candidate;
}
/**
* returns random amount of donors created in
* Fundraiser constructor
*/
public int getDonors()
{
return donors;
}
/**
* Gives each donor a random amount of money
* Adds all that money together and add's it to
* the Candidate we are doing fundraising for
*/
public void raiseMoney()
{
int total = 0;
for (int x = 0; x < donors; x++)
{
total += rand.nextInt(151);
}
candidate.addMoney(total);
}
}