-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCircle.java
64 lines (50 loc) · 1.56 KB
/
Circle.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
/*
Corey Carter
ID: 5026487
CSCI_1933, Sec-001
Project 2:Object-oriented geometry and graphics - Circle Method
*/
import java.awt.*;
public class Circle{
private double xPos; //Creates private variables, need methods to change or use.
private double yPos;
private double radius;
private Color shapeColor;
public Circle(double x, double y, double rad){
xPos = x; //Constutor class used for default values
yPos = y;
radius = rad;
shapeColor = Color.green;
}
public double calculatePerimeter(){
double perimeter = 2 * (Math.PI * radius); //formula for circle perimeter
return(perimeter);
}
public double calculateArea(){
double area = Math.PI * Math.pow(radius, 2); //formula for a circles area
return(area);
}
public void setColor(Color newShapeColor){
shapeColor = newShapeColor; //Reassigns shape color
}
public void setPos(double newXPos, double newYPos){
xPos = newXPos; //gives new X and Y cor
yPos = newYPos;
}
public void setRadius(double newRadius){
radius = newRadius; //changes circles radius
}
public Color getColor(){
return(shapeColor); //gets the shapes color
}
public double getXPos(){
return(xPos); //gets the shapes X position
}
public double getYPos(){
return(yPos); //gets the shapes Y position
}
public double getRadius(){
return(radius); //gets the shapes radius
}
}