diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..5c98b42
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,2 @@
+# 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..84da703
--- /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..8fe52dd
--- /dev/null
+++ b/GitAssignmentObserver.iml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/BallVolume.java b/src/BallVolume.java
new file mode 100644
index 0000000..6405a1d
--- /dev/null
+++ b/src/BallVolume.java
@@ -0,0 +1,22 @@
+/**
+ *
+ * @author Eman Ayman Khalaf 20170067
+ */
+import java.util.Scanner;
+
+public class BallVolume implements ISubscriber {
+
+ public BallVolume(){
+
+ }
+
+ @Override
+ public void notifySubscriber(String input) {
+ int radius= Integer.parseInt(input);
+ double pie=3.14285714286;
+ double volume=(4.0/3.0)*pie*(radius*radius*radius); // the volume of ball
+ System.out.println("Volume of the sphere="+volume);
+ }
+
+}
+
diff --git a/src/CircleArea.java b/src/CircleArea.java
new file mode 100644
index 0000000..7f00609
--- /dev/null
+++ b/src/CircleArea.java
@@ -0,0 +1,12 @@
+import java.util.Scanner;
+
+public class CircleArea implements ISubscriber
+{
+ @Override
+ public void notifySubscriber(String input){
+ int r = Integer.parseInt(input);
+ double pi = 3.14, area;
+ area = pi * r * r;
+ System.out.println("Area of circle: "+ area);
+ }
+}
\ No newline at end of file
diff --git a/src/CircleCircumference.java b/src/CircleCircumference.java
new file mode 100644
index 0000000..5d829d1
--- /dev/null
+++ b/src/CircleCircumference.java
@@ -0,0 +1,27 @@
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+
+/**
+ *
+ * @author Nour-Alhoda Khalid
+ */
+public class CircleCircumference implements ISubscriber {
+
+ public CircleCircumference() {
+
+ }
+
+ @Override
+ public void notifySubscriber(String input){
+ double x= Double.parseDouble(input);
+ double y=2*3.14*x;
+ System.out.print("the circumference equals ");
+ System.out.println(y);
+ }
+
+
+}
diff --git a/src/Fibonacci.java b/src/Fibonacci.java
new file mode 100644
index 0000000..441e9e3
--- /dev/null
+++ b/src/Fibonacci.java
@@ -0,0 +1,21 @@
+package main;
+
+/*
+ * To change this license header, choose License Headers in Project Properties.
+ * To change this template file, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/**
+ *
+ * @author m_h
+ */
+public class Fibonacci implements ISubscriber {
+ @Override
+ public void notifySubscriber(long n) {
+ if ((n == 0) || (n == 1))
+ System.out.println("Fibonacci of "+ n + " = " + n );
+ else
+ System.out.println("Fibonacci of " + n + " = " + Get_Fibonacci(n - 1) + Get_Fibonacci(n - 2));
+ }
+}
diff --git a/src/Main.java b/src/Main.java
index 9b8c2b0..a353b0f 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -1,9 +1,25 @@
+
import java.util.Scanner;
public class Main {
- private static ISubscriber subscribers [] = {
+ private static final ISubscriber subscribers [] = {
new SimpleSubscriber(),
+
new ReallySimpleSubscriber(),
+
+ new CircleCircumference(),
+ new SphereVolume(),
+ new BallVolume(),
+ new SummationSeries(),
+ new MultiplicationSeries(),
+ new CircleArea(),
+ new TwoPowerN()
+
+
+
+
+
+
};
public static void main(String[] args) {
Topic mathTopic = new Topic();
@@ -15,3 +31,4 @@ public static void main(String[] args) {
mathTopic.dispatchEvent(input);
}
}
+
diff --git a/src/MultiplicationSeries.java b/src/MultiplicationSeries.java
new file mode 100644
index 0000000..3f4d1ec
--- /dev/null
+++ b/src/MultiplicationSeries.java
@@ -0,0 +1,14 @@
+import java.math.BigDecimal;
+
+public class MultiplicationSeries implements ISubscriber {
+
+ @Override
+ public void notifySubscriber(String input) {
+ BigDecimal output=new BigDecimal("1");
+ for (int i = Integer.parseInt(input); i > 0; i--) {
+ output=output.multiply(BigDecimal.valueOf(i));
+ }
+ System.out.println("MultiplicationSeries : "+output);
+ }
+
+}
diff --git a/src/SummationSeries.java b/src/SummationSeries.java
new file mode 100644
index 0000000..254e3f8
--- /dev/null
+++ b/src/SummationSeries.java
@@ -0,0 +1,35 @@
+public class SummationSeries implements ISubscriber
+{
+ public SummationSeries() {
+}
+
+ int factorial(int t)
+ {
+ int mul = 1;
+
+ while(t > 0)
+ {
+ mul = mul * t;
+
+ t--;
+ }
+ return mul;
+ }
+
+
+
+ @Override
+ public void notifySubscriber(String input)
+ {
+ double y = 0;
+ int x=Integer.parseInt(input);
+
+ SummationSeries mSummationSeries = new SummationSeries();
+ for(int i = 1; i <= x; i++)
+ {
+ y = y + (double)i / (mSummationSeries.factorial(i));
+ }
+ System.out.println("Summation Series: "+y);
+ }
+
+}
\ No newline at end of file
diff --git a/src/TwoPowerN.java b/src/TwoPowerN.java
new file mode 100644
index 0000000..f0bedaf
--- /dev/null
+++ b/src/TwoPowerN.java
@@ -0,0 +1,15 @@
+import java.lang.Math;
+
+public class TwoPowerN implements ISubscriber
+{
+
+ @Override
+ public void notifySubscriber(String input)
+ {
+
+ double n= Double.parseDouble(input);
+
+ System.out.println("2 power " + input + " equals " + Math.pow(2,n));
+ }
+
+}