From a0cfcdc082571a4ec6e12ec5edf9d451c7d79f47 Mon Sep 17 00:00:00 2001 From: Ehsan Fakhraie Date: Fri, 24 Apr 2020 14:09:09 +0430 Subject: [PATCH 1/6] initial Commit --- .idea/libraries/JalaliCalendar_1_3_1.xml | 9 ++ .idea/misc.xml | 9 ++ .idea/modules.xml | 8 ++ .idea/uiDesigner.xml | 124 ++++++++++++++++++++ .idea/vcs.xml | 6 + .idea/workshop-2.iml | 12 ++ .idea/workspace.xml | 115 ++++++++++++++++++ EhsanFakhraie/EhsanFakhraie | 3 + EhsanFakhraie/libs/JalaliCalendar-1.3.1.jar | Bin 0 -> 4844 bytes EhsanFakhraie/src/vote/Main.java | 22 ++++ EhsanFakhraie/src/vote/Person.java | 28 +++++ EhsanFakhraie/src/vote/Vote.java | 28 +++++ EhsanFakhraie/src/vote/Voting.java | 77 ++++++++++++ EhsanFakhraie/src/vote/VotingSystem.java | 40 +++++++ 14 files changed, 481 insertions(+) create mode 100644 .idea/libraries/JalaliCalendar_1_3_1.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/uiDesigner.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workshop-2.iml create mode 100644 .idea/workspace.xml create mode 100644 EhsanFakhraie/EhsanFakhraie create mode 100644 EhsanFakhraie/libs/JalaliCalendar-1.3.1.jar create mode 100644 EhsanFakhraie/src/vote/Main.java create mode 100644 EhsanFakhraie/src/vote/Person.java create mode 100644 EhsanFakhraie/src/vote/Vote.java create mode 100644 EhsanFakhraie/src/vote/Voting.java create mode 100644 EhsanFakhraie/src/vote/VotingSystem.java diff --git a/.idea/libraries/JalaliCalendar_1_3_1.xml b/.idea/libraries/JalaliCalendar_1_3_1.xml new file mode 100644 index 0000000..651c19d --- /dev/null +++ b/.idea/libraries/JalaliCalendar_1_3_1.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..e140ea0 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..64a7333 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workshop-2.iml b/.idea/workshop-2.iml new file mode 100644 index 0000000..e090a8c --- /dev/null +++ b/.idea/workshop-2.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..ce4a2cb --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1587715853663 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/EhsanFakhraie/EhsanFakhraie b/EhsanFakhraie/EhsanFakhraie new file mode 100644 index 0000000..9aec595 --- /dev/null +++ b/EhsanFakhraie/EhsanFakhraie @@ -0,0 +1,3 @@ +Full Name: Ehsan Fakhraie +Student Number: 9831092 + diff --git a/EhsanFakhraie/libs/JalaliCalendar-1.3.1.jar b/EhsanFakhraie/libs/JalaliCalendar-1.3.1.jar new file mode 100644 index 0000000000000000000000000000000000000000..236f2b6ad1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hUT%Z{jroGZOV5ZVm{0Rs^TGxIG>)6Zp{P-yUCCb-QAFft9wu^Rs@WXB=nE z$HIoU^0_ZJ>5@z|`3KYSL&09G5^h`VvYbaNm~@x^QXygGNw%?>d6`#cLd-yJ!^yKa z*6DSh=!;b3n-sv#^R(|;rIffz2#W)(>fV};jKJ`B?rbmlkwIh!aWIOXd1BJ votes=new ArrayList<>(); + votes.add("1"); + votingSystem.vote(0,person,votes); + + votingSystem.getVoting(0).printResult(); + + } +} diff --git a/EhsanFakhraie/src/vote/Person.java b/EhsanFakhraie/src/vote/Person.java new file mode 100644 index 0000000..4b4db96 --- /dev/null +++ b/EhsanFakhraie/src/vote/Person.java @@ -0,0 +1,28 @@ +package vote; + +public class Person { + private String firstName; + private String lastName; + + public Person(String firstName, String lastName) { + this.firstName = firstName; + this.lastName = lastName; + } + + public String getFirstName() { + return firstName; + } + + + public String getLastName() { + return lastName; + } + + @Override + public String toString() { + return "Person{" + + "firstName='" + firstName + '\'' + + ", lastName='" + lastName + '\'' + + '}'; + } +} diff --git a/EhsanFakhraie/src/vote/Vote.java b/EhsanFakhraie/src/vote/Vote.java new file mode 100644 index 0000000..f1c54de --- /dev/null +++ b/EhsanFakhraie/src/vote/Vote.java @@ -0,0 +1,28 @@ +package vote; + +import java.util.Objects; + +public class Vote { + + private Person person; + + private String date; + + public Vote(Person person, String date) { + this.person = person; + this.date = date; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Vote vote = (Vote) o; + return Objects.equals(person, vote.person); + } + + @Override + public int hashCode() { + return Objects.hash(person); + } +} diff --git a/EhsanFakhraie/src/vote/Voting.java b/EhsanFakhraie/src/vote/Voting.java new file mode 100644 index 0000000..afa8740 --- /dev/null +++ b/EhsanFakhraie/src/vote/Voting.java @@ -0,0 +1,77 @@ +package vote; + +import ir.huri.jcal.JalaliCalendar; + +import java.util.*; + +public class Voting { + /** + * determines type of poll + * 0: single vote + * 1: multi vote + */ + private int type; + private String question; + + private HashMap> polls; + + private ArrayList choices; + + public Voting(String question, int type) { + this.type = type; + this.question = question; + + polls = new HashMap<>(); + choices = new ArrayList<>(); + } + + public void createChoice(String choice) { + choices.add(choice); + polls.put(choice, new HashSet<>()); + } + + public String getNowData() { + TimeZone tz = TimeZone.getTimeZone("GMT+9:00"); + Locale loc = new Locale("ja", "JP", "JP"); + Calendar calendar = Calendar.getInstance(loc); + GregorianCalendar gc = (GregorianCalendar) calendar; + JalaliCalendar jc = new JalaliCalendar(gc); + return jc.toString(); + } + + public void vote(Person p, ArrayList votes) { + for (String v : votes) { + if (choices.contains(v)) { + Vote vote = new Vote(p, getNowData()); + HashSet vs = polls.get(v); + vs.add(vote); + polls.replace(v, vs); + } + } + } + + public int getType() { + return type; + } + + public String getQuestion() { + return question; + } + + public HashMap> getPolls() { + return polls; + } + + public ArrayList getChoices() { + return choices; + } + + public void printResult() { + for (Map.Entry> stringHashSetEntry : polls.entrySet()) { + String key = (String) stringHashSetEntry.getKey(); + HashSet votes = stringHashSetEntry.getValue(); + System.out.println("Choice " + key + " Count:" + votes.size()); + } + } + +} diff --git a/EhsanFakhraie/src/vote/VotingSystem.java b/EhsanFakhraie/src/vote/VotingSystem.java new file mode 100644 index 0000000..18dbd1e --- /dev/null +++ b/EhsanFakhraie/src/vote/VotingSystem.java @@ -0,0 +1,40 @@ +package vote; + +import java.util.ArrayList; + +public class VotingSystem { + + private ArrayList votingList; + + public VotingSystem(){ + + } + + public void createVoting(String question,int type){ + votingList.add(new Voting(question,type)); + } + + public ArrayList getVotingList() { + return votingList; + } + + public Voting getVoting(int index){ + return votingList.get(index); + } + + public void printListOfVotings(){ + for (Voting e: votingList){ + System.out.println(e); + } + } + + public void printVoting(int i){ + System.out.println(getVoting(i)); + } + + public void vote(int i,Person p,ArrayList votes){ + votingList.get(i).vote(p,votes); + } + + +} From 84b813bd18d6a2b3c9095935c36a24e8a4b85e24 Mon Sep 17 00:00:00 2001 From: Ehsan Fakhraie Date: Fri, 24 Apr 2020 14:30:24 +0430 Subject: [PATCH 2/6] completed --- EhsanFakhraie/src/vote/Main.java | 6 +++++- EhsanFakhraie/src/vote/Vote.java | 2 ++ EhsanFakhraie/src/vote/Voting.java | 25 +++++++++++++++++------- EhsanFakhraie/src/vote/VotingSystem.java | 2 +- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/EhsanFakhraie/src/vote/Main.java b/EhsanFakhraie/src/vote/Main.java index 48e9ae5..c067824 100644 --- a/EhsanFakhraie/src/vote/Main.java +++ b/EhsanFakhraie/src/vote/Main.java @@ -13,7 +13,11 @@ public static void main(String[] args) { Person person=new Person(sc.nextLine(),sc.nextLine()); ArrayList votes=new ArrayList<>(); - votes.add("1"); + votes.add("1"); + votes.add("1"); + votes.add("1"); + votes.add("1"); + votes.add("2"); votingSystem.vote(0,person,votes); votingSystem.getVoting(0).printResult(); diff --git a/EhsanFakhraie/src/vote/Vote.java b/EhsanFakhraie/src/vote/Vote.java index f1c54de..5425e67 100644 --- a/EhsanFakhraie/src/vote/Vote.java +++ b/EhsanFakhraie/src/vote/Vote.java @@ -13,6 +13,8 @@ public Vote(Person person, String date) { this.date = date; } + + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/EhsanFakhraie/src/vote/Voting.java b/EhsanFakhraie/src/vote/Voting.java index afa8740..ab1a2ec 100644 --- a/EhsanFakhraie/src/vote/Voting.java +++ b/EhsanFakhraie/src/vote/Voting.java @@ -31,23 +31,34 @@ public void createChoice(String choice) { } public String getNowData() { - TimeZone tz = TimeZone.getTimeZone("GMT+9:00"); - Locale loc = new Locale("ja", "JP", "JP"); - Calendar calendar = Calendar.getInstance(loc); - GregorianCalendar gc = (GregorianCalendar) calendar; - JalaliCalendar jc = new JalaliCalendar(gc); - return jc.toString(); + JalaliCalendar jalaliDate = new JalaliCalendar(new GregorianCalendar(2016, 4, 16)); + return jalaliDate.toString(); } public void vote(Person p, ArrayList votes) { - for (String v : votes) { + if(type==0){ + for (String v : votes) { + if (choices.contains(v)) { + Vote vote = new Vote(p, getNowData()); + HashSet vs = polls.get(v); + vs.add(vote); + polls.replace(v, vs); + }else { + System.out.println("wrong vote"); + } + } + }else{ + String v=votes.get(0); if (choices.contains(v)) { Vote vote = new Vote(p, getNowData()); HashSet vs = polls.get(v); vs.add(vote); polls.replace(v, vs); + }else { + System.out.println("wrong vote"); } } + } public int getType() { diff --git a/EhsanFakhraie/src/vote/VotingSystem.java b/EhsanFakhraie/src/vote/VotingSystem.java index 18dbd1e..7618908 100644 --- a/EhsanFakhraie/src/vote/VotingSystem.java +++ b/EhsanFakhraie/src/vote/VotingSystem.java @@ -7,7 +7,7 @@ public class VotingSystem { private ArrayList votingList; public VotingSystem(){ - + votingList=new ArrayList<>(); } public void createVoting(String question,int type){ From 25094f619a248142c4b5121fea302cb9e2983795 Mon Sep 17 00:00:00 2001 From: Ehsan Fakhraie Date: Fri, 24 Apr 2020 15:14:44 +0430 Subject: [PATCH 3/6] Shape v1 added --- .idea/.gitignore | 2 + .idea/misc.xml | 4 +- .idea/workspace.xml | 115 ------------------ EhsanFakhraie/src/paint/v1/Circle.java | 44 +++++++ EhsanFakhraie/src/paint/v1/Main.java | 30 +++++ EhsanFakhraie/src/paint/v1/Paint.java | 45 +++++++ EhsanFakhraie/src/paint/v1/Rectangle.java | 52 ++++++++ EhsanFakhraie/src/paint/v1/Triangle.java | 52 ++++++++ .../META-INF/workshop-2.kotlin_module | Bin 0 -> 16 bytes .../workshop-2/paint/v1/Circle.class | Bin 0 -> 1626 bytes out/production/workshop-2/paint/v1/Main.class | Bin 0 -> 1225 bytes .../workshop-2/paint/v1/Paint.class | Bin 0 -> 1995 bytes .../workshop-2/paint/v1/Rectangle.class | Bin 0 -> 1837 bytes .../workshop-2/paint/v1/Triangle.class | Bin 0 -> 1888 bytes out/production/workshop-2/vote/Main.class | Bin 0 -> 1374 bytes out/production/workshop-2/vote/Person.class | Bin 0 -> 902 bytes out/production/workshop-2/vote/Vote.class | Bin 0 -> 884 bytes out/production/workshop-2/vote/Voting.class | Bin 0 -> 3832 bytes .../workshop-2/vote/VotingSystem.class | Bin 0 -> 1957 bytes 19 files changed, 227 insertions(+), 117 deletions(-) create mode 100644 .idea/.gitignore delete mode 100644 .idea/workspace.xml create mode 100644 EhsanFakhraie/src/paint/v1/Circle.java create mode 100644 EhsanFakhraie/src/paint/v1/Main.java create mode 100644 EhsanFakhraie/src/paint/v1/Paint.java create mode 100644 EhsanFakhraie/src/paint/v1/Rectangle.java create mode 100644 EhsanFakhraie/src/paint/v1/Triangle.java create mode 100644 out/production/workshop-2/META-INF/workshop-2.kotlin_module create mode 100644 out/production/workshop-2/paint/v1/Circle.class create mode 100644 out/production/workshop-2/paint/v1/Main.class create mode 100644 out/production/workshop-2/paint/v1/Paint.class create mode 100644 out/production/workshop-2/paint/v1/Rectangle.class create mode 100644 out/production/workshop-2/paint/v1/Triangle.class create mode 100644 out/production/workshop-2/vote/Main.class create mode 100644 out/production/workshop-2/vote/Person.class create mode 100644 out/production/workshop-2/vote/Vote.class create mode 100644 out/production/workshop-2/vote/Voting.class create mode 100644 out/production/workshop-2/vote/VotingSystem.class diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..e7e9d11 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml diff --git a/.idea/misc.xml b/.idea/misc.xml index e140ea0..fa53a49 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,7 +3,7 @@ - - + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml deleted file mode 100644 index ce4a2cb..0000000 --- a/.idea/workspace.xml +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1587715853663 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/EhsanFakhraie/src/paint/v1/Circle.java b/EhsanFakhraie/src/paint/v1/Circle.java new file mode 100644 index 0000000..f7fa119 --- /dev/null +++ b/EhsanFakhraie/src/paint/v1/Circle.java @@ -0,0 +1,44 @@ +package paint.v1; + +public class Circle { + private int radius; + + public Circle(int radius) { + this.radius = radius; + } + + public int getRadius() { + return radius; + } + public double calculatePerimeter(){ + return 2*Math.PI*radius; + } + public double calculateArea(){ + return Math.PI*radius*radius; + } + public void draw(){ + System.out.println("Circle ,"+calculatePerimeter()+","+calculateArea()); + } + + @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 radius; + } + + @Override + public String toString() { + return "Circle{" + + "radius=" + radius + + '}'; + } +} diff --git a/EhsanFakhraie/src/paint/v1/Main.java b/EhsanFakhraie/src/paint/v1/Main.java new file mode 100644 index 0000000..5f7b1f7 --- /dev/null +++ b/EhsanFakhraie/src/paint/v1/Main.java @@ -0,0 +1,30 @@ +package paint.v1; + +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 t1=new Triangle(2,2,2); + Triangle t2=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(t1); + paint.addTriangle(t2); + + paint.drawAll(); + paint.printAll(); + } +} diff --git a/EhsanFakhraie/src/paint/v1/Paint.java b/EhsanFakhraie/src/paint/v1/Paint.java new file mode 100644 index 0000000..46ae363 --- /dev/null +++ b/EhsanFakhraie/src/paint/v1/Paint.java @@ -0,0 +1,45 @@ +package paint.v1; + +import java.util.ArrayList; +import java.util.List; + +public class Paint { + public ArrayList rectangles; + public ArrayList triangles; + public ArrayList circles; + + public Paint() { + rectangles=new ArrayList<>(); + circles=new ArrayList<>(); + triangles=new ArrayList<>(); + } + + public void drawAll(){ + for (Triangle t:triangles) + t.draw(); + for (Rectangle t:rectangles) + t.draw(); + for (Circle t:circles) + t.draw(); + } + + public void printAll(){ + for (Triangle t:triangles) + System.out.println(t); + for (Rectangle t:rectangles) + System.out.println(t); + for (Circle t:circles) + System.out.println(t); + } + + public void addCircle(Circle c){ + circles.add(c); + } + + public void addTriangle(Triangle c){ + triangles.add(c); + } + public void addRectangle(Rectangle c){ + rectangles.add(c); + } +} diff --git a/EhsanFakhraie/src/paint/v1/Rectangle.java b/EhsanFakhraie/src/paint/v1/Rectangle.java new file mode 100644 index 0000000..650de57 --- /dev/null +++ b/EhsanFakhraie/src/paint/v1/Rectangle.java @@ -0,0 +1,52 @@ +package paint.v1; + +import java.util.Arrays; + +public class Rectangle { + double[] sides; + + public Rectangle(double s1,double s2,double s3,double s4) { + this.sides = new double[4]; + sides[0]=s1; + sides[1]=s2; + sides[2]=s3; + sides[3]=s4; + } + + public double[] getSides() { + return sides; + } + + public double calculatePerimeter(){ + double perimeter=0; + for(double side:sides) + perimeter+=side; + return perimeter; + } + public double calculateArea(){ + + return sides[0]*sides[1]; + } + public void draw(){ + System.out.println("Rectangle ,"+calculatePerimeter()+","+calculateArea()); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Rectangle rectangle = (Rectangle) o; + for (int i = 0; i < 3; i++) { + if(sides[i]!=rectangle.getSides()[i]) + return false; + } + return true; + } + @Override + public String toString() { + return "Rectangle{" + + "sides=" + Arrays.toString(sides) + + '}'; + } + +} diff --git a/EhsanFakhraie/src/paint/v1/Triangle.java b/EhsanFakhraie/src/paint/v1/Triangle.java new file mode 100644 index 0000000..c3c0b26 --- /dev/null +++ b/EhsanFakhraie/src/paint/v1/Triangle.java @@ -0,0 +1,52 @@ +package paint.v1; + +import java.util.Arrays; + +public class Triangle { + private double[] sides; + + public Triangle(double s1,double s2,double s3) { + this.sides = new double[3]; + sides[0]=s1; + sides[1]=s2; + sides[2]=s3; + } + + public double[] getSides() { + return sides; + } + + public double calculatePerimeter(){ + double perimeter=0; + for(double side:sides) + perimeter+=side; + return perimeter; + } + public double calculateArea(){ + double p=calculatePerimeter(); + return Math.sqrt(p*(p-sides[0])*(p-sides[1])*(p-sides[2])); + } + public void draw(){ + System.out.println("Triangle ,"+calculatePerimeter()+","+calculateArea()); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Triangle triangle = (Triangle) o; + for (int i = 0; i < 3; i++) { + if(sides[i]!=triangle.getSides()[i]) + return false; + } + + return true; + } + @Override + public String toString() { + return "Triangle{" + + "sides=" + Arrays.toString(sides) + + '}'; + } +} diff --git a/out/production/workshop-2/META-INF/workshop-2.kotlin_module b/out/production/workshop-2/META-INF/workshop-2.kotlin_module new file mode 100644 index 0000000000000000000000000000000000000000..a49347afef10a9b5f95305e1058ba36adec7d6dd GIT binary patch literal 16 RcmZQzU|?ooU|@t|0RRA102TlM literal 0 HcmV?d00001 diff --git a/out/production/workshop-2/paint/v1/Circle.class b/out/production/workshop-2/paint/v1/Circle.class new file mode 100644 index 0000000000000000000000000000000000000000..3597d1f98c0f064d9048c6d97879cd70d6689109 GIT binary patch literal 1626 zcma)5TW=dh7(L_Lt~VRkahx_KE~J#p+D_`Wq+FV|q;&{{I&E5~t=hMVy-K#-*k-dX zLWpM`_!GPUFOj&2x)Ml;Cm#4qAjFxSt>dJ$!jfmd%gj07cfOfF|M}%N01LQlVH)SN zDB^7c?_`#apZsfMd44*xl+{KS@8UfJ7c69P-o&E%UbMLVlCmzFcwae7%DH0UD(VVv z*}w-TR#fmqwR~h?RUi|{w%6Yk5X!meb-eJhK+0Jy-{Gg;ZMyp&JM=wJb0`OkD|F$tv1`{4`3kq>TGXU;3n(avBfhBU$rhXRCH&^MTt67t8nA zM^}~iOo}I4Q8mPGhO+f=P4=R?sfvKPEqAwdvu4r^9Tt*+c*_Zivixt+Ga{OAB;ah}yH?v4jb&hm@WlTmF4=>&|PBKJFo z=KYk8J(;{(bzkoCN=zP@R}_qRS6{?ia_Y}d<0RkFG~c8^Ld}(yNqYt*t|#cNFrMJo zsyuFjaeeApB15U!gv*@V$2%9g1L0%XC(G$ zXt+!i9E)IVy&;AX>Z&lJ3R)nYI&2k@Qs=*X`28V-+z5g-MBw#`5iZ0C`64nJ;lFVv zMsV^&oHyabICo>5@=q{-MfTnkScS0x?8*S+1LO)vw4J9tz{CKBedVl3r6QrGMo7v- zk}@hW$yeN|R6bp)ev5Q!ulfgaB$%x7{|(Z~z3T5MuBis*`2QM4>N}*8O4MXDqXLTr zXJBx))12xFM%A2VHEPUAd{i+PaZX^Kvr8}nj3aI2#NU`SP+L+%JM;gBcxt4p^sp;F r?ubF(Dnb0xQ{ASNR%~E^qxmleI7Y#KV1D#sI3t*)A?91ru7!UA^pP#m literal 0 HcmV?d00001 diff --git a/out/production/workshop-2/paint/v1/Main.class b/out/production/workshop-2/paint/v1/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..d5b13bc5fec882068e464271935dc821e0a6edb2 GIT binary patch literal 1225 zcmZuwOHUI~7(KU-nYIqk4v#7-zRR=nP@$lfhbY)05kf*VF+*E%NGUKDOmySQl?xMh zu5_mh7i!WbHt`4eqm1X9>BEJS>36?-zBAwB+}q!Oe*OY5iPZ>BVp7Mo2zcW!9Zu&(Sfhr97A1RwQ-IM9_&zF|%TBin%4`wwRQTIUVx~+N@o) zOScsK@qtZ+z`}kmuh5pZi}}@~z3sfSVQm+Pbf)*SR$*}xL+8n}mL z11q?1AdNl)8L8RQU`jV^x+(L6?Om$CGl(yX)Ovi8k9eAR;)JbS&TEz8#hc^SG!}|M zN~3Lso_|;k*geS;B-W>p18-)lqb^O)Io6B0LO~&Pz*|tFi*tzazRTl-5-Dj>AG1h(2t z1m#zOzAAeYArleL5=#a=&@fSZ1q@cvN+!RPw}OtO<{?35B2y5(iq5SHqRCJ!G*pHe z3k|z=q>QduC>H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tEo zo?Fh(*X#CO2Byu;f5GBoT=;K{nBc`5;58O}*ki6b?LiE2eTr|N@Gf?7x2%T{mj0vu z9U|7Zh(t5%a#OPYrVgq8t_|tyUo$#_r@0G|$I*u_PjfHVqQU7d$RuFfBmPE+e2odJFOZ2M5^A(MtxaJ=o^NSckKv+b`k>rV_ z_c6i6xSNS3`T6S9<5?v-tESYHavuXzDYbB3%M59yrF*LQ;>mBBFBu#4$)$ZjDOO9f z#vs9_nRUpoH_n)0`ZENp$?Rd}2qR3M3DTExN1jjxRfiSTkrO2GI}-_cM?!e#2v2fL z_>vcV#S6D3h=U|Y4vpKMp4WVT%-k7vUok61)u#GI9T09Dz`{Y=y?ByxN{hZ^0>{e<3?=-jAw zAH$N!XkoI2zR|*`pGoh%DE0kS*<*%4-xGdcPO{mjsOo8sM}{poIWSq?{tW-olg0qYk^iAM7t`T4LK4^ME{K*xTNdLhu3Hf^zvRGl16nt!7r(;qZ iqJ4xUt-g<1=%+@VF$)CBqmM##1R84#bdJd)IR7_Kvr(V` literal 0 HcmV?d00001 diff --git a/out/production/workshop-2/paint/v1/Triangle.class b/out/production/workshop-2/paint/v1/Triangle.class new file mode 100644 index 0000000000000000000000000000000000000000..6c5241313b4c19809ca0b8ea8a7b2dd864f45579 GIT binary patch literal 1888 zcmZ`)U2{`a6kR9D%}v8?2x*fRN+}fDe6%G5u!t?y(uhUdQb{dBMZHb#lnZGRk{cYx z(I@_ZPmZt5s4t!IV>B@8Fh2R<5Anr6;5ehW_Pq%yRv+#;`|NYhUTd$tPx9;EKRf|& z7Ns!anCU?jvtbSw!kEL$J$ME4IxdD0#7qbaGUsJ@HH1rY>@`^|hH)9M%l$WWEQxzL zgq1L^U{$u?)NxfoYuF{Lq2SxdD+FilitWtNNageS^twV|p<1#O_Al8LYo)opY1P-v z%`!c)rE1YEubXvS)@^6Nxn(m}-%`!AD^B)aF1yD4%2wH$AwnakporpYoR;B?LTJl! z3LbtSl@xqW-Tc6f#H51O-KJS4(Rga0O6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$zW9|lgVW|Os3xVVBkedi*TTqVY z8W`YT6N5V~3{g&K*)!?k(BY&1>|yrD-1C!!K4POcFv@J*V7AK`q}5N~0KJH0;ugdd z*^+cxMF?9MMiyZlVgz3>3XQ}llL&Q+&oO1Q7g0~-w&7PcI0EB{cL zM-Cn<|HQ^q8%>7dCz+121AZzP{O$=q=bebh!_Hxr%6Rya!HM`RUw9>BnZ03X2Fo{> zBdsF_YcCm4=W18R;$VE*6X^%ui!@f!=g|>Qr8-Z8R`ywr7|PxABom$YA{`|$QSgQ$ z+rOf@9<-Lh7)o@jJLl?TNiKoGJxs=FU+hbTTgtmWS4ut95O^q~;-QKPLw!;I+p&xW zBBjyfWnbpgdfoKULa59RF>E(xV^WE`*dU~9A{c5{t>5)dL_cFN12v%nKRXlgfZ^GS zp)L!ZGNP$$27CWcW1D_}N8iGrMFRDXG?KSKY;c3DPp4zbo8+tEC0Mv~0V8Z*!2GTY zZj$w>0I}cY literal 0 HcmV?d00001 diff --git a/out/production/workshop-2/vote/Vote.class b/out/production/workshop-2/vote/Vote.class new file mode 100644 index 0000000000000000000000000000000000000000..97fa825aa78033d0f7aaa3dcb02c11b30a4ecffe GIT binary patch literal 884 zcmZuvNpI6Y7=2?qaTYh}lC%X{y0FwsXf9k(5tm9xl~OH5Fc>2T71e9TGJRyYivP2P5c(M!J@so8PQk2?M+lztX8l0i5YD5rxvl87 z=^Zhz^Q^jGAzbeqn%g*s{z)~=(=NiGEz`=K$i@m57}-qQm|vpD0SZQ_n*`DbP(wX~ zd7r^JuJ;i+W9t1v#r*=qF&d5PGD|{@tiCY<$N7SNt8sA|a=@PVkfr3QT6k=Yb*A$ACmS!jd IYpQDfFaPSMlmGw# literal 0 HcmV?d00001 diff --git a/out/production/workshop-2/vote/Voting.class b/out/production/workshop-2/vote/Voting.class new file mode 100644 index 0000000000000000000000000000000000000000..a101f26f1f1d6d423cc09cf78f7e454567852865 GIT binary patch literal 3832 zcmai0X?GiE6@EtBSkh#3Vkb_MR86zk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ep!05xrUzby-B-oVZ2xWS(r^<`anhmT zeRK|l#K*2s6}xZZ;TrZ#_a>|8TE*UhusAIz_q~t!K%^_u6|Q2R3Po3_D^kV&i_3`L z!h!btt4J*W=gnn|^#!YVfUsFX?N^}3TR=r!ga-;U+!Ypl53^t3TOcLKAr*iuc5;4{ z4s|n?J?KM{9O|XpeHcSOF5?)kkb$%0-U3s*$Z$W;H_}UF-fLvu8#sZt$-7&;b%)`3 zlxUZkvH={#Ib>7-cVQG+(kQ_cJ;D1S-cG2~5HWVD(=d@o)TwZ^)<|%TR$O2LWN)0P z0Zec%q&rJej$)Fy9>yefc~XOvdXn=4(C@*}F?A2)IxgOYeiwnjJ&bsZdfhxl^l4n; zC{>c;Q?yBn0&j8R@g$-)Pbv2dPoQq1hEFz_*L*p+PBQQEY2VA2@hOj1Et(@6FQe;a_!pxqvAiOTs^Z{nJg6blTW9!rP87orjrQHf zVa4?Zrj*G^QYJ|P&X7Doo*toGmU{^d!onPVr?K^X2tA}rcv6!MDVuvjia5xCEhNQV YGAn?2ZUu0S{FY{*v8{avpNT~O3k)5FnE(I) literal 0 HcmV?d00001 diff --git a/out/production/workshop-2/vote/VotingSystem.class b/out/production/workshop-2/vote/VotingSystem.class new file mode 100644 index 0000000000000000000000000000000000000000..44e44eba4c761bbbb5c7505595e81d35fbb114c9 GIT binary patch literal 1957 zcma)7*>W3I5It9m#~O`eOG#wFAse=lWG5o*M8;$XfxLi>gTp$O2WNsZV@4wre+pl~ zD^NkMkSdC2K7@~;sKDvDV@Y=OkW$s1yL6vEr@QafUr&Dj1HkL}#zYQP0}Cb+sAe#M zcMU9>NaH=(xgx_=8Lnk<9XDjSnZYf*Z{h>gOxk}a#vd7|8(2~>cm2@yw(D*?R5)3` zXYbmTPUyBOSA)RblkKWPrr~aTcGw9Vh3R273w6RcmGua#x=5Fi1=n-KMTKOsw62i4 z?r+g~yzY9=a_9c06Rg>rE$-y&e$#HP+kq?Vcrz8=b=wNZ2T>b)?a;YTWUCoCcIfC> z3WcI3)Uv(pN+S#?rdpGbqu+O&cIf(^1c`JFnvhbsw?hJ|rZBecgc?uhVX{~nrjo&D zho3yHKhuL$m?+jtgHni-cD*g<0h#TPa41n%zSRtqu3uS|#^il+Y`Jtgy@$6MH0r<>Z`e>_EZ$7DHQvB`5{t|k=~d)wU3c5jN5%gc}xX2M?670t36^g z`r-`tgjJq8&eK}qB~0@xj4NEpSz03e%t-=5b0l`?(@V#ITKEjl*?1fUMA8j{ zMv@q*Oi9NW?P$)=(*0a7gw#=2P-d^hvM%9O;s~NoL?M_PNYea;F2?%`bSbCVY%>vT rSv&M#b1^JI@EZSYg Date: Fri, 24 Apr 2020 15:47:27 +0430 Subject: [PATCH 4/6] V2 --- EhsanFakhraie/src/paint/v2/Polygon.java | 25 ++++++++++++++++++ EhsanFakhraie/src/paint/v2/Rectangle.java | 32 +++++++++++++++++++++++ EhsanFakhraie/src/paint/v2/Shape.java | 12 +++++++++ EhsanFakhraie/src/paint/v2/Triangle.java | 4 +++ 4 files changed, 73 insertions(+) create mode 100644 EhsanFakhraie/src/paint/v2/Polygon.java create mode 100644 EhsanFakhraie/src/paint/v2/Rectangle.java create mode 100644 EhsanFakhraie/src/paint/v2/Shape.java create mode 100644 EhsanFakhraie/src/paint/v2/Triangle.java diff --git a/EhsanFakhraie/src/paint/v2/Polygon.java b/EhsanFakhraie/src/paint/v2/Polygon.java new file mode 100644 index 0000000..24a8b57 --- /dev/null +++ b/EhsanFakhraie/src/paint/v2/Polygon.java @@ -0,0 +1,25 @@ +package paint.v2; + +import java.util.ArrayList; +import java.util.Arrays; + +public abstract class Polygon extends Shape { + public ArrayList getSides() { + return sides; + } + + private ArrayList sides = new ArrayList<>(); + + public Polygon(Double... args) { + sides.addAll(Arrays.asList(args)); + } + + @Override + public double calculatePerimeter(Shape shape) { + Polygon p=(Polygon) shape; + double perimeter=0; + for(Double d:sides) + perimeter+=d; + return perimeter; + } +} diff --git a/EhsanFakhraie/src/paint/v2/Rectangle.java b/EhsanFakhraie/src/paint/v2/Rectangle.java new file mode 100644 index 0000000..0c8edb7 --- /dev/null +++ b/EhsanFakhraie/src/paint/v2/Rectangle.java @@ -0,0 +1,32 @@ +package paint.v2; + +import java.lang.reflect.Array; +import java.util.Arrays; + +public class Rectangle extends Polygon { + + public Rectangle(double a, double b) { + super(a, b); + } + + public boolean isSquare(Object o) { + return getSides().get(0).equals(getSides().get(1)); + } + + @Override + public double calculateArea(Shape shape) { + return this.getSides().get(0) * this.getSides().get(1); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + return ((Rectangle) o).getSides().equals(this.getSides()); + } + + @Override + public String toString() { + return "Rectangle{"+ Arrays.toString(getSides().toArray()) +"}"; + } +} \ No newline at end of file diff --git a/EhsanFakhraie/src/paint/v2/Shape.java b/EhsanFakhraie/src/paint/v2/Shape.java new file mode 100644 index 0000000..75c1488 --- /dev/null +++ b/EhsanFakhraie/src/paint/v2/Shape.java @@ -0,0 +1,12 @@ +package paint.v2; + +public abstract class Shape { + + public abstract double calculatePerimeter(Shape shape); + + public abstract double calculateArea(Shape shape); + + public abstract boolean equals(Object o); + + public abstract String toString(); +} \ No newline at end of file diff --git a/EhsanFakhraie/src/paint/v2/Triangle.java b/EhsanFakhraie/src/paint/v2/Triangle.java new file mode 100644 index 0000000..5e88a2f --- /dev/null +++ b/EhsanFakhraie/src/paint/v2/Triangle.java @@ -0,0 +1,4 @@ +package paint.v2; + +public class Triangle { +} From f3cb679ee0ea0826e126df2a1ce0b7b6ae12d5e6 Mon Sep 17 00:00:00 2001 From: Ehsan Fakhraie Date: Fri, 24 Apr 2020 19:37:55 +0430 Subject: [PATCH 5/6] 5 completed --- EhsanFakhraie/src/paint/v2/Circle.java | 46 ++++++++++++++++++++++ EhsanFakhraie/src/paint/v2/Main.java | 34 ++++++++++++++++ EhsanFakhraie/src/paint/v2/Paint.java | 48 +++++++++++++++++++++++ EhsanFakhraie/src/paint/v2/Polygon.java | 4 +- EhsanFakhraie/src/paint/v2/Rectangle.java | 9 ++++- EhsanFakhraie/src/paint/v2/Shape.java | 10 ++++- EhsanFakhraie/src/paint/v2/Triangle.java | 33 +++++++++++++++- 7 files changed, 177 insertions(+), 7 deletions(-) create mode 100644 EhsanFakhraie/src/paint/v2/Circle.java create mode 100644 EhsanFakhraie/src/paint/v2/Main.java create mode 100644 EhsanFakhraie/src/paint/v2/Paint.java diff --git a/EhsanFakhraie/src/paint/v2/Circle.java b/EhsanFakhraie/src/paint/v2/Circle.java new file mode 100644 index 0000000..8d9908d --- /dev/null +++ b/EhsanFakhraie/src/paint/v2/Circle.java @@ -0,0 +1,46 @@ +package paint.v2; + +public class Circle extends Shape { + private double radius; + + public Circle(double radius) { + this.radius = radius; + } + + public double getRadius() { + return radius; + } + + @Override + public double calculatePerimeter() { + return 2*Math.PI*radius; + } + + @Override + public double calculateArea() { + return Math.PI*radius*radius; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + Circle circle = (Circle) o; + + return Double.compare(circle.radius, radius) == 0; + } + + + @Override + public String toString() { + return "Circle{" + + "radius=" + radius + + '}'; + } + + @Override + public String type() { + return "Circle"; + } +} diff --git a/EhsanFakhraie/src/paint/v2/Main.java b/EhsanFakhraie/src/paint/v2/Main.java new file mode 100644 index 0000000..b120a2d --- /dev/null +++ b/EhsanFakhraie/src/paint/v2/Main.java @@ -0,0 +1,34 @@ +package paint.v2; + +public class Main { + public static void main(String[] args) { + Circle circle1=new Circle(9); + Circle circle2=new Circle(9); + Circle circle3=new Circle(9); + Circle circle4=new Circle(9); + + Rectangle rectangle=new Rectangle(10,10); + Rectangle rectangle2=new Rectangle(10,10); + Rectangle rectangle3=new Rectangle(10,10); + + Triangle triangle=new Triangle(10,2,9); + Triangle triangle2=new Triangle(10,2,9); + Triangle triangle3=new Triangle(10,2,9); + + Paint p=new Paint(); + p.addCircle(circle1); + p.addCircle(circle2); + p.addCircle(circle3); + + p.addRectangle(rectangle); + p.addRectangle(rectangle2); + p.addRectangle(rectangle3); + + p.addTriangle(triangle); + p.addTriangle(triangle2); + p.addTriangle(triangle3); + + p.printAll(); + p.drawAll(); + } +} diff --git a/EhsanFakhraie/src/paint/v2/Paint.java b/EhsanFakhraie/src/paint/v2/Paint.java new file mode 100644 index 0000000..2a38a09 --- /dev/null +++ b/EhsanFakhraie/src/paint/v2/Paint.java @@ -0,0 +1,48 @@ +package paint.v2; + +import paint.v2.Circle; +import paint.v2.Rectangle; +import paint.v2.Triangle; + +import java.util.ArrayList; + +public class Paint { + public ArrayList rectangles; + public ArrayList triangles; + public ArrayList circles; + + public Paint() { + rectangles=new ArrayList<>(); + circles=new ArrayList<>(); + triangles=new ArrayList<>(); + } + + public void drawAll(){ + for (Triangle t:triangles) + t.draw(); + for (Rectangle t:rectangles) + t.draw(); + for (Circle t:circles) + t.draw(); + } + + public void printAll(){ + for (Triangle t:triangles) + System.out.println(t); + for (Rectangle t:rectangles) + System.out.println(t); + for (Circle t:circles) + System.out.println(t); + } + + public void addCircle(Circle c){ + circles.add(c); + } + + public void addTriangle(Triangle c){ + triangles.add(c); + } + public void addRectangle(Rectangle c){ + rectangles.add(c); + } +} diff --git a/EhsanFakhraie/src/paint/v2/Polygon.java b/EhsanFakhraie/src/paint/v2/Polygon.java index 24a8b57..d5e80d3 100644 --- a/EhsanFakhraie/src/paint/v2/Polygon.java +++ b/EhsanFakhraie/src/paint/v2/Polygon.java @@ -15,8 +15,8 @@ public Polygon(Double... args) { } @Override - public double calculatePerimeter(Shape shape) { - Polygon p=(Polygon) shape; + public double calculatePerimeter() { + Polygon p=(Polygon) this; double perimeter=0; for(Double d:sides) perimeter+=d; diff --git a/EhsanFakhraie/src/paint/v2/Rectangle.java b/EhsanFakhraie/src/paint/v2/Rectangle.java index 0c8edb7..cb0fa74 100644 --- a/EhsanFakhraie/src/paint/v2/Rectangle.java +++ b/EhsanFakhraie/src/paint/v2/Rectangle.java @@ -14,8 +14,8 @@ public boolean isSquare(Object o) { } @Override - public double calculateArea(Shape shape) { - return this.getSides().get(0) * this.getSides().get(1); + public double calculateArea() { + return 2*(this.getSides().get(0) * this.getSides().get(1)); } @Override @@ -29,4 +29,9 @@ public boolean equals(Object o) { public String toString() { return "Rectangle{"+ Arrays.toString(getSides().toArray()) +"}"; } + + @Override + public String type() { + return "Rectangle"; + } } \ No newline at end of file diff --git a/EhsanFakhraie/src/paint/v2/Shape.java b/EhsanFakhraie/src/paint/v2/Shape.java index 75c1488..d973532 100644 --- a/EhsanFakhraie/src/paint/v2/Shape.java +++ b/EhsanFakhraie/src/paint/v2/Shape.java @@ -2,11 +2,17 @@ public abstract class Shape { - public abstract double calculatePerimeter(Shape shape); + public abstract double calculatePerimeter(); - public abstract double calculateArea(Shape shape); + public abstract double calculateArea(); public abstract boolean equals(Object o); public abstract String toString(); + + public abstract String type(); + + public void draw(){ + System.out.println(type()+" Perimeter"+calculatePerimeter()+" Area"+calculateArea()); + } } \ No newline at end of file diff --git a/EhsanFakhraie/src/paint/v2/Triangle.java b/EhsanFakhraie/src/paint/v2/Triangle.java index 5e88a2f..a441df5 100644 --- a/EhsanFakhraie/src/paint/v2/Triangle.java +++ b/EhsanFakhraie/src/paint/v2/Triangle.java @@ -1,4 +1,35 @@ package paint.v2; -public class Triangle { +import java.util.ArrayList; +import java.util.Arrays; + +public class Triangle extends Polygon { + public Triangle(double a, double b, double c) { + super(a, b, c); + } + + @Override + public double calculateArea() { + Triangle triangle = (Triangle) this; + double p = this.calculatePerimeter(); + ArrayList sides = getSides(); + return Math.sqrt(p * (p - sides.get(0)) * (p - sides.get(1)) * (p - sides.get(2))); + } + + @Override + public boolean equals(Object o) { + Triangle t = (Triangle) o; + return this.getSides() == t.getSides(); + } + + + @Override + public String toString() { + return "Triangle{" + Arrays.toString(getSides().toArray()) + "}"; + } + + @Override + public String type() { + return "Triangle"; + } } From cefc5c9dfbe930cb443df3401a88bde522bb6bab Mon Sep 17 00:00:00 2001 From: Ehsan Fakhraie Date: Fri, 24 Apr 2020 19:39:13 +0430 Subject: [PATCH 6/6] removed out folder --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6a3417b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/out/