-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAttackAdvertisement.java
More file actions
68 lines (59 loc) · 2.63 KB
/
AttackAdvertisement.java
File metadata and controls
68 lines (59 loc) · 2.63 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
public class AttackAdvertisement extends Advertisement
{
private Candidate target = null;
/**
* Takes in Message and a candidate.
* Utilizes Super constructor----> Advertisement
* Method Overrides cost and triggers exception if candidate does not
* have enough money to generate the Attack Based Advertisement
* Also has a target Candidate for Attack Ad
*/
public AttackAdvertisement(String inMsg, Candidate inCand, Candidate inTarget) throws OutOfMoneyException
{
super(inMsg,inCand);
setCost(rand.nextInt(25001) + 50000);
target = inTarget;
if (getCost() > getCandidate().getMoney())
{
throw new OutOfMoneyException();
}
}
/**
* Prints information about Attack Advertisement
*/
public String toString()
{
return "This Attack Advert is:\n\tFor " + getCandidate().getName() + "\n\tAgainst: " + target.getName() + "\n\tAbout: " + getMessage() + "\n\tCosts: $" + getCost();
}
/**
* If candidates money is less then the cost required to run advert, returns a string
* If Candidates Advertisement Preference is Attack based, Increase his Debate Modifier by 20% and decrease money mod by 20%
* Also decrease Targets debate mod by 15% and money mod by 20%, and return string approving message
* otherwise increase debate Modifier by 10% and decrease Money Mod by 5% and return string not approving advertisement
* Along with decreasing Targets debate mod by 5% and money mod by 10%
*/
public String run()
{
if (getCandidate().getMoney() < getCost())
{
return "NO CASH";
}
getCandidate().addMoney(getCost() * -1);
if (getCandidate().endorse(this))
{
getCandidate().setDebateMod(getCandidate().getDebateMod() + .2);
getCandidate().setMoneyMod(getCandidate().getMoneyMod() - .2);
target.setDebateMod(target.getDebateMod() - .15);
target.setMoneyMod(target.getMoneyMod() - .25);
return "My name is " + getCandidate().getName() + ", and I approve this message";
}
else
{
getCandidate().setDebateMod(getCandidate().getDebateMod() + .1);
getCandidate().setMoneyMod(getCandidate().getMoneyMod() - .05);
target.setDebateMod(target.getDebateMod() - .05);
target.setMoneyMod(target.getMoneyMod() - .1);
return "This message has not been approved by " + getCandidate().getName() + ".";
}
}
}