/
Goal.java
74 lines (64 loc) · 1.04 KB
/
Goal.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
/**
*
* Goal.java - Goal class for AirPong
*
* @author Brian Etzel
* @version 1.0
*/
import java.awt.Graphics;
import java.awt.Color;
public class Goal
{
private final int GOAL_HEIGHT = 125;
private final int GOAL_WIDTH = 30;
private int x;
private int y = 187;
private int yVelocity = 0;
/**
* Constructor for goal class
*
* @param x - the x position the goal is to be placed at
*/
public Goal(int _x)
{
this.x = _x;
}
/**
* Returns the integer value of the goal width
*/
public int getGoalWidth()
{
return this.GOAL_WIDTH;
}
/**
* Returns the integer value of the goal height
*/
public int getGoalHeight()
{
return this.GOAL_HEIGHT;
}
/**
* Returns the starting x value of the goal
*/
public int getX()
{
return this.x;
}
/**
* Returns the y position of the goal
*/
public int getY()
{
return this.y;
}
/**
* Paints the goal object on the screen
*
* @param g - Graphics object
*/
public void paint(Graphics g)
{
g.setColor(Color.RED);
g.fillRect(x, y, GOAL_WIDTH, GOAL_HEIGHT);
}
}