-
Notifications
You must be signed in to change notification settings - Fork 0
/
Character.java
88 lines (82 loc) · 2.31 KB
/
Character.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
import javax.swing.*;
/**
* The basic abstract class that is used to outline every character in the game Rainbow plants.
* Every character in the game (the Player, the Flowers, the Traps) will extend this class. A Character object will never be created.
* <PRE>
* Variable Dictionary:
* xPos int position of the Character on the x axis.
* yPos int position of the Character on the y axis.
* colour int number that helps identify the colour of the Character.
* </PRE>
* @author Eric Tu and Sejin Kwon
* @version 6
* @since June 13, 2012
*/
public abstract class Character extends JLabel
{
private int xPos, yPos;
private int colour;
/**
* <PRE> Constructs a Character with x as the position of the Character on the x axis,
* y as the position on the y axis and col as the number that helps identify the colour of the Character.
*
* @param x int initial x axis position
* @param y int initial y axis position
* @param col int colour of the Character </PRE>
*/
public Character (int x, int y, int col)
{
xPos = x;
yPos = y;
colour = col;
}
/**
* Returns the position of the Character on the x axis of its container.
*
* @return the position of the Character on the x axis of its container.
*/
public int getXPos ()
{
return xPos;
}
/**
* Returns the position of the Character on the y axis of its container.
*
* @return the position of the Character on the y axis of its container.
*/
public int getYPos ()
{
return yPos;
}
/**
* Returns the color of the Character.
*
* @return the color of the Character.
*/
public int getColor ()
{
return colour;
}
/**
* Sets the position of the Character on the x axis of its container.
*
* @param x - int - The new x position of the Character.
*/
public void setXPos (int x)
{
xPos =x;
setBounds (getXPos (), getYPos (), getPreferredSize ().width, getPreferredSize ().height);
updateUI ();
}
/**
* Sets the position of the Character on the y axis of its container.
*
* @param y - int - The new y position of the Character.
*/
public void setYPos (int y)
{
yPos =y;
setBounds (getXPos (), getYPos (), getPreferredSize ().width, getPreferredSize ().height);
updateUI ();
}
}