-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiamondClass.java
More file actions
29 lines (25 loc) · 923 Bytes
/
DiamondClass.java
File metadata and controls
29 lines (25 loc) · 923 Bytes
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
// Author: Matthew Leung
// ICS4U1 Final Project
// Penguin Solitaire
import java.awt.*; // Java's Abstract Windowing Toolkit package - includes class Color
public class DiamondClass extends SuitClass
{
public void draw (Graphics g)
{
// declare two arrays for X & Y coordinates of Diamond
int iPointsX[] = new int [4];
int iPointsY[] = new int [4];
// calculate points on diamond & store in the arrays
iPointsX [0] = getCenterX () - getWidth () / 2;
iPointsY [0] = getCenterY ();
iPointsX [1] = getCenterX ();
iPointsY [1] = getCenterY () - getHeight () / 2;
iPointsX [2] = getCenterX () + getWidth () / 2;
iPointsY [2] = getCenterY ();
iPointsX [3] = getCenterX ();
iPointsY [3] = getCenterY () + getHeight () / 2;
// draw the diamond using methods available from the Console object (c)
g.setColor (getColor ());
g.fillPolygon (iPointsX, iPointsY, 4);
}
}