-
Notifications
You must be signed in to change notification settings - Fork 0
/
Green.java
49 lines (46 loc) · 1.5 KB
/
Green.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
package game;
/**
* Purpose: game<br />
* Data Submitted: 2023/11/27 <br />
* Assignment Number: assignment 2<br />
* Course Name: COSC601 <br />
* Instructor: George Ding <br />
* File Path: Green.java <br />
*
* @author Zhenghua Mu
* @version 1.0.0
*/
public class Green extends Dragon
{
public String name;
public Green(DragonSize nSize, String name)
{
super(nSize);
this.name = nSize + name;
}
@Override
public void defendAttack(Dragon obOther)
{
if(obOther instanceof Red){
this.nHitPoints -= (int)(obOther.getAttack() * 1.2) - this.getDefense();
// System.out.println(this.name + " vs Red");
}else if (obOther instanceof Green){
this.nHitPoints -= obOther.getAttack() - this.getDefense();
// System.out.println(this.name + " vs Green");
}else if (obOther instanceof White)
{
this.nHitPoints -= (int)(obOther.getAttack() * 0.9) - this.getDefense();
// System.out.println(this.name + " vs White");
}else{
this.nHitPoints -= obOther.getAttack() - this.getDefense();
// System.out.println(this.name + " vs Black");
}
}
@Override
public String toString()
{
return "Green{" +
"name='" + name + '\'' +
"} " /*+ super.toString()*/;
}
}