diff --git a/.idea/$PRODUCT_WORKSPACE_FILE$ b/.idea/$PRODUCT_WORKSPACE_FILE$ new file mode 100644 index 0000000..3733e0d --- /dev/null +++ b/.idea/$PRODUCT_WORKSPACE_FILE$ @@ -0,0 +1,19 @@ + + + + + + + 1.8 + + + + + + + + \ 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..012255a --- /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..81c2cd4 --- /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/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..dee43f1 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,111 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1583176489308 + + + + + + + \ No newline at end of file diff --git a/git_assignment_initial.iml b/git_assignment_initial.iml new file mode 100644 index 0000000..b107a2d --- /dev/null +++ b/git_assignment_initial.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/out/production/git_assignment_initial/.classpath b/out/production/git_assignment_initial/.classpath new file mode 100644 index 0000000..fceb480 --- /dev/null +++ b/out/production/git_assignment_initial/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/out/production/git_assignment_initial/.gitignore b/out/production/git_assignment_initial/.gitignore new file mode 100644 index 0000000..539bdba --- /dev/null +++ b/out/production/git_assignment_initial/.gitignore @@ -0,0 +1,56 @@ +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.settings/ +.loadpath +.recommenders + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# PyDev specific (Python IDE for Eclipse) +*.pydevproject + +# CDT-specific (C/C++ Development Tooling) +.cproject + +# CDT- autotools +.autotools + +# Java annotation processor (APT) +.factorypath + +# PDT-specific (PHP Development Tools) +.buildpath + +# sbteclipse plugin +.target + +# Tern plugin +.tern-project + +# TeXlipse plugin +.texlipse + +# STS (Spring Tool Suite) +.springBeans + +# Code Recommenders +.recommenders/ + +# Annotation Processing +.apt_generated/ +.apt_generated_test/ + +# Scala IDE specific (Scala & Java development for Eclipse) +.cache-main +.scala_dependencies +.worksheet \ No newline at end of file diff --git a/out/production/git_assignment_initial/.idea/$PRODUCT_WORKSPACE_FILE$ b/out/production/git_assignment_initial/.idea/$PRODUCT_WORKSPACE_FILE$ new file mode 100644 index 0000000..3733e0d --- /dev/null +++ b/out/production/git_assignment_initial/.idea/$PRODUCT_WORKSPACE_FILE$ @@ -0,0 +1,19 @@ + + + + + + + 1.8 + + + + + + + + \ No newline at end of file diff --git a/out/production/git_assignment_initial/.idea/codeStyles/codeStyleConfig.xml b/out/production/git_assignment_initial/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..a55e7a1 --- /dev/null +++ b/out/production/git_assignment_initial/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/out/production/git_assignment_initial/.idea/misc.xml b/out/production/git_assignment_initial/.idea/misc.xml new file mode 100644 index 0000000..012255a --- /dev/null +++ b/out/production/git_assignment_initial/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/out/production/git_assignment_initial/.idea/modules.xml b/out/production/git_assignment_initial/.idea/modules.xml new file mode 100644 index 0000000..81c2cd4 --- /dev/null +++ b/out/production/git_assignment_initial/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/out/production/git_assignment_initial/.idea/vcs.xml b/out/production/git_assignment_initial/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/out/production/git_assignment_initial/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/out/production/git_assignment_initial/.idea/workspace.xml b/out/production/git_assignment_initial/.idea/workspace.xml new file mode 100644 index 0000000..93158ff --- /dev/null +++ b/out/production/git_assignment_initial/.idea/workspace.xml @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1583176489308 + + + + + + + \ No newline at end of file diff --git a/out/production/git_assignment_initial/.project b/out/production/git_assignment_initial/.project new file mode 100644 index 0000000..a91a890 --- /dev/null +++ b/out/production/git_assignment_initial/.project @@ -0,0 +1,17 @@ + + + GitAssignmentObserver + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/out/production/git_assignment_initial/git_assignment_initial.iml b/out/production/git_assignment_initial/git_assignment_initial.iml new file mode 100644 index 0000000..b107a2d --- /dev/null +++ b/out/production/git_assignment_initial/git_assignment_initial.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/out/production/git_assignment_initial/src/CircleVolum.class b/out/production/git_assignment_initial/src/CircleVolum.class new file mode 100644 index 0000000..4b9e20d Binary files /dev/null and b/out/production/git_assignment_initial/src/CircleVolum.class differ diff --git a/out/production/git_assignment_initial/src/ISubscriber.class b/out/production/git_assignment_initial/src/ISubscriber.class new file mode 100644 index 0000000..2ef0f03 Binary files /dev/null and b/out/production/git_assignment_initial/src/ISubscriber.class differ diff --git a/out/production/git_assignment_initial/src/Main.class b/out/production/git_assignment_initial/src/Main.class new file mode 100644 index 0000000..b429552 Binary files /dev/null and b/out/production/git_assignment_initial/src/Main.class differ diff --git a/out/production/git_assignment_initial/src/MultiplicationSeries.class b/out/production/git_assignment_initial/src/MultiplicationSeries.class new file mode 100644 index 0000000..54f224f Binary files /dev/null and b/out/production/git_assignment_initial/src/MultiplicationSeries.class differ diff --git a/out/production/git_assignment_initial/src/ReallySimpleSubscriber.class b/out/production/git_assignment_initial/src/ReallySimpleSubscriber.class new file mode 100644 index 0000000..0e9a2d1 Binary files /dev/null and b/out/production/git_assignment_initial/src/ReallySimpleSubscriber.class differ diff --git a/out/production/git_assignment_initial/src/SimpleSubscriber.class b/out/production/git_assignment_initial/src/SimpleSubscriber.class new file mode 100644 index 0000000..69431a8 Binary files /dev/null and b/out/production/git_assignment_initial/src/SimpleSubscriber.class differ diff --git a/out/production/git_assignment_initial/src/SphereArea.class b/out/production/git_assignment_initial/src/SphereArea.class new file mode 100644 index 0000000..f1bd33e Binary files /dev/null and b/out/production/git_assignment_initial/src/SphereArea.class differ diff --git a/out/production/git_assignment_initial/src/SphereVolume.class b/out/production/git_assignment_initial/src/SphereVolume.class new file mode 100644 index 0000000..f6be0fc Binary files /dev/null and b/out/production/git_assignment_initial/src/SphereVolume.class differ diff --git a/out/production/git_assignment_initial/src/SummationSeries.class b/out/production/git_assignment_initial/src/SummationSeries.class new file mode 100644 index 0000000..2498874 Binary files /dev/null and b/out/production/git_assignment_initial/src/SummationSeries.class differ diff --git a/out/production/git_assignment_initial/src/Topic.class b/out/production/git_assignment_initial/src/Topic.class new file mode 100644 index 0000000..03ee8ab Binary files /dev/null and b/out/production/git_assignment_initial/src/Topic.class differ diff --git a/out/production/git_assignment_initial/src/fibonnachi_series.class b/out/production/git_assignment_initial/src/fibonnachi_series.class new file mode 100644 index 0000000..9eedd6d Binary files /dev/null and b/out/production/git_assignment_initial/src/fibonnachi_series.class differ diff --git a/out/production/git_assignment_initial/src/twoPowerN.class b/out/production/git_assignment_initial/src/twoPowerN.class new file mode 100644 index 0000000..ad4133f Binary files /dev/null and b/out/production/git_assignment_initial/src/twoPowerN.class differ diff --git a/src/CircleArea.java b/src/CircleArea.java new file mode 100644 index 0000000..ed97ad5 --- /dev/null +++ b/src/CircleArea.java @@ -0,0 +1,10 @@ +package src; + +public class CircleArea implements ISubscriber { + + @Override + public void notifySubscriber(String input) { + Double radius = Double.parseDouble(input); + System.out.println("The area of the circle is : "+ 3.14*radius*radius); + } +} diff --git a/src/CircleVolum.java b/src/CircleVolum.java new file mode 100644 index 0000000..45e23c6 --- /dev/null +++ b/src/CircleVolum.java @@ -0,0 +1,13 @@ +package src; + +public class CircleVolum implements ISubscriber { + + @Override + public void notifySubscriber(String input) { + // TODO Auto-generated method stub + double r=Double.parseDouble(input),pi=22.0/7.0; + double volume=(4.0/3.0)*pi*(r*r*r); + System.out.println("Volume="+volume); + + } +} diff --git a/src/ISubscriber.java b/src/ISubscriber.java index d3a605c..9c29e10 100644 --- a/src/ISubscriber.java +++ b/src/ISubscriber.java @@ -1,4 +1,5 @@ - -public interface ISubscriber { - public abstract void notifySubscriber(String input); -} +package src; + +public interface ISubscriber { + public abstract void notifySubscriber(String input); +} diff --git a/src/Main.java b/src/Main.java index 9b8c2b0..66e5a1a 100644 --- a/src/Main.java +++ b/src/Main.java @@ -1,17 +1,27 @@ +package src; + 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 MultiplicationSeries(), + new SphereVolume(), + new CircleArea(), + new CircleVolum(), + new SphereArea(), + new SummationSeries() + + }; + + public static void main(String[] args) { + Topic mathTopic = new Topic(); + for (ISubscriber sub : subscribers) { + mathTopic.addSubscriber(sub); + } + Scanner sc = new Scanner(System.in); + System.out.println("enter number: "); + String input = sc.next(); + mathTopic.dispatchEvent(input); + + } } diff --git a/src/MultiplicationSeries.java b/src/MultiplicationSeries.java new file mode 100644 index 0000000..18600d4 --- /dev/null +++ b/src/MultiplicationSeries.java @@ -0,0 +1,24 @@ +package src; +/* + OverView : A class calculates a multiplication series from 0 to N + Author : Lamya Raed Aly + ID : 20170399 + Group : CS-4 + */ + +public class MultiplicationSeries implements ISubscriber { + + public int MultSeries(int N){ + int answer =1; + for(int i=1; i<=N; i++){ + answer *= i; + } + return answer; + } + + @Override + public void notifySubscriber(String input) { + System.out.print("Hello, I am a multiplication series and I am notified with " + input); + System.out.println("and my result is : " + MultSeries(Integer.parseInt(input))); + } +} diff --git a/src/ReallySimpleSubscriber.java b/src/ReallySimpleSubscriber.java index fb1114a..9a5316d 100644 --- a/src/ReallySimpleSubscriber.java +++ b/src/ReallySimpleSubscriber.java @@ -1,8 +1,9 @@ - -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); - } -} +package src; + +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 index 5b0e4aa..6372150 100644 --- a/src/SimpleSubscriber.java +++ b/src/SimpleSubscriber.java @@ -1,10 +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); - } - -} +package src; +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 new file mode 100644 index 0000000..0c0eb10 --- /dev/null +++ b/src/SphereArea.java @@ -0,0 +1,16 @@ +package src; +public class SphereArea implements ISubscriber{ + public float SArea(float R){ + float result; + result=4*(float)(22.0/7.0)*(R*R); + return result; + } + + @Override + public void notifySubscriber(String input){ + System.out.println("Hello, I am a Sphere Area and I am notified with " + input); + System.out.println(" and my result is : " + SArea(Integer.parseInt(input))); + } +} + + diff --git a/src/SphereVolume.java b/src/SphereVolume.java new file mode 100644 index 0000000..b9d0957 --- /dev/null +++ b/src/SphereVolume.java @@ -0,0 +1,13 @@ +package src; +public class SphereVolume implements ISubscriber { + + @Override + public void notifySubscriber(String input) { + // TODO Auto-generated method stub + double radius = Double.parseDouble(input); + double Volume = (4*22*radius*radius*radius) / (3*7); + System.out.println("Volume=" + Volume); + } + +} + diff --git a/src/SummationSeries.java b/src/SummationSeries.java new file mode 100644 index 0000000..1a26671 --- /dev/null +++ b/src/SummationSeries.java @@ -0,0 +1,20 @@ +package src; +/* +Name: Omar Khaled Ali +ID: 20170374 +*/ +public class SummationSeries implements ISubscriber { + private int Sum (int num){ + int sum = 0; + for(int i=1 ; i<=num ; i++){ + sum += i; + } + return sum; + } + + @Override + public void notifySubscriber(String input) { + System.out.print("\nHello, I am Summation series and I am notified with: " + input + "\n"); + System.out.println("result: " + Sum(Integer.parseInt(input))); + } +} diff --git a/src/Topic.java b/src/Topic.java index 8fa2e2e..21b5290 100644 --- a/src/Topic.java +++ b/src/Topic.java @@ -1,25 +1,27 @@ -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); - } - } -} +package src; + +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/fibonnachi_series.java b/src/fibonnachi_series.java new file mode 100644 index 0000000..3c50bf3 --- /dev/null +++ b/src/fibonnachi_series.java @@ -0,0 +1,25 @@ +package src; +/* fibonnachi series + name: omar mahmoud salah + id:20160163 +*/ +public class fibonnachi_series implements ISubscriber { + + static int fibb(int N) { + if (N <= 1) + return N; + else { + + return fibb(N - 1) + fibb(N - 2); + } + + } + + public void notifySubscriber(String input) { + + System.out.print("Hello, I am fibonnachi series and I am notified with " + input); + + System.out.println(" and my result is : " + fibb(Integer.parseInt(input))); + } +} + diff --git a/src/twoPowerN.java b/src/twoPowerN.java new file mode 100644 index 0000000..4bd2c99 --- /dev/null +++ b/src/twoPowerN.java @@ -0,0 +1,13 @@ +package src; + + +public class twoPowerN implements ISubscriber { + + @Override + public void notifySubscriber(String input) { + long num = Long.parseLong(input); + long res = 1; + System.out.println(res << num); + } + +}