Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arvand_Darvish_9831137 #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Arvand_Darvish/ArvandDarvish
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Full Name: Arvand Darvish
Student Number: 9831137


Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions Arvand_Darvish/workshop4&5/workshop5/.idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Arvand_Darvish/workshop4&5/workshop5/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Arvand_Darvish/workshop4&5/workshop5/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 124 additions & 0 deletions Arvand_Darvish/workshop4&5/workshop5/.idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

95 changes: 95 additions & 0 deletions Arvand_Darvish/workshop4&5/workshop5/.idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
47 changes: 47 additions & 0 deletions Arvand_Darvish/workshop4&5/workshop5/src/Circle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import java.util.Objects;

public class Circle {

private int radius;

Circle(int radius) {
this.radius = radius;
}

public double calculatePerimeter() {
return 2*3.14*radius;
}

public double calculateArea() {
return 3.14*radius*radius;
}

public void draw() {
System.out.println(toString());
System.out.println("Perimeter = " + calculatePerimeter());
System.out.println("Area = " + calculateArea());
System.out.println();
}

@Override
public String toString() {
return "Circle{" + " radius=" + getRadius() + '}';
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Circle circle = (Circle) o;
return radius == circle.radius;
}

@Override
public int hashCode() {
return Objects.hash(radius);
}

public int getRadius() {
return radius;
}
}
22 changes: 22 additions & 0 deletions Arvand_Darvish/workshop4&5/workshop5/src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
public class Main {

public static void main(String[] args) {
Circle circle1 = new Circle(19);
Circle circle2 = new Circle(3);
Rectangle rect1 = new Rectangle(1,4,1,4);
Rectangle rect2 = new Rectangle(8,5,8,5);
Rectangle rect3 = new Rectangle(6,6,6,6);
Triangle tri1 = new Triangle(2,2,2);
Triangle tri2 = new Triangle(4,4,6);
Paint paint = new Paint();
paint.addCircle(circle1);
paint.addCircle(circle2);
paint.addRectangle(rect1);
paint.addRectangle(rect2);
paint.addRectangle(rect3);
paint.addTriangle(tri1);
paint.addTriangle(tri2);
paint.drawAll();
paint.printAll();
}
}
49 changes: 49 additions & 0 deletions Arvand_Darvish/workshop4&5/workshop5/src/Paint.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import java.util.ArrayList;

public class Paint {
private ArrayList<Triangle> triangles = new ArrayList<>();
private ArrayList<Circle> circles = new ArrayList<>();
private ArrayList<Rectangle> rectangles = new ArrayList<>();

public void addTriangle(Triangle triangle) {
triangles.add(triangle);
}

public void addRectangle(Rectangle rectangle) {
rectangles.add(rectangle);
}

public void addCircle(Circle circle) {
circles.add(circle);
}

public void drawAll() {
for (Triangle a: triangles) {
a.draw();
}
System.out.println();
for (Rectangle a: rectangles) {
a.draw();
}
System.out.println();
for (Circle a: circles) {
a.draw();
}
System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$");
}

public void printAll() {
for (Triangle a: triangles) {
System.out.println(a.toString());
}
System.out.println();
for (Rectangle a: rectangles) {
System.out.println(a.toString());
}
System.out.println();
for (Circle a: circles) {
System.out.println(a.toString());
}
System.out.println("***********************");
}
}
Loading