-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOrange.java
More file actions
37 lines (33 loc) · 1.04 KB
/
Copy pathOrange.java
File metadata and controls
37 lines (33 loc) · 1.04 KB
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
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
import javax.swing.event.*;
/**
* Class responsible for drawing the orange.
*
* @author Grant Visker, John Hurley, Joseph Capper, and Logan Belak.
* @version 5/7/2021
*/
public class Orange extends Fruit
{
public Orange(JComponent container){
super(-3, -17, container, 80, container.getWidth()/3 * 2);
}
/**
Draw the orange at its current location.
@param g the Graphics object on which the orange should be drawn
*/
public void paint(Graphics g) {
if(!sliced){
g.setColor(Color.black);
g.drawOval((int)upperLeftX, (int)upperLeftY, size/2, size/2);
g.setColor(Color.orange);
g.fillOval((int)upperLeftX, (int)upperLeftY, size/2, size/2);
} else {
g.setColor(Color.orange);
g.fillArc((int)upperLeftX, (int)upperLeftY, size/2, size/2, 0, 180);
g.fillArc((int)upperLeftX, (int)upperLeftY+5, size/2, size/2,180, 180);
}
}
}