From fe2e5c7b07bfc2a4edd433be0f677bcc3f27fb1d Mon Sep 17 00:00:00 2001 From: 42awa Date: Thu, 27 Feb 2020 00:46:34 +0200 Subject: [PATCH 01/35] have made SphereCircumference --- .idea/.name | 1 + .idea/codeStyles/codeStyleConfig.xml | 5 +++ .idea/misc.xml | 6 +++ .idea/modules.xml | 8 ++++ .idea/vcs.xml | 6 +++ .idea/workspace.xml | 60 ++++++++++++++++++++++++++++ GitAssignmentObserver.iml | 12 ++++++ src/Main.java | 5 ++- src/SphereCircumference.java | 25 ++++++++++++ 9 files changed, 126 insertions(+), 2 deletions(-) create mode 100644 .idea/.name create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 GitAssignmentObserver.iml create mode 100644 src/SphereCircumference.java 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/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ 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..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..67b98b4 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + 1582650687567 + + + + + + + \ 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 9b8c2b0..7b24a65 100644 --- a/src/Main.java +++ b/src/Main.java @@ -2,8 +2,9 @@ public class Main { private static ISubscriber subscribers [] = { - new SimpleSubscriber(), - new ReallySimpleSubscriber(), + /*new SimpleSubscriber(), + new ReallySimpleSubscriber(),*/ + new SphereCircumference() }; public static void main(String[] args) { Topic mathTopic = new Topic(); diff --git a/src/SphereCircumference.java b/src/SphereCircumference.java new file mode 100644 index 0000000..29100d7 --- /dev/null +++ b/src/SphereCircumference.java @@ -0,0 +1,25 @@ + +public class SphereCircumference implements ISubscriber{ + private double getSphereCircumference(double r) { + double area=2*Math.PI*r; + return area; + } + @Override + public void notifySubscriber(String input) { + double r; + try { + r=Double.parseDouble(input); + } catch (Exception e) { + System.out.println("enter a real number"); + return; + } + + if(r<0) { + System.out.println("r must be >= 0"); + return; + } + System.out.println("Area= "+getSphereCircumference(r)); + + } + +} From ed1d255ddc2ed8e78b8c1fef3ed394701f541267 Mon Sep 17 00:00:00 2001 From: Berserk132 Date: Fri, 28 Feb 2020 11:32:19 +0200 Subject: [PATCH 02/35] Added New Class --- .idea/misc.xml | 2 +- .idea/workspace.xml | 238 +++++++++++++++++++++++++++++++++++++- GitAssignmentObserver.iml | 2 +- src/Main.java | 3 +- src/SphereArea.java | 25 ++++ 5 files changed, 265 insertions(+), 5 deletions(-) create mode 100644 src/SphereArea.java diff --git a/.idea/misc.xml b/.idea/misc.xml index ba93b15..9a4f0b5 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 67b98b4..e1900f3 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -1,7 +1,13 @@ - + + + + + + + \ No newline at end of file diff --git a/GitAssignmentObserver.iml b/GitAssignmentObserver.iml deleted file mode 100644 index 26db12c..0000000 --- a/GitAssignmentObserver.iml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Main.java b/src/Main.java index 234a1c5..9b8c2b0 100644 --- a/src/Main.java +++ b/src/Main.java @@ -2,11 +2,6 @@ public class Main { private static ISubscriber subscribers [] = { - /*new SimpleSubscriber(), - new ReallySimpleSubscriber(),*/ - new SphereCircumference(), - new SphereArea() - new SimpleSubscriber(), new ReallySimpleSubscriber(), }; diff --git a/src/SphereArea.java b/src/SphereArea.java deleted file mode 100644 index e856d8d..0000000 --- a/src/SphereArea.java +++ /dev/null @@ -1,25 +0,0 @@ -import java.sql.SQLOutput; - -public class SphereArea implements ISubscriber { - - - @Override - public void notifySubscriber(String input) { - - double R = Double.parseDouble(input); - - double sphereArea = calcSphereArea(R); - - System.out.println("The Sphere Area = " + sphereArea); - - } - - double calcSphereArea(double r){ - - double sphereArea = 0.0; - - sphereArea = 4 * Math.PI * Math.pow(r, 2); - - return sphereArea; - } -} From ef539941b23bd6ecd89b1e03bbd010a886eaff33 Mon Sep 17 00:00:00 2001 From: farah afifi <36455840+farah-afifi@users.noreply.github.com> Date: Sun, 1 Mar 2020 19:00:59 +0200 Subject: [PATCH 22/35] fibonacci DONE --- src/fibonacci.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/fibonacci.java diff --git a/src/fibonacci.java b/src/fibonacci.java new file mode 100644 index 0000000..ce2f362 --- /dev/null +++ b/src/fibonacci.java @@ -0,0 +1,22 @@ +public class fibonacci implements ISubscriber { + + int calcFib(String input){ + int x = Integer.parseInt(input); + int ans = 0 ; + int fibN_1 = 1 ,fibN_2 = 1 ,fibN = 0; + + for(int i = 2 ; i < x ; i ++) { + fibN = fibN_1 + fibN_2; + fibN_2 = fibN_1; + fibN_1 = fibN; + } + return fibN; + } + @Override + public void notifySubscriber(String input) { + // TODO Auto-generated method stub + + System.out.println("fibonacci of "+input+ " is " + calcFib(input)); + + } +} \ No newline at end of file From 5d16811b2ed60e8fd59f27e4d8c7e19d93d84283 Mon Sep 17 00:00:00 2001 From: Ahmed01151526059 <44085402+Ahmed01151526059@users.noreply.github.com> Date: Sun, 1 Mar 2020 19:20:34 +0200 Subject: [PATCH 23/35] circle volume --- src/ISubscriber.java | 4 ---- src/Main.java | 24 ------------------------ src/ReallySimpleSubscriber.java | 8 -------- src/SimpleSubscriber.java | 10 ---------- src/Topic.java | 25 ------------------------- src/circleV.java | 14 -------------- 6 files changed, 85 deletions(-) delete mode 100644 src/ISubscriber.java delete mode 100644 src/Main.java delete mode 100644 src/ReallySimpleSubscriber.java delete mode 100644 src/SimpleSubscriber.java delete mode 100644 src/Topic.java delete mode 100644 src/circleV.java diff --git a/src/ISubscriber.java b/src/ISubscriber.java deleted file mode 100644 index d3a605c..0000000 --- a/src/ISubscriber.java +++ /dev/null @@ -1,4 +0,0 @@ - -public interface ISubscriber { - public abstract void notifySubscriber(String input); -} diff --git a/src/Main.java b/src/Main.java deleted file mode 100644 index 51d8a51..0000000 --- a/src/Main.java +++ /dev/null @@ -1,24 +0,0 @@ -import java.util.Scanner; - -public class Main { - private static ISubscriber subscribers [] = { - - new SphereCircumference(), - new SphereArea(), - new Fibonacci(), - new Sphere_Volume(), - new SummationSeries() - // 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); - } -} diff --git a/src/ReallySimpleSubscriber.java b/src/ReallySimpleSubscriber.java deleted file mode 100644 index fb1114a..0000000 --- a/src/ReallySimpleSubscriber.java +++ /dev/null @@ -1,8 +0,0 @@ - -public class ReallySimpleSubscriber implements ISubscriber { - @Override - public void notifySubscriber(String input) { - // TODO Auto-generated method stub - System.out.println("Hello, I am really a simple subscriber and I am notified with " + input); - } -} diff --git a/src/SimpleSubscriber.java b/src/SimpleSubscriber.java deleted file mode 100644 index 5b0e4aa..0000000 --- a/src/SimpleSubscriber.java +++ /dev/null @@ -1,10 +0,0 @@ - -public class SimpleSubscriber implements ISubscriber { - - @Override - public void notifySubscriber(String input) { - // TODO Auto-generated method stub - System.out.println("Hello, I am a simple subscriber and I am notified with " + input); - } - -} diff --git a/src/Topic.java b/src/Topic.java deleted file mode 100644 index 8fa2e2e..0000000 --- a/src/Topic.java +++ /dev/null @@ -1,25 +0,0 @@ -import java.util.ArrayList; -import java.util.List; - -public class Topic { - - private List subscribers; - - public Topic() { - subscribers = new ArrayList(); - } - - public void addSubscriber(ISubscriber sub) { - subscribers.add(sub); - } - - public List getSubscribers() { - return subscribers; - } - - public void dispatchEvent(String input) { - for (ISubscriber sub : this.getSubscribers()) { - sub.notifySubscriber(input); - } - } -} diff --git a/src/circleV.java b/src/circleV.java deleted file mode 100644 index 6e34dbf..0000000 --- a/src/circleV.java +++ /dev/null @@ -1,14 +0,0 @@ - -public class circleV implements ISubscriber { - @Override - public void notifySubscriber(String input) { - - double r = Double.parseDouble(input); - - - double volume= Math.PI*r*r; - - System.out.println("Volume is:" +volume); - - } -} From 84b2a42ea639e74c31510bba5800761a8e027a00 Mon Sep 17 00:00:00 2001 From: Ahmed01151526059 <44085402+Ahmed01151526059@users.noreply.github.com> Date: Sun, 1 Mar 2020 19:27:57 +0200 Subject: [PATCH 24/35] circle volume --- src/Fibonacci.java | 23 ----------------------- src/ISubscriber.java | 4 ++++ src/Main.java | 24 ++++++++++++++++++++++++ src/ReallySimpleSubscriber.java | 8 ++++++++ src/SimpleSubscriber.java | 10 ++++++++++ src/SphereArea.java | 25 ------------------------- src/SphereCircumference.java | 24 ------------------------ src/Sphere_Volume.java | 9 --------- src/SummationSeries.java | 15 --------------- src/Topic.java | 25 +++++++++++++++++++++++++ src/circleV.java | 14 ++++++++++++++ 11 files changed, 85 insertions(+), 96 deletions(-) delete mode 100644 src/Fibonacci.java create mode 100644 src/ISubscriber.java create mode 100644 src/Main.java create mode 100644 src/ReallySimpleSubscriber.java create mode 100644 src/SimpleSubscriber.java delete mode 100644 src/SphereArea.java delete mode 100644 src/SphereCircumference.java delete mode 100644 src/Sphere_Volume.java delete mode 100644 src/SummationSeries.java create mode 100644 src/Topic.java create mode 100644 src/circleV.java diff --git a/src/Fibonacci.java b/src/Fibonacci.java deleted file mode 100644 index be380bc..0000000 --- a/src/Fibonacci.java +++ /dev/null @@ -1,23 +0,0 @@ - -public class Fibonacci implements ISubscriber { - - int calcFib(String input){ - int x = Integer.parseInt(input); - int ans = 0 ; - int fibN_1 = 1 ,fibN_2 = 1 ,fibN = 0; - - for(int i = 2 ; i < x ; i ++) { - fibN = fibN_1 + fibN_2; - fibN_2 = fibN_1; - fibN_1 = fibN; - } - return fibN; - } - @Override - public void notifySubscriber(String input) { - // TODO Auto-generated method stub - - System.out.println("fibonacci of "+input+ " is " + calcFib(input)); - - } -} diff --git a/src/ISubscriber.java b/src/ISubscriber.java new file mode 100644 index 0000000..d3a605c --- /dev/null +++ b/src/ISubscriber.java @@ -0,0 +1,4 @@ + +public interface ISubscriber { + public abstract void notifySubscriber(String input); +} diff --git a/src/Main.java b/src/Main.java new file mode 100644 index 0000000..51d8a51 --- /dev/null +++ b/src/Main.java @@ -0,0 +1,24 @@ +import java.util.Scanner; + +public class Main { + private static ISubscriber subscribers [] = { + + new SphereCircumference(), + new SphereArea(), + new Fibonacci(), + new Sphere_Volume(), + new SummationSeries() + // 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); + } +} diff --git a/src/ReallySimpleSubscriber.java b/src/ReallySimpleSubscriber.java new file mode 100644 index 0000000..fb1114a --- /dev/null +++ b/src/ReallySimpleSubscriber.java @@ -0,0 +1,8 @@ + +public class ReallySimpleSubscriber implements ISubscriber { + @Override + public void notifySubscriber(String input) { + // TODO Auto-generated method stub + System.out.println("Hello, I am really a simple subscriber and I am notified with " + input); + } +} diff --git a/src/SimpleSubscriber.java b/src/SimpleSubscriber.java new file mode 100644 index 0000000..5b0e4aa --- /dev/null +++ b/src/SimpleSubscriber.java @@ -0,0 +1,10 @@ + +public class SimpleSubscriber implements ISubscriber { + + @Override + public void notifySubscriber(String input) { + // TODO Auto-generated method stub + System.out.println("Hello, I am a simple subscriber and I am notified with " + input); + } + +} diff --git a/src/SphereArea.java b/src/SphereArea.java deleted file mode 100644 index e856d8d..0000000 --- a/src/SphereArea.java +++ /dev/null @@ -1,25 +0,0 @@ -import java.sql.SQLOutput; - -public class SphereArea implements ISubscriber { - - - @Override - public void notifySubscriber(String input) { - - double R = Double.parseDouble(input); - - double sphereArea = calcSphereArea(R); - - System.out.println("The Sphere Area = " + sphereArea); - - } - - double calcSphereArea(double r){ - - double sphereArea = 0.0; - - sphereArea = 4 * Math.PI * Math.pow(r, 2); - - return sphereArea; - } -} diff --git a/src/SphereCircumference.java b/src/SphereCircumference.java deleted file mode 100644 index dac652c..0000000 --- a/src/SphereCircumference.java +++ /dev/null @@ -1,24 +0,0 @@ -public class SphereCircumference implements ISubscriber{ - private double getSphereCircumference(double r) { - double area=2*Math.PI*r; - return area; - } - @Override - public void notifySubscriber(String input) { - double r; - try { - r=Double.parseDouble(input); - } catch (Exception e) { - System.out.println("enter a real number"); - return; - } - - if(r<0) { - System.out.println("r must be >= 0"); - return; - } - System.out.println("Area= "+getSphereCircumference(r)); - - } - -} diff --git a/src/Sphere_Volume.java b/src/Sphere_Volume.java deleted file mode 100644 index 14011bc..0000000 --- a/src/Sphere_Volume.java +++ /dev/null @@ -1,9 +0,0 @@ -public class Sphere_Volume implements ISubscriber { - @Override - public void notifySubscriber(String input) { - double radius = Double.parseDouble(input); - double Sphere_volume = (4/3) * Math.PI * Math.pow(radius, 3); - System.out.println("Sphere_volume = " + Sphere_volume); - } -} - diff --git a/src/SummationSeries.java b/src/SummationSeries.java deleted file mode 100644 index 3c84dc1..0000000 --- a/src/SummationSeries.java +++ /dev/null @@ -1,15 +0,0 @@ -public class SummationSeries implements ISubscriber -{ - @Override - public void notifySubscriber(String input) - { - int end = Integer.parseInt(input); - int sum = sigma(end); - System.out.println("The sum from 1 to the end number = " + sum); - } - - public static int sigma(int end) - { - return (end*(end+1))/2; - } -} diff --git a/src/Topic.java b/src/Topic.java new file mode 100644 index 0000000..8fa2e2e --- /dev/null +++ b/src/Topic.java @@ -0,0 +1,25 @@ +import java.util.ArrayList; +import java.util.List; + +public class Topic { + + private List subscribers; + + public Topic() { + subscribers = new ArrayList(); + } + + public void addSubscriber(ISubscriber sub) { + subscribers.add(sub); + } + + public List getSubscribers() { + return subscribers; + } + + public void dispatchEvent(String input) { + for (ISubscriber sub : this.getSubscribers()) { + sub.notifySubscriber(input); + } + } +} diff --git a/src/circleV.java b/src/circleV.java new file mode 100644 index 0000000..6e34dbf --- /dev/null +++ b/src/circleV.java @@ -0,0 +1,14 @@ + +public class circleV implements ISubscriber { + @Override + public void notifySubscriber(String input) { + + double r = Double.parseDouble(input); + + + double volume= Math.PI*r*r; + + System.out.println("Volume is:" +volume); + + } +} From 04a91f08c008d92da090d960e837d08d82283760 Mon Sep 17 00:00:00 2001 From: AhmedOsama <36333141+gqozgalz@users.noreply.github.com> Date: Sun, 1 Mar 2020 23:39:02 +0200 Subject: [PATCH 25/35] added SphereCircumference class id: 20170010 --- src/SphereCircumference.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/SphereCircumference.java diff --git a/src/SphereCircumference.java b/src/SphereCircumference.java new file mode 100644 index 0000000..dac652c --- /dev/null +++ b/src/SphereCircumference.java @@ -0,0 +1,24 @@ +public class SphereCircumference implements ISubscriber{ + private double getSphereCircumference(double r) { + double area=2*Math.PI*r; + return area; + } + @Override + public void notifySubscriber(String input) { + double r; + try { + r=Double.parseDouble(input); + } catch (Exception e) { + System.out.println("enter a real number"); + return; + } + + if(r<0) { + System.out.println("r must be >= 0"); + return; + } + System.out.println("Area= "+getSphereCircumference(r)); + + } + +} From ae946ecb94a9f93666cbe2ec6ff21ed0679095a0 Mon Sep 17 00:00:00 2001 From: Berserk132 Date: Mon, 2 Mar 2020 00:10:25 +0200 Subject: [PATCH 26/35] 20170021-Added SphereArea Class --- src/SphereArea.java | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/SphereArea.java diff --git a/src/SphereArea.java b/src/SphereArea.java new file mode 100644 index 0000000..e856d8d --- /dev/null +++ b/src/SphereArea.java @@ -0,0 +1,25 @@ +import java.sql.SQLOutput; + +public class SphereArea implements ISubscriber { + + + @Override + public void notifySubscriber(String input) { + + double R = Double.parseDouble(input); + + double sphereArea = calcSphereArea(R); + + System.out.println("The Sphere Area = " + sphereArea); + + } + + double calcSphereArea(double r){ + + double sphereArea = 0.0; + + sphereArea = 4 * Math.PI * Math.pow(r, 2); + + return sphereArea; + } +} From 911f0c90ced9e545427ebaa74458ce808edc05a9 Mon Sep 17 00:00:00 2001 From: Ahmad Date: Mon, 2 Mar 2020 13:42:01 +0200 Subject: [PATCH 27/35] Add summation series class ID:20170006 --- src/SummationSeries.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/SummationSeries.java diff --git a/src/SummationSeries.java b/src/SummationSeries.java new file mode 100644 index 0000000..3c84dc1 --- /dev/null +++ b/src/SummationSeries.java @@ -0,0 +1,15 @@ +public class SummationSeries implements ISubscriber +{ + @Override + public void notifySubscriber(String input) + { + int end = Integer.parseInt(input); + int sum = sigma(end); + System.out.println("The sum from 1 to the end number = " + sum); + } + + public static int sigma(int end) + { + return (end*(end+1))/2; + } +} From 143a121eacdc6957ecbb1c062dfd3a738bfa0bdf Mon Sep 17 00:00:00 2001 From: esraa2367 <36345039+esraa2367@users.noreply.github.com> Date: Mon, 2 Mar 2020 17:37:24 +0200 Subject: [PATCH 28/35] Sphere Volume Done --- src/Sphere_Volume.java | 4 ++++ src/circleV.java | 14 -------------- 2 files changed, 4 insertions(+), 14 deletions(-) create mode 100644 src/Sphere_Volume.java delete mode 100644 src/circleV.java diff --git a/src/Sphere_Volume.java b/src/Sphere_Volume.java new file mode 100644 index 0000000..1c5323e --- /dev/null +++ b/src/Sphere_Volume.java @@ -0,0 +1,4 @@ + +public class Sphere_Volume { + +} diff --git a/src/circleV.java b/src/circleV.java deleted file mode 100644 index 6e34dbf..0000000 --- a/src/circleV.java +++ /dev/null @@ -1,14 +0,0 @@ - -public class circleV implements ISubscriber { - @Override - public void notifySubscriber(String input) { - - double r = Double.parseDouble(input); - - - double volume= Math.PI*r*r; - - System.out.println("Volume is:" +volume); - - } -} From 9610efd9a203f5da352cb8cd50f4e1f2605688e5 Mon Sep 17 00:00:00 2001 From: esraa2367 <36345039+esraa2367@users.noreply.github.com> Date: Mon, 2 Mar 2020 17:50:10 +0200 Subject: [PATCH 29/35] Sphere Volume implementation --- src/Sphere_Volume.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Sphere_Volume.java b/src/Sphere_Volume.java index 1c5323e..50315f6 100644 --- a/src/Sphere_Volume.java +++ b/src/Sphere_Volume.java @@ -1,4 +1,17 @@ -public class Sphere_Volume { - +public class Sphere_Volume implements ISubscriber { + @Override + public void notifySubscriber(String input) { + + double Radius = Double.parseDouble(input); + if(Radius < 0) + { + System.out.println("Radius can not be equal nagative number"); + } + else { + double Volume = (4/3) * Math.PI * Math.pow(Radius, 3); + System.out.println("Volume = "+ Volume); + } + + } } From 6901849d6e37f3990db445a03277ec378c89c7e5 Mon Sep 17 00:00:00 2001 From: "abdonasef733@gmail.com" <61522713+HamidoNasef@users.noreply.github.com> Date: Mon, 2 Mar 2020 20:57:31 +0200 Subject: [PATCH 30/35] Create CircleArea.java 20170162-Add-circle-area-class --- src/CircleArea.java | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/CircleArea.java diff --git a/src/CircleArea.java b/src/CircleArea.java new file mode 100644 index 0000000..c798237 --- /dev/null +++ b/src/CircleArea.java @@ -0,0 +1,24 @@ + +public class CircleArea { + private float PI = (float) 3.14159265359; + private float reduis = 0; + + public CircleArea () {} + + public CircleArea (float reduis) { + this.reduis = reduis; + } + + public float get_reduis() { + return this.reduis; + } + + public void set_reduis(float reduis) { + this.reduis = reduis; + } + + public float area() { + return (float) PI * reduis *reduis; + } +} + From 27fb4f409a1cb9a36687432edf035410bf124e55 Mon Sep 17 00:00:00 2001 From: "abdonasef733@gmail.com" <61522713+HamidoNasef@users.noreply.github.com> Date: Mon, 2 Mar 2020 21:30:42 +0200 Subject: [PATCH 31/35] Update CircleArea.java 20170162_CircleArea edit on class & added some functions --- src/CircleArea.java | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/CircleArea.java b/src/CircleArea.java index c798237..ce21b6a 100644 --- a/src/CircleArea.java +++ b/src/CircleArea.java @@ -1,24 +1,17 @@ -public class CircleArea { - private float PI = (float) 3.14159265359; - private float reduis = 0; +public class CircleArea implements ISubscriber{ - public CircleArea () {} - - public CircleArea (float reduis) { - this.reduis = reduis; - } - - public float get_reduis() { - return this.reduis; + @Override + public void notifySubscriber(String input) { + double reduis=Double.parseDouble(input); + System.out.println("Area= "+area(reduis)); + } - public void set_reduis(float reduis) { - this.reduis = reduis; - } - public float area() { - return (float) PI * reduis *reduis; + public double area(double reduis) { + double setArea=Math.PI * reduis *reduis; + return setArea; } } From c09c02939bc2c843e829fe847c739a0a632a7196 Mon Sep 17 00:00:00 2001 From: Ahmed01151526059 <44085402+Ahmed01151526059@users.noreply.github.com> Date: Tue, 3 Mar 2020 11:50:17 +0200 Subject: [PATCH 32/35] volume of circle --- src/SphereArea.java | 25 ------------------------- src/SphereCircumference.java | 24 ------------------------ src/Sphere_Volume.java | 17 ----------------- src/SummationSeries.java | 15 --------------- src/fibonacci.java | 22 ---------------------- 5 files changed, 103 deletions(-) delete mode 100644 src/SphereArea.java delete mode 100644 src/SphereCircumference.java delete mode 100644 src/Sphere_Volume.java delete mode 100644 src/SummationSeries.java delete mode 100644 src/fibonacci.java diff --git a/src/SphereArea.java b/src/SphereArea.java deleted file mode 100644 index e856d8d..0000000 --- a/src/SphereArea.java +++ /dev/null @@ -1,25 +0,0 @@ -import java.sql.SQLOutput; - -public class SphereArea implements ISubscriber { - - - @Override - public void notifySubscriber(String input) { - - double R = Double.parseDouble(input); - - double sphereArea = calcSphereArea(R); - - System.out.println("The Sphere Area = " + sphereArea); - - } - - double calcSphereArea(double r){ - - double sphereArea = 0.0; - - sphereArea = 4 * Math.PI * Math.pow(r, 2); - - return sphereArea; - } -} diff --git a/src/SphereCircumference.java b/src/SphereCircumference.java deleted file mode 100644 index dac652c..0000000 --- a/src/SphereCircumference.java +++ /dev/null @@ -1,24 +0,0 @@ -public class SphereCircumference implements ISubscriber{ - private double getSphereCircumference(double r) { - double area=2*Math.PI*r; - return area; - } - @Override - public void notifySubscriber(String input) { - double r; - try { - r=Double.parseDouble(input); - } catch (Exception e) { - System.out.println("enter a real number"); - return; - } - - if(r<0) { - System.out.println("r must be >= 0"); - return; - } - System.out.println("Area= "+getSphereCircumference(r)); - - } - -} diff --git a/src/Sphere_Volume.java b/src/Sphere_Volume.java deleted file mode 100644 index 50315f6..0000000 --- a/src/Sphere_Volume.java +++ /dev/null @@ -1,17 +0,0 @@ - -public class Sphere_Volume implements ISubscriber { - @Override - public void notifySubscriber(String input) { - - double Radius = Double.parseDouble(input); - if(Radius < 0) - { - System.out.println("Radius can not be equal nagative number"); - } - else { - double Volume = (4/3) * Math.PI * Math.pow(Radius, 3); - System.out.println("Volume = "+ Volume); - } - - } -} diff --git a/src/SummationSeries.java b/src/SummationSeries.java deleted file mode 100644 index 3c84dc1..0000000 --- a/src/SummationSeries.java +++ /dev/null @@ -1,15 +0,0 @@ -public class SummationSeries implements ISubscriber -{ - @Override - public void notifySubscriber(String input) - { - int end = Integer.parseInt(input); - int sum = sigma(end); - System.out.println("The sum from 1 to the end number = " + sum); - } - - public static int sigma(int end) - { - return (end*(end+1))/2; - } -} diff --git a/src/fibonacci.java b/src/fibonacci.java deleted file mode 100644 index ce2f362..0000000 --- a/src/fibonacci.java +++ /dev/null @@ -1,22 +0,0 @@ -public class fibonacci implements ISubscriber { - - int calcFib(String input){ - int x = Integer.parseInt(input); - int ans = 0 ; - int fibN_1 = 1 ,fibN_2 = 1 ,fibN = 0; - - for(int i = 2 ; i < x ; i ++) { - fibN = fibN_1 + fibN_2; - fibN_2 = fibN_1; - fibN_1 = fibN; - } - return fibN; - } - @Override - public void notifySubscriber(String input) { - // TODO Auto-generated method stub - - System.out.println("fibonacci of "+input+ " is " + calcFib(input)); - - } -} \ No newline at end of file From 1499e004a1444ef127f3ce8f11955b87d1a3a8b3 Mon Sep 17 00:00:00 2001 From: Ahmed01151526059 <44085402+Ahmed01151526059@users.noreply.github.com> Date: Tue, 3 Mar 2020 12:30:23 +0200 Subject: [PATCH 33/35] volume of circle --- src/CircleArea.java | 17 ----------------- src/circleV.java | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 17 deletions(-) delete mode 100644 src/CircleArea.java create mode 100644 src/circleV.java diff --git a/src/CircleArea.java b/src/CircleArea.java deleted file mode 100644 index ce21b6a..0000000 --- a/src/CircleArea.java +++ /dev/null @@ -1,17 +0,0 @@ - -public class CircleArea implements ISubscriber{ - - @Override - public void notifySubscriber(String input) { - double reduis=Double.parseDouble(input); - System.out.println("Area= "+area(reduis)); - - } - - - public double area(double reduis) { - double setArea=Math.PI * reduis *reduis; - return setArea; - } -} - diff --git a/src/circleV.java b/src/circleV.java new file mode 100644 index 0000000..6e34dbf --- /dev/null +++ b/src/circleV.java @@ -0,0 +1,14 @@ + +public class circleV implements ISubscriber { + @Override + public void notifySubscriber(String input) { + + double r = Double.parseDouble(input); + + + double volume= Math.PI*r*r; + + System.out.println("Volume is:" +volume); + + } +} From 92e9cb28ed5281640e91fcc0b45cf12a08cf8ff5 Mon Sep 17 00:00:00 2001 From: Ahmed01151526059 <44085402+Ahmed01151526059@users.noreply.github.com> Date: Tue, 3 Mar 2020 12:55:36 +0200 Subject: [PATCH 34/35] 20170024-circle volume --- src/CircleArea.java | 17 +++++++++++++++++ src/SphereArea.java | 25 +++++++++++++++++++++++++ src/SphereCircumference.java | 24 ++++++++++++++++++++++++ src/Sphere_Volume.java | 17 +++++++++++++++++ src/SummationSeries.java | 15 +++++++++++++++ src/circleV.java | 14 -------------- src/fibonacci.java | 22 ++++++++++++++++++++++ 7 files changed, 120 insertions(+), 14 deletions(-) create mode 100644 src/CircleArea.java create mode 100644 src/SphereArea.java create mode 100644 src/SphereCircumference.java create mode 100644 src/Sphere_Volume.java create mode 100644 src/SummationSeries.java delete mode 100644 src/circleV.java create mode 100644 src/fibonacci.java diff --git a/src/CircleArea.java b/src/CircleArea.java new file mode 100644 index 0000000..ce21b6a --- /dev/null +++ b/src/CircleArea.java @@ -0,0 +1,17 @@ + +public class CircleArea implements ISubscriber{ + + @Override + public void notifySubscriber(String input) { + double reduis=Double.parseDouble(input); + System.out.println("Area= "+area(reduis)); + + } + + + public double area(double reduis) { + double setArea=Math.PI * reduis *reduis; + return setArea; + } +} + diff --git a/src/SphereArea.java b/src/SphereArea.java new file mode 100644 index 0000000..e856d8d --- /dev/null +++ b/src/SphereArea.java @@ -0,0 +1,25 @@ +import java.sql.SQLOutput; + +public class SphereArea implements ISubscriber { + + + @Override + public void notifySubscriber(String input) { + + double R = Double.parseDouble(input); + + double sphereArea = calcSphereArea(R); + + System.out.println("The Sphere Area = " + sphereArea); + + } + + double calcSphereArea(double r){ + + double sphereArea = 0.0; + + sphereArea = 4 * Math.PI * Math.pow(r, 2); + + return sphereArea; + } +} diff --git a/src/SphereCircumference.java b/src/SphereCircumference.java new file mode 100644 index 0000000..dac652c --- /dev/null +++ b/src/SphereCircumference.java @@ -0,0 +1,24 @@ +public class SphereCircumference implements ISubscriber{ + private double getSphereCircumference(double r) { + double area=2*Math.PI*r; + return area; + } + @Override + public void notifySubscriber(String input) { + double r; + try { + r=Double.parseDouble(input); + } catch (Exception e) { + System.out.println("enter a real number"); + return; + } + + if(r<0) { + System.out.println("r must be >= 0"); + return; + } + System.out.println("Area= "+getSphereCircumference(r)); + + } + +} diff --git a/src/Sphere_Volume.java b/src/Sphere_Volume.java new file mode 100644 index 0000000..50315f6 --- /dev/null +++ b/src/Sphere_Volume.java @@ -0,0 +1,17 @@ + +public class Sphere_Volume implements ISubscriber { + @Override + public void notifySubscriber(String input) { + + double Radius = Double.parseDouble(input); + if(Radius < 0) + { + System.out.println("Radius can not be equal nagative number"); + } + else { + double Volume = (4/3) * Math.PI * Math.pow(Radius, 3); + System.out.println("Volume = "+ Volume); + } + + } +} diff --git a/src/SummationSeries.java b/src/SummationSeries.java new file mode 100644 index 0000000..3c84dc1 --- /dev/null +++ b/src/SummationSeries.java @@ -0,0 +1,15 @@ +public class SummationSeries implements ISubscriber +{ + @Override + public void notifySubscriber(String input) + { + int end = Integer.parseInt(input); + int sum = sigma(end); + System.out.println("The sum from 1 to the end number = " + sum); + } + + public static int sigma(int end) + { + return (end*(end+1))/2; + } +} diff --git a/src/circleV.java b/src/circleV.java deleted file mode 100644 index 6e34dbf..0000000 --- a/src/circleV.java +++ /dev/null @@ -1,14 +0,0 @@ - -public class circleV implements ISubscriber { - @Override - public void notifySubscriber(String input) { - - double r = Double.parseDouble(input); - - - double volume= Math.PI*r*r; - - System.out.println("Volume is:" +volume); - - } -} diff --git a/src/fibonacci.java b/src/fibonacci.java new file mode 100644 index 0000000..ce2f362 --- /dev/null +++ b/src/fibonacci.java @@ -0,0 +1,22 @@ +public class fibonacci implements ISubscriber { + + int calcFib(String input){ + int x = Integer.parseInt(input); + int ans = 0 ; + int fibN_1 = 1 ,fibN_2 = 1 ,fibN = 0; + + for(int i = 2 ; i < x ; i ++) { + fibN = fibN_1 + fibN_2; + fibN_2 = fibN_1; + fibN_1 = fibN; + } + return fibN; + } + @Override + public void notifySubscriber(String input) { + // TODO Auto-generated method stub + + System.out.println("fibonacci of "+input+ " is " + calcFib(input)); + + } +} \ No newline at end of file From 72ab32b80eeb2ee23080e930d3fdc1609f4f9cf0 Mon Sep 17 00:00:00 2001 From: Ahmed01151526059 <44085402+Ahmed01151526059@users.noreply.github.com> Date: Tue, 3 Mar 2020 13:02:20 +0200 Subject: [PATCH 35/35] volume of circle 20170024 --- src/circleV.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/circleV.java diff --git a/src/circleV.java b/src/circleV.java new file mode 100644 index 0000000..6e34dbf --- /dev/null +++ b/src/circleV.java @@ -0,0 +1,14 @@ + +public class circleV implements ISubscriber { + @Override + public void notifySubscriber(String input) { + + double r = Double.parseDouble(input); + + + double volume= Math.PI*r*r; + + System.out.println("Volume is:" +volume); + + } +}