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
new file mode 100644
index 0000000..26db12c
--- /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..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/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/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/LucasSeries.java b/src/LucasSeries.java
new file mode 100644
index 0000000..1e7a65c
--- /dev/null
+++ b/src/LucasSeries.java
@@ -0,0 +1,32 @@
+
+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.print(printSeries(i)+" ");
+ }
+ System.out.println("");
+ } 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 9b8c2b0..643bfe4 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -1,17 +1,78 @@
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(),
+ new LucasSeries(),
+ new SphereVolume(),
+ new BallVolume(),
+ new twoPowerN(),
+ new CircleCircumference(),
+ new SphereArea(),
+ new CircleArea()
+
+ //please add your object here
+ };
+ public static void main(String[] args) {
+ Topic mathTopic = new Topic();
+ 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]);
+ }
+ else if (c==9){
+ mathTopic.addSubscriber(subscribers[8]);
+ }
+
+ //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);
+
+ }
}
diff --git a/src/MultiplicationSeries.java b/src/MultiplicationSeries.java
new file mode 100644
index 0000000..9ae55b8
--- /dev/null
+++ b/src/MultiplicationSeries.java
@@ -0,0 +1,31 @@
+
+
+
+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 "+Result);
+ }
+}
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 );
+
+ }
+
+}