Add files via upload

This commit is contained in:
sys_32
2024-09-25 12:40:41 -07:00
committed by GitHub
parent 9e7018f83e
commit 207ef79678
4 changed files with 161 additions and 0 deletions

31
Circle/Circle.java Normal file
View File

@@ -0,0 +1,31 @@
package Circle;
public class Circle {
private double radius;
private String color;
public Circle(double radius, String color) {
this.radius = radius;
this.color = color;
}
public double getRadius() {
return radius;
}
public void setRadius(double radius) {
this.radius = radius;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public double getArea() {
return Math.PI * Math.pow(radius, 2);
}
}

41
Circle/Rectangle.java Normal file
View File

@@ -0,0 +1,41 @@
package Circle;
public class Rectangle {
private double length;
private double width;
private String color;
public Rectangle(double length, double width, String color) {
this.length = length;
this.width = width;
this.color = color;
}
public double getLength() {
return length;
}
public void setLength(double length) {
this.length = length;
}
public double getWidth() {
return width;
}
public void setWidth(double width) {
this.width = width;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public double getArea() {
return length * width;
}
}

58
Circle/Shape.java Normal file
View File

@@ -0,0 +1,58 @@
package Circle;
public class Shape {
public static void main(String[] args) {
Circle circle = new Circle(5, "red");
Circle circle2 = new Circle(14, "blue");
Square square = new Square(5, "red");
Square square2 = new Square(14, "blue");
Rectangle rectangle = new Rectangle(5, 10, "red");
Rectangle rectangle2 = new Rectangle(14, 20, "blue");
System.out.println("Circle 1");
System.out.println("---------");
System.out.println("Circle 1 Area: " + circle.getArea());
System.out.println("Circle 1 Color: " + circle.getColor());
System.out.println("Circle 1 Radius: " + circle.getRadius());
System.out.println();
System.out.println("Circle 2");
System.out.println("---------");
System.out.println("Circle 2 Area: " + circle2.getArea());
System.out.println("Circle 2 Color: " + circle2.getColor());
System.out.println("Circle 2 Radius: " + circle2.getRadius());
System.out.println();
System.out.println("Square 1");
System.out.println("---------");
System.out.println("Square 1 Area: " + square.getArea());
System.out.println("Square 1 Color: " + square.getColor());
System.out.println("Square 1 Side: " + square.getSide());
System.out.println();
System.out.println("Square 2");
System.out.println("---------");
System.out.println("Square 2 Area: " + square2.getArea());
System.out.println("Square 2 Color: " + square2.getColor());
System.out.println("Square 2 Side: " + square2.getSide());
System.out.println();
System.out.println("Rectangle 1");
System.out.println("---------");
System.out.println("Rectangle 1 Area: " + rectangle.getArea());
System.out.println("Rectangle 1 Color: " + rectangle.getColor());
System.out.println("Rectangle 1 Length: " + rectangle.getLength());
System.out.println("Rectangle 1 Width: " + rectangle.getWidth());
System.out.println();
System.out.println("Rectangle 2");
System.out.println("---------");
System.out.println("Rectangle 2 Area: " + rectangle2.getArea());
System.out.println("Rectangle 2 Color: " + rectangle2.getColor());
System.out.println("Rectangle 2 Length: " + rectangle2.getLength());
System.out.println("Rectangle 2 Width: " + rectangle2.getWidth());
}
}

31
Circle/Square.java Normal file
View File

@@ -0,0 +1,31 @@
package Circle;
public class Square {
private double side;
private String color;
public Square(double side, String color) {
this.side = side;
this.color = color;
}
public double getSide() {
return side;
}
public void setSide(double side) {
this.side = side;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public double getArea() {
return Math.pow(side, 2);
}
}