From 70a46c5e374be3016d2aa34f2b60db6dc7fddbcd Mon Sep 17 00:00:00 2001 From: Leenahessam Date: Sun, 1 Mar 2020 15:55:04 +0200 Subject: [PATCH 01/13] adding multiplication series class 20170204 --- src/Main.java | 28 +++++++++++++++------------- src/MultiplicationSeries.java | 31 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 13 deletions(-) create mode 100644 src/MultiplicationSeries.java diff --git a/src/Main.java b/src/Main.java index 9b8c2b0..3d181ae 100644 --- a/src/Main.java +++ b/src/Main.java @@ -1,17 +1,19 @@ +package com.company; import java.util.Scanner; public class Main { - private static ISubscriber subscribers [] = { - new SimpleSubscriber(), - new ReallySimpleSubscriber(), - }; - public static void main(String[] args) { - Topic mathTopic = new Topic(); - for (ISubscriber sub : subscribers) { - mathTopic.addSubscriber(sub); - } - Scanner sc = new Scanner(System.in); - String input = sc.next(); - mathTopic.dispatchEvent(input); - } + private static ISubscriber subscribers [] = { + new SimpleSubscriber(), + new ReallySimpleSubscriber(), + new MultiplicationSeries() + }; + public static void main(String[] args) { + Topic mathTopic = new Topic(); + for (ISubscriber sub : subscribers) { + mathTopic.addSubscriber(sub); + } + Scanner sc = new Scanner(System.in); + String input = sc.next(); + mathTopic.dispatchEvent(input); + } } diff --git a/src/MultiplicationSeries.java b/src/MultiplicationSeries.java new file mode 100644 index 0000000..98f058e --- /dev/null +++ b/src/MultiplicationSeries.java @@ -0,0 +1,31 @@ +package com.company; + + +public class MultiplicationSeries implements ISubscriber { + private int count; + private int product = 1; + @Override + public void notifySubscriber(String input) { + count = Integer.parseInt(input); + try { + System.out.println(MultSeries(count)); + } + catch (NumberFormatException e) { + System.out.println(e.getMessage()); + } + + } + int MultSeries (int num) + { + int number = 1; + for (int i=0; i Date: Sun, 1 Mar 2020 18:50:36 +0200 Subject: [PATCH 02/13] aading lucasSeries class --- src/LucasSeries.java | 32 ++++++++++++++++++++++++++++++++ src/Main.java | 3 ++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/LucasSeries.java diff --git a/src/LucasSeries.java b/src/LucasSeries.java new file mode 100644 index 0000000..3262d08 --- /dev/null +++ b/src/LucasSeries.java @@ -0,0 +1,32 @@ +package com.company; + +public class LucasSeries implements ISubscriber{ + + @Override + public void notifySubscriber(String input) { + try { + int n = Integer.parseInt(input); + for(int i=1;i<=n;i++) + { + System.out.println(printSeries(i)); + } + } catch (NumberFormatException e) { + System.out.println("Enter a valid input"); + } + + + + } + public int printSeries(int input) + { + if(input==1||input==0) + { + return 2; + } + if(input==2) + { + return 1; + } + return printSeries(input-1)+printSeries(input-2); + } +} diff --git a/src/Main.java b/src/Main.java index 3d181ae..2070b0e 100644 --- a/src/Main.java +++ b/src/Main.java @@ -5,7 +5,8 @@ public class Main { private static ISubscriber subscribers [] = { new SimpleSubscriber(), new ReallySimpleSubscriber(), - new MultiplicationSeries() + new MultiplicationSeries(), + new LucasSeries() }; public static void main(String[] args) { Topic mathTopic = new Topic(); From 35cd69d8644ef594fb51ff3fefccacaf9d112de1 Mon Sep 17 00:00:00 2001 From: Lubna Hassan Date: Sun, 1 Mar 2020 22:51:45 +0200 Subject: [PATCH 03/13] https://github.com/Leenahessam/git_assignment_initial/tree/SphereVolume20170202 --- .idea/.gitignore | 3 +++ .idea/.name | 1 + .idea/misc.xml | 6 ++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ GitAssignmentObserver.iml | 12 ++++++++++++ src/Main.java | 6 +++--- src/SphereVolume.java | 10 ++++++++++ 8 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/.name create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 GitAssignmentObserver.iml create mode 100644 src/SphereVolume.java diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..0e40fe8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ + +# Default ignored files +/workspace.xml \ No newline at end of file diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..477e576 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +GitAssignmentObserver \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..ba93b15 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..3dd0b66 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ 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/GitAssignmentObserver.iml b/GitAssignmentObserver.iml new file mode 100644 index 0000000..409f5aa --- /dev/null +++ b/GitAssignmentObserver.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Main.java b/src/Main.java index 2070b0e..426d84c 100644 --- a/src/Main.java +++ b/src/Main.java @@ -1,4 +1,3 @@ -package com.company; import java.util.Scanner; public class Main { @@ -6,7 +5,8 @@ public class Main { new SimpleSubscriber(), new ReallySimpleSubscriber(), new MultiplicationSeries(), - new LucasSeries() + new LucasSeries(), + new SphereVolume() }; public static void main(String[] args) { Topic mathTopic = new Topic(); @@ -17,4 +17,4 @@ public static void main(String[] args) { String input = sc.next(); mathTopic.dispatchEvent(input); } -} +} \ No newline at end of file diff --git a/src/SphereVolume.java b/src/SphereVolume.java new file mode 100644 index 0000000..de06906 --- /dev/null +++ b/src/SphereVolume.java @@ -0,0 +1,10 @@ +public class SphereVolume implements ISubscriber +{ + @Override + public void notifySubscriber(String radius) + { + double Result =0.0; + Result = (Math.pow(Double.parseDouble(radius),3)*4/3*Math.PI); // pi = 22/7 + System.out.println("The Sphere Volume --> "+Result); + } +} From 65191f99a065bfcdb7ea2a34627f2ac5d4ed3529 Mon Sep 17 00:00:00 2001 From: seifalaa Date: Sun, 1 Mar 2020 23:34:42 +0200 Subject: [PATCH 04/13] removing unneeded folder --- .idea/.gitignore | 3 --- .idea/.name | 1 - .idea/misc.xml | 6 ------ .idea/modules.xml | 8 -------- .idea/vcs.xml | 6 ------ 5 files changed, 24 deletions(-) delete mode 100644 .idea/.gitignore delete mode 100644 .idea/.name delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 0e40fe8..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ - -# Default ignored files -/workspace.xml \ No newline at end of file diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index 477e576..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -GitAssignmentObserver \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index ba93b15..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 3dd0b66..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 35eb1dd..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 520f8daba2674bd97936d650f61fff9a1c8f8833 Mon Sep 17 00:00:00 2001 From: OsamaElneshwy Date: Mon, 2 Mar 2020 02:55:13 +0200 Subject: [PATCH 05/13] added class twoPowerN --- src/twoPowerN.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/twoPowerN.java diff --git a/src/twoPowerN.java b/src/twoPowerN.java new file mode 100644 index 0000000..7ce5a33 --- /dev/null +++ b/src/twoPowerN.java @@ -0,0 +1,12 @@ +public class twoPowerN implements ISubscriber +{ + @Override + public void notifySubscriber(String input) + { + Double x = Double.parseDouble(input); + Double result = Math.pow(2,x); + System.out.println("2 Power "+x+" = "+result ); + + } + +} From cca0169f93235af4b8c21e37baaf190007ef3565 Mon Sep 17 00:00:00 2001 From: seifalaa Date: Mon, 2 Mar 2020 14:10:51 +0200 Subject: [PATCH 06/13] adding an opject of the twoPowerN class in main class --- src/Main.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Main.java b/src/Main.java index 426d84c..66fa720 100644 --- a/src/Main.java +++ b/src/Main.java @@ -6,7 +6,8 @@ public class Main { new ReallySimpleSubscriber(), new MultiplicationSeries(), new LucasSeries(), - new SphereVolume() + new SphereVolume(), + new twoPowerN() }; public static void main(String[] args) { Topic mathTopic = new Topic(); @@ -17,4 +18,4 @@ public static void main(String[] args) { String input = sc.next(); mathTopic.dispatchEvent(input); } -} \ No newline at end of file +} From 0dc91f21bcfc55b4bf88333a3e49585f420855fc Mon Sep 17 00:00:00 2001 From: sara adel Date: Mon, 2 Mar 2020 15:51:38 +0200 Subject: [PATCH 07/13] ball volume --- src/BallVolume.java | 13 +++++++++++++ src/Main.java | 1 + 2 files changed, 14 insertions(+) create mode 100644 src/BallVolume.java diff --git a/src/BallVolume.java b/src/BallVolume.java new file mode 100644 index 0000000..33c90e5 --- /dev/null +++ b/src/BallVolume.java @@ -0,0 +1,13 @@ + +public class BallVolume implements ISubscriber { + + @Override + public void notifySubscriber(String input) { + + double r=Double.parseDouble(input); + double volume= (4*22*r*r*r)/(3*7); + + System.out.println("Ball Volume is:" +volume); + } + +} diff --git a/src/Main.java b/src/Main.java index 66fa720..35b00b6 100644 --- a/src/Main.java +++ b/src/Main.java @@ -7,6 +7,7 @@ public class Main { new MultiplicationSeries(), new LucasSeries(), new SphereVolume(), + new BallVolume(), new twoPowerN() }; public static void main(String[] args) { From 819f00b83051130846ae6fb41d431f567f50ad3b Mon Sep 17 00:00:00 2001 From: Leenahessam <36443583+Leenahessam@users.noreply.github.com> Date: Mon, 2 Mar 2020 17:41:47 +0200 Subject: [PATCH 08/13] update lucasSeries class --- src/LucasSeries.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/LucasSeries.java b/src/LucasSeries.java index 3262d08..1885a7e 100644 --- a/src/LucasSeries.java +++ b/src/LucasSeries.java @@ -1,4 +1,4 @@ -package com.company; + public class LucasSeries implements ISubscriber{ From e21e2fa0bca6687c9f0a5bc56fd9176d17373b97 Mon Sep 17 00:00:00 2001 From: Leenahessam <36443583+Leenahessam@users.noreply.github.com> Date: Mon, 2 Mar 2020 17:43:19 +0200 Subject: [PATCH 09/13] update MultiplicationSeries class --- src/MultiplicationSeries.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MultiplicationSeries.java b/src/MultiplicationSeries.java index 98f058e..9ae55b8 100644 --- a/src/MultiplicationSeries.java +++ b/src/MultiplicationSeries.java @@ -1,4 +1,4 @@ -package com.company; + public class MultiplicationSeries implements ISubscriber { From a9347af85d56da6702ff54b32d83645c0a643632 Mon Sep 17 00:00:00 2001 From: Mehrizz Date: Mon, 2 Mar 2020 18:58:55 +0200 Subject: [PATCH 10/13] Adding CircleCercumference class --- src/CircleCircumference.java | 12 ++++++++++++ src/Main.java | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/CircleCircumference.java diff --git a/src/CircleCircumference.java b/src/CircleCircumference.java new file mode 100644 index 0000000..17a07e7 --- /dev/null +++ b/src/CircleCircumference.java @@ -0,0 +1,12 @@ +public class CircleCircumference implements ISubscriber +{ + @Override + public void notifySubscriber(String input) + { + Double radius = Double.parseDouble(input); + Double res = 2*Math.PI*radius; + System.out.println("circleCircumference is "+res ); + + } + +} diff --git a/src/Main.java b/src/Main.java index 35b00b6..1bb4c81 100644 --- a/src/Main.java +++ b/src/Main.java @@ -8,7 +8,8 @@ public class Main { new LucasSeries(), new SphereVolume(), new BallVolume(), - new twoPowerN() + new twoPowerN(), + new CircleCircumference() }; public static void main(String[] args) { Topic mathTopic = new Topic(); From 5fcf5fc40bc5d05ea8eb00cbbf463de565015255 Mon Sep 17 00:00:00 2001 From: seifalaa Date: Mon, 2 Mar 2020 21:12:50 +0200 Subject: [PATCH 11/13] adding a user menu to the main class --- src/LucasSeries.java | 5 ++-- src/Main.java | 60 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/src/LucasSeries.java b/src/LucasSeries.java index 1885a7e..0cb54f7 100644 --- a/src/LucasSeries.java +++ b/src/LucasSeries.java @@ -1,5 +1,5 @@ - +package com.company; public class LucasSeries implements ISubscriber{ @Override @@ -8,8 +8,9 @@ public void notifySubscriber(String input) { int n = Integer.parseInt(input); for(int i=1;i<=n;i++) { - System.out.println(printSeries(i)); + System.out.print(printSeries(i)+" "); } + System.out.println(""); } catch (NumberFormatException e) { System.out.println("Enter a valid input"); } diff --git a/src/Main.java b/src/Main.java index 1bb4c81..df3f6bf 100644 --- a/src/Main.java +++ b/src/Main.java @@ -1,3 +1,5 @@ +package com.company; + import java.util.Scanner; public class Main { @@ -8,16 +10,66 @@ public class Main { new LucasSeries(), new SphereVolume(), new BallVolume(), - new twoPowerN(), - new CircleCircumference() + new twoPowerN(), + new CircleCircumference() + //please add your object here }; public static void main(String[] args) { Topic mathTopic = new Topic(); - for (ISubscriber sub : subscribers) { - mathTopic.addSubscriber(sub); + System.out.println("Enter 0 to execute all"); + System.out.println("1-SimpleSubscriber\n" + + "2-ReallySimpleSubscriber\n3-MultiplicationSeries\n4-LucasSeries\n" + + "5-SphereVolume\n6-BallVolume\n7-twoPowerN\n8-CircleCircumference"); + Scanner choice = new Scanner(System.in); + System.out.println("Enter your choice: "); + int c = choice.nextInt(); + if(c==0) { + + for (ISubscriber sub : subscribers) { + mathTopic.addSubscriber(sub); + } + + } + else if(c==1) + { + mathTopic.addSubscriber(subscribers[0]); + } + else if(c==2) + { + mathTopic.addSubscriber(subscribers[1]); + } + else if(c==3) + { + mathTopic.addSubscriber(subscribers[2]); + } + else if(c==4) + { + mathTopic.addSubscriber(subscribers[3]); + } + else if(c==5) + { + mathTopic.addSubscriber(subscribers[4]); } + else if(c==6) + { + mathTopic.addSubscriber(subscribers[5]); + } + else if(c==7) + { + mathTopic.addSubscriber(subscribers[6]); + } + else if(c==8) + { + mathTopic.addSubscriber(subscribers[7]); + } + + //please call your method as the above calls here + + Scanner sc = new Scanner(System.in); + System.out.println("Enter your input: "); String input = sc.next(); mathTopic.dispatchEvent(input); + } } From 526edc6de308b2eae80ddf5a4ef0f3407364ce58 Mon Sep 17 00:00:00 2001 From: Ahmed Saeed Date: Tue, 3 Mar 2020 00:48:07 +0200 Subject: [PATCH 12/13] add SphereArea class and changes to main ID:20150011 --- .idea/.gitignore | 2 ++ .idea/misc.xml | 6 ++++++ .idea/modules.xml | 8 ++++++++ .idea/vcs.xml | 6 ++++++ GitAssignmentObserver.iml | 2 +- src/LucasSeries.java | 1 - src/Main.java | 11 ++++++----- src/SphereArea.java | 7 +++++++ 8 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 src/SphereArea.java 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 new file mode 100644 index 0000000..2ae5e0d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..3dd0b66 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ 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/GitAssignmentObserver.iml b/GitAssignmentObserver.iml index 409f5aa..26db12c 100644 --- a/GitAssignmentObserver.iml +++ b/GitAssignmentObserver.iml @@ -7,6 +7,6 @@ - + \ No newline at end of file diff --git a/src/LucasSeries.java b/src/LucasSeries.java index 0cb54f7..1e7a65c 100644 --- a/src/LucasSeries.java +++ b/src/LucasSeries.java @@ -1,5 +1,4 @@ -package com.company; public class LucasSeries implements ISubscriber{ @Override diff --git a/src/Main.java b/src/Main.java index df3f6bf..3802feb 100644 --- a/src/Main.java +++ b/src/Main.java @@ -1,5 +1,3 @@ -package com.company; - import java.util.Scanner; public class Main { @@ -11,7 +9,8 @@ public class Main { new SphereVolume(), new BallVolume(), new twoPowerN(), - new CircleCircumference() + new CircleCircumference(), + new SphereArea() //please add your object here }; public static void main(String[] args) { @@ -58,10 +57,12 @@ else if(c==7) { mathTopic.addSubscriber(subscribers[6]); } - else if(c==8) - { + else if(c==8) { mathTopic.addSubscriber(subscribers[7]); } + else if (c==9){ + mathTopic.addSubscriber(subscribers[8]); + } //please call your method as the above calls here diff --git a/src/SphereArea.java b/src/SphereArea.java new file mode 100644 index 0000000..53c217e --- /dev/null +++ b/src/SphereArea.java @@ -0,0 +1,7 @@ +public class SphereArea implements ISubscriber { + @Override + public void notifySubscriber(String input) { + int radius = Integer.parseInt(input); + System.out.println("The sphere area is "+4*radius*radius*3.14); + } +} From d69de0ea72c574a462331cf726c95eaddb954694 Mon Sep 17 00:00:00 2001 From: NadiaAmer <36113047+NadiaAmer@users.noreply.github.com> Date: Tue, 3 Mar 2020 01:07:19 +0200 Subject: [PATCH 13/13] adding CricelArea class adding CricelArea class --- src/CircleArea.java | 15 +++++++++++++++ src/Main.java | 1 + 2 files changed, 16 insertions(+) create mode 100644 src/CircleArea.java diff --git a/src/CircleArea.java b/src/CircleArea.java new file mode 100644 index 0000000..2cab725 --- /dev/null +++ b/src/CircleArea.java @@ -0,0 +1,15 @@ + + +public class CircleArea implements ISubscriber { + + + @Override + public void notifySubscriber(String input) { + double pi = 3.14 , res; + int r = Integer.parseInt(input); + res = pi *(r*r); + System.out.println("Area of circle:" + res ); + } +} + + diff --git a/src/Main.java b/src/Main.java index df3f6bf..3ae0e24 100644 --- a/src/Main.java +++ b/src/Main.java @@ -12,6 +12,7 @@ public class Main { new BallVolume(), new twoPowerN(), new CircleCircumference() + new CircleArea() //please add your object here }; public static void main(String[] args) {