-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMario.java
141 lines (126 loc) · 3.55 KB
/
Mario.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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/**
* This class stores information about Mario's location on the map.
* It has a copy constructor and has methods to retrieve and set the location of Mario.
*/
public class Mario extends Character {
private int health;
private int coins;
private String sprite = "Right";
private int startPositionX;
private int startPositionY;
private int player;
/**
* This constructor takes two integers as parameters corresponding to Mario's x and y positions.
* Within the constructor Mario's health is set to a default of 3 - this is before any interaction with Goombas
* or any other obstacles that may reduce his health. Coins are also set to a default of 0 which increments as collects them.
* @param x is Mario's x position
* @param y is Mario's y position
*/
public Mario(int x, int y, int player) {
super(x, y);
this.setStartPositionX(x);
this.setStartPositionY(y);
setHealth(3);
setCoins(0);
this.player = player;
}
/**
* Copy Constructor
* @param m instance of Mario
*/
public Mario(Mario m) {
super(m.getXPos(), m.getYPos());
setHealth(m.getHealth());
setCoins(m.getCoins());
}
/**
* Setter Method that takes an integer as a parameter which corresponds to Mario's health
* @param health represents Mario's health
*/
public void setHealth(int health) {
this.health = health;
}
/**
* This method takes an integer that decrements Marios health when he comes into contact with obstacles
* on the board that may cause harm to him
* @param damage represents how much to decrement Mario's health (usually by 1)
*/
public void hurt(int damage){
this.health -= damage;
}
/**
* Getter Method for Health
* @return returns an Integer which is Mario's Health
*/
public int getHealth() {
return this.health;
}
/**
* Setter Method that takes an integer as a parameter which represents coins collected
* @param coins represents coins collected by Mario
*/
public void setCoins(int coins) {
this.coins = coins;
}
/**
* Getter Method for Coins
* @return returns an Integer coins collected
*/
public int getCoins() {
return this.coins;
}
/**
* This method increments the each coins Mario collects during the gameplay by 1
*/
public void addCoin() {
this.coins += 1;
}
public String getType() {
return "Mario";
}
/**
* Getter Method for sprites
* @return returns a String which is set to a default of "Right"
*/
public String getSprite(){
return sprite;
}
public int getPlayer(){
return player;
}
/**
* Setter Method for sprites
* @param s setting the sprite to s which corresponds to user input and changes accordingly
*/
public void setSprite(String s){
sprite = s;
}
/**
* Getter Method for the starting x position of Mario
* @return returns an Integer corresponding to Mario's initial x position on the board
*/
public int getStartPositionX() {
return startPositionX;
}
/**
* Setter Method for the starting x position of Mario
* @param startPositionX sets the initial x position of Mario on the board
*/
public void setStartPositionX(int startPositionX) {
this.startPositionX = startPositionX;
}
/**
* Getter Method for the starting y position of Mario
* @return returns an Integer corresponding to Mario's initial y position on the board
*/
public int getStartPositionY() {
return startPositionY;
}
/**
*Setter Method for the starting y position of Mario
* @param startPositionX sets the initial y position of Mario on the board
*/
public void setStartPositionY(int startPositionY) {
this.startPositionY = startPositionY;
}
}