=gHm4*49N>^h
K$$6qH;ph*7^S%cF
literal 0
HcmV?d00001
diff --git a/src/SimpleSubscriber.class b/src/SimpleSubscriber.class
new file mode 100644
index 0000000000000000000000000000000000000000..a5fbbbdbbdf7860ecc4e71da66ecef88a44f802a
GIT binary patch
literal 775
zcmZuv%TC)s6g?A?I2gAyfe`vOg_Z;;Ub0BlMJrWBib^F{kyuXRDGaj5mOZB8v&te!
zRO$!xqpIGqqoyQX_|Dwd@ww;Duiv*n0UW`zP+@rB%P0wjpO3O}Dn}x!JS$_UzmZDnw+u_&-jJdCJ`RM9C9F8G&|p{{NF_ey5n+Deqfjuk
z2Jx7OL!L_GPlHu`E;EyxC(-UDsSVP;w`W@!}Ri;Jc
zU;`Z@8RwdzT{g?u`%Imh`UQ{r79KKm=3(FEG7Lo8z+;A^k0K1?1NYeFk;~nz(9F&L
ziso_^l*xjz6oLCq>T}n|CY~BSn&$T0fr~9tjwgvw0mJM64YM%clt|w|Y&+P&ONNGy
z%i$T;yS;@Ls@+A;LYHB!nCtGu4))Mwuo5Fes2FNeB}SjtA`*k`$9XyyAEen~dwxxa
z1|M4>iRr7+)2h%(FM#Yac^;jN&f4A$?C(X|AzLqk72Kn{Qx@PpR>`9sqDj^?pP))`
yK<65*AJ{x?J-We@{Ry5;@M3~jGdQ~_vuM|i0&=5ln?e!*_HjU+iufX6kR7x;>1{`4JnsW26In
l=b9J`2jB)(@D
zDO4cM2k<{UjWl8%CsGQ9ab%y1_g;Iib(Zt>zt8^wxQZ7B5&~Ae*O7s2_-@pd29g3(
zuboY&2dS5Y=s8W0=ug9sM&7?swo43)TZM`Qb1G$GK(!&c`CdqFi|Kr1d@0B
zwoKpp_AI`#5ZGyXU_p
zsY0bvtYmQqVL5TXheki*ZPNBePKMDnAYB7}ZOKXAh!g?4;r&~5~T43L}2)C8D
zu@Wh_ErSfs3Y=T-NP9Du+xB1Cjy+^xzg1y}s|~d&J-ecut_)?MBTN*rpk*krXkl12
zKAjq)OIFh?nN1dkdiXK|
z$#a-1RQ|8p5|y`GQB$?-m{)&6C*QKLjN5cj=nuIFf9^u*}_2|zk6$zZSifEqnP<0-x=ZEUmyRo57tm3hOM*`F1qpNzM+>n8VH9R3`
z&k6dHd%rn^s!5;ME$qX7DyzJn_DF7rc9hDj`%%!6_muYk^macl=;CxFEyg>=+tl9;
z4V>gN%N4&vu1+DLT@51->u*f{#c2Xle5M(ogQw#iaK(>jlvLuV-=&=8db(kotXTnn;y%YDuAs^p<;Dp-ApZpC520yj
z4c0j7c=OB_YD;rlcsi~y8NWF|1!u`(ZX3Ee;->!+*71xODgF%B(dZ50CGh+^38xkl
literal 0
HcmV?d00001
diff --git a/src/SphereVolume.java b/src/SphereVolume.java
new file mode 100644
index 0000000..3ce6b89
--- /dev/null
+++ b/src/SphereVolume.java
@@ -0,0 +1,32 @@
+import java.lang.Math;
+public class SphereVolume implements ISubscriber {
+
+ private static double value = 4.0/3.0;
+
+
+
+ public static void sphereVolume(int diameter) {
+ /*calculating the volume of a sphere requires two constant inputs and a variable one.
+
+ 1- (variable)a radius (which can be calculated from the given diameter).
+ 2- (constant)Pi, which simply = 3.14 or 22/7.
+ 3- (constant)the value (4/3).
+
+ */
+ int radius = diameter/2;
+ double volume = value*(Math.PI)*Math.pow(radius, 3); // value;
+ System.out.println("The volume of a sphere with a given Diameter of " + diameter + "cm = " + volume + " cubic meters.");
+
+
+ }
+
+ @Override
+ public void notifySubscriber(String input) {
+ int value = Integer.parseInt(input);
+ sphereVolume(value);
+
+ }
+
+
+
+}
diff --git a/src/Topic.class b/src/Topic.class
new file mode 100644
index 0000000000000000000000000000000000000000..298ca71d599d6f39a809945facb6d80bb2f290a3
GIT binary patch
literal 1189
zcmZWn+fEZv6kTU%8QM+@lv2EMQ)F5$RlJ}ULGY506nrSD(YI+kmV0uyJ_E4j`5>GSL=
ztNT}^BfV9DJ~LGi2t28k?J)WfH4s8r$DqJShhp7ztpmjqMhwvq1mXsQ=oc8wNypx9
zzN4%it5_v>JXb4O)q>?pb#Dg)-mauL!4|sM+eY%c^YZHM4Y!Bt4i!s@PtKlzQT3>WovAHgzs|-o9vAHtLpF+I_Zf
zJDg6Bj=bker;<$-!Zd2uz!aucHz@;Y%n1xg&vq@Z<_aWxs5aa2Yy=C)=vbt{PVXmK
z12=Jt6LakMBu<&ylWz_>J}9>P1|Hxc2efN7wtZmk
z1$_)kr`{w@yvycxd$c$2S*5pIR^1=6jfQy!Z~sO
z1vIrwJayhQ3?RUNZXv%BMmAU_cn+lxVWfW|_UaHr-!S~euO8ty=HsY$Aq?_ef-$4@
z2BS#wCNPEzZM>)C&{ReGD~9Kea8bj{4p!LDMadlVagwdtHjcubz$B5lCzxigrTLn#
zG~>sCphEsk3Jpr0Y7H3fk`+9absaOzsy08cI>6IRf5(j@m;&3MkXSgvyufcPZOv2a
z9SsaD3w%8Ot0edN_;LT;C|gWooXE3mRar3U+hU$dH<85(*~TbZHKE}Vs}j(T5k)|U
R(6P$Y0
Date: Sat, 29 Feb 2020 19:31:00 +0200
Subject: [PATCH 14/78] Delete ISubscriber.class
---
src/ISubscriber.class | Bin 154 -> 0 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 src/ISubscriber.class
diff --git a/src/ISubscriber.class b/src/ISubscriber.class
deleted file mode 100644
index fe408e49e06f565007fbecc6939dbe0133eb4091..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 154
zcmX^0Z`VEs1_pBmPId++Mh0%r;L@bx
From 21acc1b3785ccd542b811826d4ae90470736d3c5 Mon Sep 17 00:00:00 2001
From: Abdulelah <58626327+AbdulelahAdam@users.noreply.github.com>
Date: Sat, 29 Feb 2020 19:31:29 +0200
Subject: [PATCH 15/78] Delete Main.class
---
src/Main.class | Bin 1171 -> 0 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 src/Main.class
diff --git a/src/Main.class b/src/Main.class
deleted file mode 100644
index 1b2fa6c72af7c8cb6c8e72444da1a0395dd770cd..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1171
zcmZuxT~8BH5IwiM?Y3p16ex&@0xGn8RS`ibf{LId1rwJvsXQ&)4J>ZAO}i!X?jP~V
zXEA}qM&9+;_zTo?7s5xNN$;JVJu`FW%(TD%{x|_Ji!}`)0d?JUJPoQq`<}UPW?j?U
z$-dj(vn^ksrQX=CTQz6fuGIzFw(@Jnxg#eKU9eoobNodCC7mfS*>a_1YiMEQC8UN{
zW;dL2)wM6;x88)Z9=E+k?Q
zxTPbEh(IFmc=kr4Ov;<)wrdM?p95zc3KFF2?>g)&l9w8=AGOSz4ANWq
z3oQ)4=6E}~OhLn-KzOrKb*wlBkdVg%9S<=q&}x=S7p<||^cAUOa9SW4WNrA4n>8%c
z^Xys-qZrpPc13;Tpzhmc9TS)o2uVh%Q$9{5yXI9JJ}KE|ITyzW9!Uisv;FjqkW4{>
zp6HmyQ}*ZCpE%X7bmn@0vYS~Q&oIYsN>06M`qu8szU?s}b(TEXjdMMidiGzs?)v
z5{Q*ee>YG|K+6XPC04jmEO12~Hd(ir=9JWBc^D9OWXE!f*G9rThHqLQ*Uf4$RSh{!
zu0Y(VG-{T;>d5KGPt-wkjha05Ix2D@X3s-EPh3MZ@7PIeQf*)
z_dhG5Kc#;8_os=G;vq7}$ga~rwJ|nvgc(^@3D^&j7pO=SE$HKKa)5URZQPgy=E!;x
z$$-*ypw1HJkt06JKad4HC#gRA7qP@Hry2PIFKNw@;wvn(!fRr?5&Fj?qG3g2dLcBd
Nf|Uf`@NEch{{sTh^DqDa
From c29f2a06c80b628a8b4524fdc535d5132c5bef62 Mon Sep 17 00:00:00 2001
From: Abdulelah <58626327+AbdulelahAdam@users.noreply.github.com>
Date: Sat, 29 Feb 2020 19:31:52 +0200
Subject: [PATCH 16/78] Delete ReallySimpleSubscriber.class
---
src/ReallySimpleSubscriber.class | Bin 800 -> 0 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 src/ReallySimpleSubscriber.class
diff --git a/src/ReallySimpleSubscriber.class b/src/ReallySimpleSubscriber.class
deleted file mode 100644
index 94179cb01f5ce1f075364d2dd2865aa664f6289b..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 800
zcmZuv%Wl&^6g`tBaq1dM(&ho>F{M0`w$w`&L0y1^s1#8|sz@v+@wA<4{E$5c<+EUs
zN+9t8d=%o^jtC`L_|Dw%J!j56cYgi;{u97UxE4wbt&dV@Jsm1P(sG!NlS!<`GPY1=
zxN{{w3s;Na!aW^d$%(O0W!N}blrdCasX&=yhP7^Q#87?{deX)kHXK-}F>DT0Am67x
zah{2>mJE$SI1zdzVwL6d!?L+l2}5VFT27zD1ffyq(|_-7b_WZELldjuqTd^>V+&0S
z+c)$Nr-_ligBIE(HB1ddvjD5m{Xj@Vcq#n8g}V&x|7l;RN_#S{VTa-Pozyx!!KI#lslzE{8hKdTJ%%;XN6N5br
z(|97^s%)S;t7mqU-GW_^-}F`J&6Q}SM?rC&GM83HYi0i$_SgKkL$R74mT-&qPEml{
z*rbdGiaNy%e2OyB0qt*S{6ObZ=gHm4*49N>^h
K$$6qH;ph*7^S%cF
From 976495335959c6fd7d41602b1c66969a0af26f76 Mon Sep 17 00:00:00 2001
From: Abdulelah <58626327+AbdulelahAdam@users.noreply.github.com>
Date: Sat, 29 Feb 2020 19:32:32 +0200
Subject: [PATCH 17/78] Delete SimpleSubscriber.class
---
src/SimpleSubscriber.class | Bin 775 -> 0 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 src/SimpleSubscriber.class
diff --git a/src/SimpleSubscriber.class b/src/SimpleSubscriber.class
deleted file mode 100644
index a5fbbbdbbdf7860ecc4e71da66ecef88a44f802a..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 775
zcmZuv%TC)s6g?A?I2gAyfe`vOg_Z;;Ub0BlMJrWBib^F{kyuXRDGaj5mOZB8v&te!
zRO$!xqpIGqqoyQX_|Dwd@ww;Duiv*n0UW`zP+@rB%P0wjpO3O}Dn}x!JS$_UzmZDnw+u_&-jJdCJ`RM9C9F8G&|p{{NF_ey5n+Deqfjuk
z2Jx7OL!L_GPlHu`E;EyxC(-UDsSVP;w`W@!}Ri;Jc
zU;`Z@8RwdzT{g?u`%Imh`UQ{r79KKm=3(FEG7Lo8z+;A^k0K1?1NYeFk;~nz(9F&L
ziso_^l*xjz6oLCq>T}n|CY~BSn&$T0fr~9tjwgvw0mJM64YM%clt|w|Y&+P&ONNGy
z%i$T;yS;@Ls@+A;LYHB!nCtGu4))Mwuo5Fes2FNeB}SjtA`*k`$9XyyAEen~dwxxa
z1|M4>iRr7+)2h%(FM#Yac^;jN&f4A$?C(X|AzLqk72Kn{Qx@PpR>`9sqDj^?pP))`
yK<65*AJ{x?J-We@{Ry5;@M3~jGdQ~_vuM|i0&=5ln?e!*_HjU
Date: Sat, 29 Feb 2020 19:33:47 +0200
Subject: [PATCH 18/78] Delete SphereVolume.class
---
src/SphereVolume.class | Bin 1314 -> 0 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 src/SphereVolume.class
diff --git a/src/SphereVolume.class b/src/SphereVolume.class
deleted file mode 100644
index 4e027c95f0a4ed856a97c15cb7abe1da05fffe5e..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1314
zcmaJ>+iufX6kR7x;>1{`4JnsW26In
l=b9J`2jB)(@D
zDO4cM2k<{UjWl8%CsGQ9ab%y1_g;Iib(Zt>zt8^wxQZ7B5&~Ae*O7s2_-@pd29g3(
zuboY&2dS5Y=s8W0=ug9sM&7?swo43)TZM`Qb1G$GK(!&c`CdqFi|Kr1d@0B
zwoKpp_AI`#5ZGyXU_p
zsY0bvtYmQqVL5TXheki*ZPNBePKMDnAYB7}ZOKXAh!g?4;r&~5~T43L}2)C8D
zu@Wh_ErSfs3Y=T-NP9Du+xB1Cjy+^xzg1y}s|~d&J-ecut_)?MBTN*rpk*krXkl12
zKAjq)OIFh?nN1dkdiXK|
z$#a-1RQ|8p5|y`GQB$?-m{)&6C*QKLjN5cj=nuIFf9^u*}_2|zk6$zZSifEqnP<0-x=ZEUmyRo57tm3hOM*`F1qpNzM+>n8VH9R3`
z&k6dHd%rn^s!5;ME$qX7DyzJn_DF7rc9hDj`%%!6_muYk^macl=;CxFEyg>=+tl9;
z4V>gN%N4&vu1+DLT@51->u*f{#c2Xle5M(ogQw#iaK(>jlvLuV-=&=8db(kotXTnn;y%YDuAs^p<;Dp-ApZpC520yj
z4c0j7c=OB_YD;rlcsi~y8NWF|1!u`(ZX3Ee;->!+*71xODgF%B(dZ50CGh+^38xkl
From 0071696e6f86560d2419a9777f37e9462925def5 Mon Sep 17 00:00:00 2001
From: Abdulelah <58626327+AbdulelahAdam@users.noreply.github.com>
Date: Sat, 29 Feb 2020 19:34:26 +0200
Subject: [PATCH 19/78] Delete Topic.class
---
src/Topic.class | Bin 1189 -> 0 bytes
1 file changed, 0 insertions(+), 0 deletions(-)
delete mode 100644 src/Topic.class
diff --git a/src/Topic.class b/src/Topic.class
deleted file mode 100644
index 298ca71d599d6f39a809945facb6d80bb2f290a3..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 1189
zcmZWn+fEZv6kTU%8QM+@lv2EMQ)F5$RlJ}ULGY506nrSD(YI+kmV0uyJ_E4j`5>GSL=
ztNT}^BfV9DJ~LGi2t28k?J)WfH4s8r$DqJShhp7ztpmjqMhwvq1mXsQ=oc8wNypx9
zzN4%it5_v>JXb4O)q>?pb#Dg)-mauL!4|sM+eY%c^YZHM4Y!Bt4i!s@PtKlzQT3>WovAHgzs|-o9vAHtLpF+I_Zf
zJDg6Bj=bker;<$-!Zd2uz!aucHz@;Y%n1xg&vq@Z<_aWxs5aa2Yy=C)=vbt{PVXmK
z12=Jt6LakMBu<&ylWz_>J}9>P1|Hxc2efN7wtZmk
z1$_)kr`{w@yvycxd$c$2S*5pIR^1=6jfQy!Z~sO
z1vIrwJayhQ3?RUNZXv%BMmAU_cn+lxVWfW|_UaHr-!S~euO8ty=HsY$Aq?_ef-$4@
z2BS#wCNPEzZM>)C&{ReGD~9Kea8bj{4p!LDMadlVagwdtHjcubz$B5lCzxigrTLn#
zG~>sCphEsk3Jpr0Y7H3fk`+9absaOzsy08cI>6IRf5(j@m;&3MkXSgvyufcPZOv2a
z9SsaD3w%8Ot0edN_;LT;C|gWooXE3mRar3U+hU$dH<85(*~TbZHKE}Vs}j(T5k)|U
R(6P$Y0
Date: Sat, 29 Feb 2020 19:40:06 +0200
Subject: [PATCH 20/78] Function takes a double instead of int.
---
src/SphereVolume.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/SphereVolume.java b/src/SphereVolume.java
index 3ce6b89..2a29799 100644
--- a/src/SphereVolume.java
+++ b/src/SphereVolume.java
@@ -5,7 +5,7 @@ public class SphereVolume implements ISubscriber {
- public static void sphereVolume(int diameter) {
+ public static void sphereVolume(double diameter) {
/*calculating the volume of a sphere requires two constant inputs and a variable one.
1- (variable)a radius (which can be calculated from the given diameter).
@@ -13,7 +13,7 @@ public static void sphereVolume(int diameter) {
3- (constant)the value (4/3).
*/
- int radius = diameter/2;
+ double radius = diameter/2;
double volume = value*(Math.PI)*Math.pow(radius, 3); // value;
System.out.println("The volume of a sphere with a given Diameter of " + diameter + "cm = " + volume + " cubic meters.");
@@ -22,7 +22,7 @@ public static void sphereVolume(int diameter) {
@Override
public void notifySubscriber(String input) {
- int value = Integer.parseInt(input);
+ double value = Double.parseDouble(input);
sphereVolume(value);
}
From 33c6e0ca695c34b9058d49e3e7da9dfe10051c3f Mon Sep 17 00:00:00 2001
From: merna ezzat
Date: Sun, 1 Mar 2020 10:59:38 +0200
Subject: [PATCH 21/78] adding new class CircleArea
---
src/CircleArea.java | 27 +++++++++++++++++++++++++++
src/Main.java | 1 +
2 files changed, 28 insertions(+)
create mode 100644 src/CircleArea.java
diff --git a/src/CircleArea.java b/src/CircleArea.java
new file mode 100644
index 0000000..f9574c1
--- /dev/null
+++ b/src/CircleArea.java
@@ -0,0 +1,27 @@
+
+public class CircleArea implements ISubscriber {
+
+ @Override
+ public void notifySubscriber(String input) {
+ System.out.println("Hello, I am Circle Area and I am notified with " + input);
+
+ double radius;
+ try {
+ radius = Double.parseDouble(input);
+ if (radius < 0) {
+ System.out.println("Radius is negative.");
+ return;
+ }
+
+ } catch (NumberFormatException ignored) {
+ System.out.println("Radius is not a number.");
+ return;
+ }
+
+ System.out.println("Radius is " + radius + ", Circle Area is: " + calculat(radius));
+ }
+
+ public double calculat(double input) {
+ return Math.PI * input *input;
+ }
+}
diff --git a/src/Main.java b/src/Main.java
index 9b8c2b0..4dfe564 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -4,6 +4,7 @@ public class Main {
private static ISubscriber subscribers [] = {
new SimpleSubscriber(),
new ReallySimpleSubscriber(),
+ new CircleArea(),
};
public static void main(String[] args) {
Topic mathTopic = new Topic();
From 520b6b1b8d7909866046f29d771a921487052bbd Mon Sep 17 00:00:00 2001
From: marim medhat
Date: Sun, 1 Mar 2020 11:19:39 +0200
Subject: [PATCH 22/78] adding new class CircleArea by 20170282
---
src/CircleArea.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/CircleArea.java b/src/CircleArea.java
index f9574c1..150d8cc 100644
--- a/src/CircleArea.java
+++ b/src/CircleArea.java
@@ -18,7 +18,7 @@ public void notifySubscriber(String input) {
return;
}
- System.out.println("Radius is " + radius + ", Circle Area is: " + calculat(radius));
+ System.out.println("Radius is " + radius + ", Area is: " + calculat(radius));
}
public double calculat(double input) {
From 779391eccb1dce7c152e2fbeb63e5c45507fab56 Mon Sep 17 00:00:00 2001
From: Amr Magdy <36246549+amrmagdy12@users.noreply.github.com>
Date: Sun, 1 Mar 2020 18:40:18 +0200
Subject: [PATCH 23/78] Initialversion
added a class Fibonacci which calculates the fibonacci series for large numbers and have a minor changes in Main
---
src/Fibonacci.java | 35 +++++++++++++++++++++++++++++++++++
src/Main.java | 6 ++++--
2 files changed, 39 insertions(+), 2 deletions(-)
create mode 100644 src/Fibonacci.java
diff --git a/src/Fibonacci.java b/src/Fibonacci.java
new file mode 100644
index 0000000..c85019e
--- /dev/null
+++ b/src/Fibonacci.java
@@ -0,0 +1,35 @@
+package com.company ;
+public class Fibonacci implements ISubscriber {
+ @Override
+ public void notifySubscriber(int n) {
+ int pascTriangle[][] = new int [n][n] ;
+ pascTriangle[1][0] = 1;
+ pascTriangle[1][1] = 1;
+
+ if (n == 1 || n == 2) System.out.println("Result is:" +1) ;
+ else {
+ // drawing pascal's triangle as a base for Fibonnacii
+ for (int i = 2; i <= n; i++) {
+ pascTriangle[i][0] = 1;
+ for (int j = 1; j <= i; j++) {
+ pascTriangle[i][j] = pascTriangle[i - 1][j - 1] + pascTriangle[i - 1][j];
+ }
+ pascTriangle[i][i] = 1;
+ }
+
+ int i = n - 1;
+ int j = 0;
+ int result = 0;
+
+ while (j <= i)
+ {
+ result += pascTriangle[i][j];
+ i--;
+ j++;
+
+ }
+
+ System.out.println("Result is:" +result) ;
+ }
+ }
+}
diff --git a/src/Main.java b/src/Main.java
index 9b8c2b0..5187553 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -1,9 +1,11 @@
+package com.company;
+
import java.util.Scanner;
public class Main {
private static ISubscriber subscribers [] = {
new SimpleSubscriber(),
- new ReallySimpleSubscriber(),
+ new Fibonacci(),
};
public static void main(String[] args) {
Topic mathTopic = new Topic();
@@ -11,7 +13,7 @@ public static void main(String[] args) {
mathTopic.addSubscriber(sub);
}
Scanner sc = new Scanner(System.in);
- String input = sc.next();
+ int input = sc.nextInt() ;
mathTopic.dispatchEvent(input);
}
}
From c6a4b90e9a5ce9f73d933c4cad8837cc2d8eb289 Mon Sep 17 00:00:00 2001
From: Abdulelah <58626327+AbdulelahAdam@users.noreply.github.com>
Date: Sun, 1 Mar 2020 19:22:58 +0200
Subject: [PATCH 24/78] Function now takes the radius instead of a diameter.
---
src/SphereVolume.java | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/SphereVolume.java b/src/SphereVolume.java
index 2a29799..2b3b9a8 100644
--- a/src/SphereVolume.java
+++ b/src/SphereVolume.java
@@ -5,17 +5,17 @@ public class SphereVolume implements ISubscriber {
- public static void sphereVolume(double diameter) {
+ public static void sphereVolume(double radius) {
/*calculating the volume of a sphere requires two constant inputs and a variable one.
- 1- (variable)a radius (which can be calculated from the given diameter).
+ 1- (variable)a radius (which is given).
2- (constant)Pi, which simply = 3.14 or 22/7.
3- (constant)the value (4/3).
- */
- double radius = diameter/2;
- double volume = value*(Math.PI)*Math.pow(radius, 3); // value;
- System.out.println("The volume of a sphere with a given Diameter of " + diameter + "cm = " + volume + " cubic meters.");
+ */
+
+ double volume = value*(Math.PI)*Math.pow(radius, 3);
+ System.out.println("The volume of a sphere with a given Radius of " + radius + "cm = " + volume + " cubic meters.");
}
From 0ebc25cc7f3f284be375f8be00f62de105f7fe8e Mon Sep 17 00:00:00 2001
From: mohamed magdy <36678529+devmagdyy@users.noreply.github.com>
Date: Sun, 1 Mar 2020 19:43:44 +0200
Subject: [PATCH 25/78] 20160219-MultiplicationSeise
I add my class called (MultiplicationSeriess) , it recive interger value therefor i change every string in src code from string to int , because i think we all use integer value in in him function ,
---
.idea/.name | 1 +
.idea/misc.xml | 6 ++++
.idea/modules.xml | 8 +++++
.idea/vcs.xml | 6 ++++
.idea/workspace.xml | 58 ++++++++++++++++++++++++++++++++++
GitAssignmentObserver.iml | 12 +++++++
src/ISubscriber.java | 2 +-
src/Main.java | 3 +-
src/Multiplicationseriess.java | 14 ++++++++
src/Topic.java | 2 +-
10 files changed, 109 insertions(+), 3 deletions(-)
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 .idea/workspace.xml
create mode 100644 GitAssignmentObserver.iml
create mode 100644 src/Multiplicationseriess.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/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/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..6b1befe
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,58 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1583076785152
+
+
+ 1583076785152
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ 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/ISubscriber.java b/src/ISubscriber.java
index d3a605c..7e3d582 100644
--- a/src/ISubscriber.java
+++ b/src/ISubscriber.java
@@ -1,4 +1,4 @@
public interface ISubscriber {
- public abstract void notifySubscriber(String input);
+ public abstract void notifySubscriber(int input);
}
diff --git a/src/Main.java b/src/Main.java
index 9b8c2b0..f880665 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -4,6 +4,7 @@ public class Main {
private static ISubscriber subscribers [] = {
new SimpleSubscriber(),
new ReallySimpleSubscriber(),
+
};
public static void main(String[] args) {
Topic mathTopic = new Topic();
@@ -11,7 +12,7 @@ public static void main(String[] args) {
mathTopic.addSubscriber(sub);
}
Scanner sc = new Scanner(System.in);
- String input = sc.next();
+ int input = sc.nextInt();
mathTopic.dispatchEvent(input);
}
}
diff --git a/src/Multiplicationseriess.java b/src/Multiplicationseriess.java
new file mode 100644
index 0000000..6e131e3
--- /dev/null
+++ b/src/Multiplicationseriess.java
@@ -0,0 +1,14 @@
+public class Multiplicationseriess implements ISubscriber {
+ public int m(int n){
+ int result = 1;
+ for(int i=0; i<=n; i++){
+ result = result*i;
+ }
+ return result;
+ }
+ @Override
+ public void notifySubscriber(int input) {
+ System.out.println("Hello, I am really a simple subscriber and I am notified with " + input);
+ System.out.println("and my result is : " + m(input));
+ }
+}
diff --git a/src/Topic.java b/src/Topic.java
index 8fa2e2e..c147e76 100644
--- a/src/Topic.java
+++ b/src/Topic.java
@@ -17,7 +17,7 @@ public List getSubscribers() {
return subscribers;
}
- public void dispatchEvent(String input) {
+ public void dispatchEvent(int input) {
for (ISubscriber sub : this.getSubscribers()) {
sub.notifySubscriber(input);
}
From 42dbb2230364e784e3efdec889eeadf510395005 Mon Sep 17 00:00:00 2001
From: Abdulazizsayed
Date: Sun, 1 Mar 2020 21:09:43 +0200
Subject: [PATCH 26/78] Initial code for two power N
---
src/Main.java | 1 +
src/TowPowerN.java | 13 +++++++++++++
2 files changed, 14 insertions(+)
create mode 100644 src/TowPowerN.java
diff --git a/src/Main.java b/src/Main.java
index 9b8c2b0..f6f808f 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -4,6 +4,7 @@ public class Main {
private static ISubscriber subscribers [] = {
new SimpleSubscriber(),
new ReallySimpleSubscriber(),
+ new TowPowerN(),
};
public static void main(String[] args) {
Topic mathTopic = new Topic();
diff --git a/src/TowPowerN.java b/src/TowPowerN.java
new file mode 100644
index 0000000..052bf44
--- /dev/null
+++ b/src/TowPowerN.java
@@ -0,0 +1,13 @@
+
+public class TowPowerN implements ISubscriber {
+ @Override
+ public void notifySubscriber(String input) {
+ int p = Integer.parseInt(input), res = 2;
+
+ for(int i = 1 ; i < p ; i++){
+ res += res;
+ }
+
+ System.out.println(res);
+ }
+}
\ No newline at end of file
From 2fa8601008cc37961cbe33faf0aa55abf61760e8 Mon Sep 17 00:00:00 2001
From: Ahmed Dardery
Date: Sun, 1 Mar 2020 23:19:52 +0200
Subject: [PATCH 27/78] no packaging
---
src/Fibonacci.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/Fibonacci.java b/src/Fibonacci.java
index c85019e..8641aa3 100644
--- a/src/Fibonacci.java
+++ b/src/Fibonacci.java
@@ -1,4 +1,3 @@
-package com.company ;
public class Fibonacci implements ISubscriber {
@Override
public void notifySubscriber(int n) {
From 7430a189825255ae9a7479eb48568fc0655de7dc Mon Sep 17 00:00:00 2001
From: Ahmed Dardery
Date: Sun, 1 Mar 2020 23:20:48 +0200
Subject: [PATCH 28/78] do NOT violate the subscriber format
---
src/Fibonacci.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/Fibonacci.java b/src/Fibonacci.java
index 8641aa3..69bc013 100644
--- a/src/Fibonacci.java
+++ b/src/Fibonacci.java
@@ -1,6 +1,7 @@
public class Fibonacci implements ISubscriber {
@Override
- public void notifySubscriber(int n) {
+ public void notifySubscriber(String s) {
+ int n = Integer.parseInt(s);
int pascTriangle[][] = new int [n][n] ;
pascTriangle[1][0] = 1;
pascTriangle[1][1] = 1;
From a2a72018a99986d3ddbfd8133d066224159b9073 Mon Sep 17 00:00:00 2001
From: Ahmed Dardery
Date: Sun, 1 Mar 2020 23:21:08 +0200
Subject: [PATCH 29/78] Update Main.java
---
src/Main.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/Main.java b/src/Main.java
index b13bb11..eaaee8b 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -1,5 +1,3 @@
-package com.company;
-
import java.util.Scanner;
public class Main {
@@ -15,7 +13,7 @@ public static void main(String[] args) {
mathTopic.addSubscriber(sub);
}
Scanner sc = new Scanner(System.in);
- int input = sc.nextInt() ;
+ String input = sc.next() ;
mathTopic.dispatchEvent(input);
}
}
From 9c20c22d15ad176784a3fe7662240f38819d0a20 Mon Sep 17 00:00:00 2001
From: Ahmed Dardery
Date: Sun, 1 Mar 2020 23:21:29 +0200
Subject: [PATCH 30/78] spacing
---
src/Main.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Main.java b/src/Main.java
index eaaee8b..085e6cb 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -13,7 +13,7 @@ public static void main(String[] args) {
mathTopic.addSubscriber(sub);
}
Scanner sc = new Scanner(System.in);
- String input = sc.next() ;
+ String input = sc.next();
mathTopic.dispatchEvent(input);
}
}
From 37d2b5170e8fccb8a53ed21378c22e90bca11a4c Mon Sep 17 00:00:00 2001
From: Ahmed Dardery
Date: Sun, 1 Mar 2020 23:53:34 +0200
Subject: [PATCH 31/78] broken fibonacci
crashes for 5
---
src/Fibonacci.java | 35 -----------------------------------
1 file changed, 35 deletions(-)
delete mode 100644 src/Fibonacci.java
diff --git a/src/Fibonacci.java b/src/Fibonacci.java
deleted file mode 100644
index 69bc013..0000000
--- a/src/Fibonacci.java
+++ /dev/null
@@ -1,35 +0,0 @@
-public class Fibonacci implements ISubscriber {
- @Override
- public void notifySubscriber(String s) {
- int n = Integer.parseInt(s);
- int pascTriangle[][] = new int [n][n] ;
- pascTriangle[1][0] = 1;
- pascTriangle[1][1] = 1;
-
- if (n == 1 || n == 2) System.out.println("Result is:" +1) ;
- else {
- // drawing pascal's triangle as a base for Fibonnacii
- for (int i = 2; i <= n; i++) {
- pascTriangle[i][0] = 1;
- for (int j = 1; j <= i; j++) {
- pascTriangle[i][j] = pascTriangle[i - 1][j - 1] + pascTriangle[i - 1][j];
- }
- pascTriangle[i][i] = 1;
- }
-
- int i = n - 1;
- int j = 0;
- int result = 0;
-
- while (j <= i)
- {
- result += pascTriangle[i][j];
- i--;
- j++;
-
- }
-
- System.out.println("Result is:" +result) ;
- }
- }
-}
From 8ddacdc815f4d3e622c855c5a1ce7e7b16b9f702 Mon Sep 17 00:00:00 2001
From: Ahmed Dardery
Date: Sun, 1 Mar 2020 23:54:02 +0200
Subject: [PATCH 32/78] broken fibonacci
---
src/Main.java | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/src/Main.java b/src/Main.java
index 1d5c67b..15f899b 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -5,9 +5,8 @@ public class Main {
new SimpleSubscriber(),
new ReallySimpleSubscriber(),
new SphereCircumference(),
- new Fibonacci(),
- new SphereVolume(),
- new CircleCircumference(),
+ new SphereVolume(),
+ new CircleCircumference(),
};
public static void main(String[] args) {
Topic mathTopic = new Topic();
From 2259809e8604467b2f54db2015fd138924000d24 Mon Sep 17 00:00:00 2001
From: Ahmed Dardery
Date: Mon, 2 Mar 2020 00:06:18 +0200
Subject: [PATCH 33/78] changed input to int.
---
src/SphereCircumference.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/SphereCircumference.java b/src/SphereCircumference.java
index 1c2c086..bc0374e 100644
--- a/src/SphereCircumference.java
+++ b/src/SphereCircumference.java
@@ -3,9 +3,9 @@ public class SphereCircumference implements ISubscriber {
public void notifySubscriber(String input) {
System.out.println("Hello, I am Sphere Circumference and I am notified with " + input);
- double radius;
+ int radius;
try {
- radius = Double.parseDouble(input);
+ radius = Integer.parseInt(input);
if (radius < 0) {
System.out.println("Radius is negative.");
return;
@@ -19,7 +19,7 @@ public void notifySubscriber(String input) {
System.out.println("Radius is " + radius + ", Sphere Circumference is: " + doCalculation(radius));
}
- public double doCalculation(double input) {
+ public double doCalculation(int input) {
return 2 * Math.PI * input;
}
}
From 18857149bcf3bb5af6ea939a3601c0425af75a2b Mon Sep 17 00:00:00 2001
From: Megadardery
Date: Mon, 2 Mar 2020 00:33:14 +0200
Subject: [PATCH 34/78] preperation for bonus
added IntegerSubscriber and DoubleSubscriber, each class should extend one of them and overrides the abstract methods
---
src/CircleCircumference.java | 6 +++---
src/DoubleSubscriber.java | 10 ++++++++++
src/Fibonacci.java | 35 ---------------------------------
src/ISubscriber.java | 2 +-
src/IntegerSubscriber.java | 10 ++++++++++
src/Main.java | 12 +++++++----
src/ReallySimpleSubscriber.java | 2 +-
src/SimpleSubscriber.java | 2 +-
src/SphereCircumference.java | 29 ++++++++++-----------------
src/SphereVolume.java | 8 +++-----
src/Topic.java | 9 +++++++--
11 files changed, 54 insertions(+), 71 deletions(-)
create mode 100644 src/DoubleSubscriber.java
delete mode 100644 src/Fibonacci.java
create mode 100644 src/IntegerSubscriber.java
diff --git a/src/CircleCircumference.java b/src/CircleCircumference.java
index 3b088d3..a48123e 100644
--- a/src/CircleCircumference.java
+++ b/src/CircleCircumference.java
@@ -3,16 +3,16 @@
public class CircleCircumference implements ISubscriber {
@Override
- public void notifySubscriber(String input) {
+ public void notifySubscriber(int input) {
// TODO Auto-generated method stub
System.out.println("Hello, I am CircleCircumference subscriber and I am notified with " + input);
display(input);
}
- void display(String input){ // accept input and check if valid or not then call get_CircleCircumference and display the result.
+ void display(int input){ // accept input and check if valid or not then call get_CircleCircumference and display the result.
double radius=0;
try{ //check if the input can converted to double or not ..
- radius=Double.valueOf(input); // convert input String to double.
+ radius=input; // convert input String to double.
}catch (NumberFormatException e) {
System.out.println(" invalid input ");
System.out.println(" "+ e.getMessage());
diff --git a/src/DoubleSubscriber.java b/src/DoubleSubscriber.java
new file mode 100644
index 0000000..a1a5702
--- /dev/null
+++ b/src/DoubleSubscriber.java
@@ -0,0 +1,10 @@
+public abstract class DoubleSubscriber implements ISubscriber {
+ public void notifySubscriber(int input) throws Exception{
+ preProcess(input);
+ double ans = doCalculation(input);
+ printAnswer(ans);
+ }
+ public abstract void preProcess(int input) throws Exception;
+ public abstract double doCalculation(int input);
+ public abstract void printAnswer(double output);
+}
diff --git a/src/Fibonacci.java b/src/Fibonacci.java
deleted file mode 100644
index 69bc013..0000000
--- a/src/Fibonacci.java
+++ /dev/null
@@ -1,35 +0,0 @@
-public class Fibonacci implements ISubscriber {
- @Override
- public void notifySubscriber(String s) {
- int n = Integer.parseInt(s);
- int pascTriangle[][] = new int [n][n] ;
- pascTriangle[1][0] = 1;
- pascTriangle[1][1] = 1;
-
- if (n == 1 || n == 2) System.out.println("Result is:" +1) ;
- else {
- // drawing pascal's triangle as a base for Fibonnacii
- for (int i = 2; i <= n; i++) {
- pascTriangle[i][0] = 1;
- for (int j = 1; j <= i; j++) {
- pascTriangle[i][j] = pascTriangle[i - 1][j - 1] + pascTriangle[i - 1][j];
- }
- pascTriangle[i][i] = 1;
- }
-
- int i = n - 1;
- int j = 0;
- int result = 0;
-
- while (j <= i)
- {
- result += pascTriangle[i][j];
- i--;
- j++;
-
- }
-
- System.out.println("Result is:" +result) ;
- }
- }
-}
diff --git a/src/ISubscriber.java b/src/ISubscriber.java
index d3a605c..e3de552 100644
--- a/src/ISubscriber.java
+++ b/src/ISubscriber.java
@@ -1,4 +1,4 @@
public interface ISubscriber {
- public abstract void notifySubscriber(String input);
+ public abstract void notifySubscriber(int input) throws Exception;
}
diff --git a/src/IntegerSubscriber.java b/src/IntegerSubscriber.java
new file mode 100644
index 0000000..2843c0d
--- /dev/null
+++ b/src/IntegerSubscriber.java
@@ -0,0 +1,10 @@
+public abstract class IntegerSubscriber implements ISubscriber {
+ public void notifySubscriber(int input) throws Exception{
+ preProcess(input);
+ int ans = doCalculation(input);
+ printAnswer(ans);
+ }
+ public abstract void preProcess(int input) throws Exception;
+ public abstract int doCalculation(int input);
+ public abstract void printAnswer(int output);
+}
diff --git a/src/Main.java b/src/Main.java
index 1d5c67b..d59e59a 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -5,9 +5,8 @@ public class Main {
new SimpleSubscriber(),
new ReallySimpleSubscriber(),
new SphereCircumference(),
- new Fibonacci(),
- new SphereVolume(),
- new CircleCircumference(),
+ new SphereVolume(),
+ new CircleCircumference(),
};
public static void main(String[] args) {
Topic mathTopic = new Topic();
@@ -16,6 +15,11 @@ public static void main(String[] args) {
}
Scanner sc = new Scanner(System.in);
String input = sc.next();
- mathTopic.dispatchEvent(input);
+ try{
+ int n = Integer.parseInt(input);
+ mathTopic.dispatchEvent(n);
+ }catch(NumberFormatException ignored) {
+ System.out.println("Your input is not a valid integer.");
+ }
}
}
diff --git a/src/ReallySimpleSubscriber.java b/src/ReallySimpleSubscriber.java
index fb1114a..33ae146 100644
--- a/src/ReallySimpleSubscriber.java
+++ b/src/ReallySimpleSubscriber.java
@@ -1,7 +1,7 @@
public class ReallySimpleSubscriber implements ISubscriber {
@Override
- public void notifySubscriber(String input) {
+ public void notifySubscriber(int 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 c051520..bd70164 100644
--- a/src/SimpleSubscriber.java
+++ b/src/SimpleSubscriber.java
@@ -1,7 +1,7 @@
public class SimpleSubscriber implements ISubscriber {
@Override
- public void notifySubscriber(String input) {
+ public void notifySubscriber(int 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/SphereCircumference.java b/src/SphereCircumference.java
index 1c2c086..55eea01 100644
--- a/src/SphereCircumference.java
+++ b/src/SphereCircumference.java
@@ -1,25 +1,16 @@
-public class SphereCircumference implements ISubscriber {
+public class SphereCircumference extends DoubleSubscriber {
@Override
- public void notifySubscriber(String input) {
- System.out.println("Hello, I am Sphere Circumference and I am notified with " + input);
-
- double radius;
- try {
- radius = Double.parseDouble(input);
- if (radius < 0) {
- System.out.println("Radius is negative.");
- return;
- }
-
- } catch (NumberFormatException ignored) {
- System.out.println("Radius is not a number.");
- return;
- }
-
- System.out.println("Radius is " + radius + ", Sphere Circumference is: " + doCalculation(radius));
+ public void preProcess(int input) throws Exception {
+ System.out.print("Hello, I'm SphereCircumference, and I'm notified with: " + input + " as radius. ");
+ if (input < 0) throw new Exception("Negative radius is invalid!");
}
- public double doCalculation(double input) {
+ public double doCalculation(int input) {
return 2 * Math.PI * input;
}
+
+ @Override
+ public void printAnswer(double output) {
+ System.out.println("Sphere Circumference is: " + output);
+ }
}
diff --git a/src/SphereVolume.java b/src/SphereVolume.java
index 2b3b9a8..72dd7a3 100644
--- a/src/SphereVolume.java
+++ b/src/SphereVolume.java
@@ -5,7 +5,7 @@ public class SphereVolume implements ISubscriber {
- public static void sphereVolume(double radius) {
+ public static void sphereVolume(int radius) {
/*calculating the volume of a sphere requires two constant inputs and a variable one.
1- (variable)a radius (which is given).
@@ -21,10 +21,8 @@ public static void sphereVolume(double radius) {
}
@Override
- public void notifySubscriber(String input) {
- double value = Double.parseDouble(input);
- sphereVolume(value);
-
+ public void notifySubscriber(int input) {
+ sphereVolume(input);
}
diff --git a/src/Topic.java b/src/Topic.java
index 8fa2e2e..27c7832 100644
--- a/src/Topic.java
+++ b/src/Topic.java
@@ -17,9 +17,14 @@ public List getSubscribers() {
return subscribers;
}
- public void dispatchEvent(String input) {
+ public void dispatchEvent(int input) {
for (ISubscriber sub : this.getSubscribers()) {
- sub.notifySubscriber(input);
+ try {
+ sub.notifySubscriber(input);
+ }
+ catch(Exception ex){
+ System.out.println(ex.getMessage());
+ }
}
}
}
From c5ac0225b55453fa36e978a6baee31a7590919e4 Mon Sep 17 00:00:00 2001
From: Fatima <44647655+fatima196@users.noreply.github.com>
Date: Mon, 2 Mar 2020 00:59:17 +0200
Subject: [PATCH 35/78] Change type of input to integer.
---
src/CircleCircumference.java | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/CircleCircumference.java b/src/CircleCircumference.java
index 3b088d3..8595772 100644
--- a/src/CircleCircumference.java
+++ b/src/CircleCircumference.java
@@ -10,15 +10,15 @@ public void notifySubscriber(String input) {
}
void display(String input){ // accept input and check if valid or not then call get_CircleCircumference and display the result.
- double radius=0;
- try{ //check if the input can converted to double or not ..
- radius=Double.valueOf(input); // convert input String to double.
+ int radius=0;
+ try{ //check if the input can converted to integer or not ..
+ radius=Integer.parseInt(input); // convert input String to integer.
+ if (radius<0) {System.out.println(" Sorry,You enterd invalid radius. "); return; } //its invalid if the input radius < 0.
}catch (NumberFormatException e) {
System.out.println(" invalid input ");
System.out.println(" "+ e.getMessage());
return;
- }
- if (radius<0) {System.out.println(" Sorry,You enterd invalid radius. "); return; } //its invalid if the input radius < 0.
+ }
double circumference = get_CircleCircumference(radius);
System.out.println(" Circumference of a Circle = " + circumference);
}
From b62da27d4b6ed1f3f56e04c79556c0c18c4bf0cc Mon Sep 17 00:00:00 2001
From: Marim-medhat <36182751+Marim-medhat@users.noreply.github.com>
Date: Mon, 2 Mar 2020 10:39:06 +0200
Subject: [PATCH 36/78] Update CircleArea.java
---
src/CircleArea.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/CircleArea.java b/src/CircleArea.java
index 150d8cc..92e7b29 100644
--- a/src/CircleArea.java
+++ b/src/CircleArea.java
@@ -5,9 +5,9 @@ public class CircleArea implements ISubscriber {
public void notifySubscriber(String input) {
System.out.println("Hello, I am Circle Area and I am notified with " + input);
- double radius;
+ int radius;
try {
- radius = Double.parseDouble(input);
+ radius = Integer.parseDouble(input);
if (radius < 0) {
System.out.println("Radius is negative.");
return;
@@ -21,7 +21,7 @@ public void notifySubscriber(String input) {
System.out.println("Radius is " + radius + ", Area is: " + calculat(radius));
}
- public double calculat(double input) {
+ public double calculat(int input) {
return Math.PI * input *input;
}
}
From f9aec7a997fbda5d08413c2292552574ac6ca59b Mon Sep 17 00:00:00 2001
From: Marim-medhat <36182751+Marim-medhat@users.noreply.github.com>
Date: Mon, 2 Mar 2020 17:21:29 +0200
Subject: [PATCH 37/78] Update CircleArea.java
---
src/CircleArea.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/CircleArea.java b/src/CircleArea.java
index 92e7b29..93b7459 100644
--- a/src/CircleArea.java
+++ b/src/CircleArea.java
@@ -7,7 +7,7 @@ public void notifySubscriber(String input) {
int radius;
try {
- radius = Integer.parseDouble(input);
+ radius = Integer.parseInt(input);
if (radius < 0) {
System.out.println("Radius is negative.");
return;
From e80e370f933c7b0a9132e461ea963ed0ad336fe7 Mon Sep 17 00:00:00 2001
From: mahmoud-mohamed-abozied
<36476250+mahmoud-mohamed-abozied@users.noreply.github.com>
Date: Mon, 2 Mar 2020 18:25:49 +0200
Subject: [PATCH 38/78] 20170270-Adding SummationSeries class
---
src/Main.java | 1 +
src/SummationSeries.java | 10 ++++++++++
2 files changed, 11 insertions(+)
create mode 100644 src/SummationSeries.java
diff --git a/src/Main.java b/src/Main.java
index a0cf2f6..05d378f 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -7,6 +7,7 @@ public class Main {
new SphereCircumference(),
new SphereVolume(),
new CircleCircumference(),
+ new SummationSeries(),
new CircleArea(),
};
public static void main(String[] args) {
diff --git a/src/SummationSeries.java b/src/SummationSeries.java
new file mode 100644
index 0000000..e0f9465
--- /dev/null
+++ b/src/SummationSeries.java
@@ -0,0 +1,10 @@
+public class SummationSeries implements ISubscriber {
+
+ @Override
+ public void notifySubscriber(String input) {
+ int sum=((Integer.parseInt(input) * (Integer.parseInt(input)+1))) / 2 ;
+ System.out.println("The summation of series = " + sum);
+
+ }
+
+}
From 8867a5fa7fb7ecb282d00f325fd2b2de7f494ec6 Mon Sep 17 00:00:00 2001
From: Abdulazizsayed
Date: Mon, 2 Mar 2020 21:39:27 +0200
Subject: [PATCH 39/78] Modification of class name
---
src/Main.java | 2 +-
src/TwoPowerN.java | 13 +++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
create mode 100644 src/TwoPowerN.java
diff --git a/src/Main.java b/src/Main.java
index f6f808f..1df1b4c 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -4,7 +4,7 @@ public class Main {
private static ISubscriber subscribers [] = {
new SimpleSubscriber(),
new ReallySimpleSubscriber(),
- new TowPowerN(),
+ new TwoPowerN(),
};
public static void main(String[] args) {
Topic mathTopic = new Topic();
diff --git a/src/TwoPowerN.java b/src/TwoPowerN.java
new file mode 100644
index 0000000..206f29d
--- /dev/null
+++ b/src/TwoPowerN.java
@@ -0,0 +1,13 @@
+
+public class TwoPowerN implements ISubscriber {
+ @Override
+ public void notifySubscriber(String input) {
+ int p = Integer.parseInt(input), res = 2;
+
+ for(int i = 1 ; i < p ; i++){
+ res += res;
+ }
+
+ System.out.println(res);
+ }
+}
\ No newline at end of file
From c56c8068697b10ec5bd5e78c0b66124faf38438e Mon Sep 17 00:00:00 2001
From: Abdulaziz Sayed <36112643+Abdulazizsayed@users.noreply.github.com>
Date: Mon, 2 Mar 2020 21:56:24 +0200
Subject: [PATCH 40/78] TowPowerN.java was deleted
It was deleted because it replaced by TwoPowerN.java class
---
src/TowPowerN.java | 13 -------------
1 file changed, 13 deletions(-)
delete mode 100644 src/TowPowerN.java
diff --git a/src/TowPowerN.java b/src/TowPowerN.java
deleted file mode 100644
index 052bf44..0000000
--- a/src/TowPowerN.java
+++ /dev/null
@@ -1,13 +0,0 @@
-
-public class TowPowerN implements ISubscriber {
- @Override
- public void notifySubscriber(String input) {
- int p = Integer.parseInt(input), res = 2;
-
- for(int i = 1 ; i < p ; i++){
- res += res;
- }
-
- System.out.println(res);
- }
-}
\ No newline at end of file
From 377f89e60e20ed961c65a1c53adeb17fd4d00782 Mon Sep 17 00:00:00 2001
From: Mina Botros <36329091+Mina1998@users.noreply.github.com>
Date: Mon, 2 Mar 2020 22:04:00 +0200
Subject: [PATCH 41/78] Version 2
---
src/CircleVolume.class | Bin 545 -> 0 bytes
src/CircleVolume.java | 5 +++--
src/ISubscriber.class | Bin 154 -> 0 bytes
src/Main.class | Bin 1171 -> 0 bytes
src/ReallySimpleSubscriber.class | Bin 800 -> 0 bytes
src/SimpleSubscriber.class | Bin 775 -> 0 bytes
src/Topic.class | Bin 1189 -> 0 bytes
7 files changed, 3 insertions(+), 2 deletions(-)
delete mode 100644 src/CircleVolume.class
delete mode 100644 src/ISubscriber.class
delete mode 100644 src/Main.class
delete mode 100644 src/ReallySimpleSubscriber.class
delete mode 100644 src/SimpleSubscriber.class
delete mode 100644 src/Topic.class
diff --git a/src/CircleVolume.class b/src/CircleVolume.class
deleted file mode 100644
index bf4b907a0673538fbb06a3f522199df2f72b4bcc..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 545
zcmZXR%TB^j5QhILmqMu^MeufD3VHf-x~BCMHBpFznlU#6x-^r8VKPbfJk0AHat)
z&M727Ty&;$&iwy;)BgN^eFHehu?~%3Udzb!L_hQrU+BmZR)_Yh-S+HY(7tzu!i{z0
z38mX!;*8x$IwB(EFJvI&OG2jE>Jzfp;gc|sLCJ)U0-@5Cfw)V2Zho{KPY|qb=-OW2
zj-;w*huQc=jtS-NB1DG~f-siPlf{YkW_Qljiz68fI<0;YHPm&iEm8L-<5>768dzt*
zFo_BEsaS^X2UfnM=W=l*h7_|kCf002ss&yl&AF{h+y=>
zByz=#R6AD}*E&_+I0Pf{ljC2YapteZvB*`MGjYzHe8PB3uT75m^iabJznjwrlu_Y|
tcSe5?`^I#<}eH^e2F`HsK`U8;mZzcc$
diff --git a/src/CircleVolume.java b/src/CircleVolume.java
index f8743dc..a29073c 100644
--- a/src/CircleVolume.java
+++ b/src/CircleVolume.java
@@ -3,8 +3,9 @@ public class CircleVolume implements ISubscriber {
@Override
public void notifySubscriber(String input) {
- // TODO Auto-generated method stub
- System.out.println("0");
+ int radius = Integer.parseInt(input);
+ double CircleVolume = (4.0/3.0) * Math.PI * Math.pow(radius, 3);
+ System.out.println("The Volume of the Circle is : " + CircleVolume);
}
}
diff --git a/src/ISubscriber.class b/src/ISubscriber.class
deleted file mode 100644
index a83512f2b788a72f2112d3a4bd5ec50f3e87837f..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 154
zcmX^0Z`VEs1_lcTPId++Mh0%r;L@bx+K!ujCDk2C)P!W`*#l$5|Do@*G1B=^j({72p`$v58
zSxg|Yk$3$y{sQ&fh42w*(tGDl&&-@TGyVPd#|eOESl18|Q1hnaX;1~)_so4WdZSdgYEH?n)dkwNa_h#qBP$SHv|Pt?{3QV;l`b&ZN@d&D(89<|NDZyb
zZaC$tYhT32p(CNA9Z`YEVvt5dhd|GJ+jQN7>+mEJ8oCAa6{lvocA?@n%61%GNW>s;
zOGg+Hfke*n?2Sg5lsCipkYWLyjiI_Rvd#!$m4;IhZqrPHMh4fT4T4VD^khelt41b+VCAWV_2r=
z*|iwPFri`miu%Su-M7m+CNU)tl8m}f`8bu#x>s%Zq-2}rY#gI_Bo%zj_ER@P(gg{6
zqGJY6*`H^B;#9j*>FfQ;Zsv5Z#XP&&cIs8rw{}%2iO
zfmqq}cLTKqv|M0NVuc&U0$0>wlXZ(}PDx#shXG+nb}XlOZ6wTN_@?zSZ&rh;YRGDG
z1>#1fQM2qdM@~N`XFDZhF~l`dxcWrMU7@8Q3XNaF`1(Mv{ES3?B3@LQ(2K`tGm2^x
zNm`voG2BEKtsdh$dcP4FLLblDK`xbNn8S$htzj4{HzP`0qGU}j`dOU}Z$V#p>=^wQ
zX(EAB2}1N!0PbLbz!>i09zBxeFOrtjmzx+QmEqhWdW#F;lUY?+`il0x@W6C_eBucA
zKPzIOTmACyPZOiXL!^(9$OSy@&I*bkEzs7Mqo=;wcOkarqw+?WLB$$AON
zfYMB$&N3E|B|eHdEaEvy_0zwEWp+8k$QO7?Yn~KeVTBc56WfE(KOPYcs~Xb_pk41
diff --git a/src/ReallySimpleSubscriber.class b/src/ReallySimpleSubscriber.class
deleted file mode 100644
index 0764dc0a4c19bfb50394ba6960b65a0daf977c71..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 800
zcmZuv+iuf95IvhFaq1dM(&hr?vZY*-w$!gkL45!TQ7NK`RFQbx#M^eO^+om?l+S{P
zR04?);G+;@J0g_i!LvK-IcLwD*!TD}Plw8nv>c}6WD={fj4hNI
z?p%q_!qp!q6G4meVIOL1@(Z^xwOi-N8cP(8MaZ==VnJ*h167
z_6_~RX=0@BpoKO`4O7F=EWj#sKM>LoUJAc&;Vwh_f7;in(w>ZK*kL$+C$$a_`3V<3
zCk(mA1y6DVdGgmmE&{Kp$%QNF@h{3;avL2y$jqr{yGITX{v7w_q3KH+>a)b0u2oQBYi`%%zplTG_vb{WbsXP^{*MCETLDQxxDf
zHYuZlqE0abpQ223K>HgSKhXKqxOa{F2QxgJ;qeU57Ib!AR;9sPIc2MW%_)fh2RI~B
Ka-Qf)IQj#I488~e
diff --git a/src/SimpleSubscriber.class b/src/SimpleSubscriber.class
deleted file mode 100644
index 0525bade573c3404a9af6708c16877c257a96388..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 775
zcmZuv%Wl&^6g`tBaq1e{q)k)a?hBH()Ju?pSb&766j3BskyuXRX*-oYw(K#ep9PCl
z0*MdcqY!uOh|q+E@63H2pL_27`u+VUfS2$rR2bHL86~0c^HDZVW?kuEbbds57jb%*q(*ucVUtHN#T3H)N>3jRRq02`dgPG#FL~Qi%_FM3`rM6bgpc
zARhB@$Wv+jX|Spr|?Xes8#pb+j#P++yxuXIexK
zHqjxHajqHKWwVUEkJPEDU+}1J;T}V09`;Qx!$71BJYab7UW8$MPbHU6ynN1cvskeJfM7
zoJ!_JanCM!0+B|u*eJQOXuAy-i!k!NN-i3&rB5r0#9mXJB&U=4TKQZF(@$7p;&ia>p<~@5koWtfw+Mn`UM7a(y_Oj
z?DptuI&(%s+wP3kY-P^%{w<{@I&-p!)KWdfB9Z77+?2(u%L~sdLbX*pQb#y2R
z2Cib9x(OgKYPLGd>vt7%pxdO=^s?Byh8^HoHIur*Igh9SbFlMyg
zU=&H-1jcZojrWusnyN^D#qit_E^2t$!3z7iD4AnEPO??o#!
Date: Mon, 2 Mar 2020 22:11:29 +0200
Subject: [PATCH 42/78] unnecessary files
---
src/.classpath | 6 ------
src/.project | 17 -----------------
2 files changed, 23 deletions(-)
delete mode 100644 src/.classpath
delete mode 100644 src/.project
diff --git a/src/.classpath b/src/.classpath
deleted file mode 100644
index 3f3893a..0000000
--- a/src/.classpath
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
diff --git a/src/.project b/src/.project
deleted file mode 100644
index 0c67e86..0000000
--- a/src/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
- Software Assignment Team 15
-
-
-
-
-
- org.eclipse.jdt.core.javabuilder
-
-
-
-
-
- org.eclipse.jdt.core.javanature
-
-
From c467b6d817c6fb652f8a33f5f90245b187371dcb Mon Sep 17 00:00:00 2001
From: mohamed magdy <36678529+devmagdyy@users.noreply.github.com>
Date: Mon, 2 Mar 2020 22:34:56 +0200
Subject: [PATCH 43/78] MulitiplicationSeries-20160219
I'm added my task and call it in main
---
.idea/.gitignore | 2 ++
.idea/.name | 1 +
.idea/misc.xml | 6 ++++++
.idea/modules.xml | 8 ++++++++
.idea/vcs.xml | 6 ++++++
GitAssignmentObserver.iml | 12 ++++++++++++
src/Main.java | 1 +
src/MultiplicationSeries.java | 17 +++++++++++++++++
8 files changed, 53 insertions(+)
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/MultiplicationSeries.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/.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..26db12c
--- /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..56e3f57 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -4,6 +4,7 @@ public class Main {
private static ISubscriber subscribers [] = {
new SimpleSubscriber(),
new ReallySimpleSubscriber(),
+ new MultiplicationSeries(),
};
public static void main(String[] args) {
Topic mathTopic = new Topic();
diff --git a/src/MultiplicationSeries.java b/src/MultiplicationSeries.java
new file mode 100644
index 0000000..01e5ace
--- /dev/null
+++ b/src/MultiplicationSeries.java
@@ -0,0 +1,17 @@
+public class MultiplicationSeries implements ISubscriber {
+
+ public int m(String n) {
+ int x = Integer.parseInt(n);
+ int result = 1;
+ for (int i = 1; i <= x; i++) {
+ result = result * i;
+ }
+ return result;
+ }
+
+ @Override
+ public void notifySubscriber(String input) {
+ System.out.print("Hello,I am a multiplication series and I am notified with" + input);
+ System.out.print("and my result is : " + m(input));
+ }
+}
\ No newline at end of file
From d36757ba0371aa0cb9f0d06dbdbdeebaf5b13693 Mon Sep 17 00:00:00 2001
From: MostafaAshrafMahmoud
<36164425+MostafaAshrafMahmoud@users.noreply.github.com>
Date: Mon, 2 Mar 2020 23:28:54 +0200
Subject: [PATCH 44/78] 20170285 Adding class SphereArea
---
src/Main.java | 1 +
src/SphereArea.java | 16 ++++++++++++++++
2 files changed, 17 insertions(+)
create mode 100644 src/SphereArea.java
diff --git a/src/Main.java b/src/Main.java
index 967585b..8106995 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -12,6 +12,7 @@ public class Main {
new CircleArea(),
new CircleVolume(),
new TwoPowerN(),
+ new SphereArea(),
};
public static void main(String[] args) {
Topic mathTopic = new Topic();
diff --git a/src/SphereArea.java b/src/SphereArea.java
new file mode 100644
index 0000000..46d638f
--- /dev/null
+++ b/src/SphereArea.java
@@ -0,0 +1,16 @@
+
+public class SphereArea implements ISubscriber{
+ @Override
+ public void notifySubscriber(String input) {
+
+
+ double radius = Integer.parseInt(input);
+ double Area = 4*(Math.PI)*Math.pow(radius, 2);
+ System.out.println("The Area of Sphere = " + Area +" square meters" );
+
+
+ }
+
+ }
+
+
From bc391e3b60585135aa2842aeb489831f4ae7628b Mon Sep 17 00:00:00 2001
From: Megadardery
Date: Mon, 2 Mar 2020 23:42:27 +0200
Subject: [PATCH 45/78] removed unnecessary files
---
.idea/.name | 1 -
.idea/misc.xml | 6 ----
.idea/modules.xml | 8 ------
.idea/vcs.xml | 6 ----
.idea/workspace.xml | 58 ---------------------------------------
GitAssignmentObserver.iml | 12 --------
6 files changed, 91 deletions(-)
delete mode 100644 .idea/.name
delete mode 100644 .idea/misc.xml
delete mode 100644 .idea/modules.xml
delete mode 100644 .idea/vcs.xml
delete mode 100644 .idea/workspace.xml
delete mode 100644 GitAssignmentObserver.iml
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
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
deleted file mode 100644
index 6b1befe..0000000
--- a/.idea/workspace.xml
+++ /dev/null
@@ -1,58 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1583076785152
-
-
- 1583076785152
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ 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
From 63194c4edc66fa40b2d6b4f0250d8763be8e35c4 Mon Sep 17 00:00:00 2001
From: mohamed magdy <36678529+devmagdyy@users.noreply.github.com>
Date: Tue, 3 Mar 2020 01:09:33 +0200
Subject: [PATCH 46/78] MultiplicationSeries-20160219
i am added my task and called it in main.
---
.idea/.gitignore | 2 ++
.idea/.name | 1 +
.idea/misc.xml | 6 ++++++
.idea/modules.xml | 8 ++++++++
.idea/vcs.xml | 6 ++++++
src/ISubscriber.java | 2 +-
src/Main.java | 3 ++-
src/Multiplicationseriess.java | 7 ++++---
src/Topic.java | 2 +-
9 files changed, 31 insertions(+), 6 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
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/.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/src/ISubscriber.java b/src/ISubscriber.java
index 7e3d582..d3a605c 100644
--- a/src/ISubscriber.java
+++ b/src/ISubscriber.java
@@ -1,4 +1,4 @@
public interface ISubscriber {
- public abstract void notifySubscriber(int input);
+ public abstract void notifySubscriber(String input);
}
diff --git a/src/Main.java b/src/Main.java
index f880665..1283e19 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -4,6 +4,7 @@ public class Main {
private static ISubscriber subscribers [] = {
new SimpleSubscriber(),
new ReallySimpleSubscriber(),
+ new Multiplicationseriess(),
};
public static void main(String[] args) {
@@ -12,7 +13,7 @@ public static void main(String[] args) {
mathTopic.addSubscriber(sub);
}
Scanner sc = new Scanner(System.in);
- int input = sc.nextInt();
+ String input = sc.next();
mathTopic.dispatchEvent(input);
}
}
diff --git a/src/Multiplicationseriess.java b/src/Multiplicationseriess.java
index 6e131e3..e401bae 100644
--- a/src/Multiplicationseriess.java
+++ b/src/Multiplicationseriess.java
@@ -1,13 +1,14 @@
public class Multiplicationseriess implements ISubscriber {
- public int m(int n){
+ public int m(String n){
int result = 1;
- for(int i=0; i<=n; i++){
+ int x = Integer.parseInt(n);
+ for(int i=0; i<=x; i++){
result = result*i;
}
return result;
}
@Override
- public void notifySubscriber(int input) {
+ public void notifySubscriber(String input) {
System.out.println("Hello, I am really a simple subscriber and I am notified with " + input);
System.out.println("and my result is : " + m(input));
}
diff --git a/src/Topic.java b/src/Topic.java
index c147e76..8fa2e2e 100644
--- a/src/Topic.java
+++ b/src/Topic.java
@@ -17,7 +17,7 @@ public List getSubscribers() {
return subscribers;
}
- public void dispatchEvent(int input) {
+ public void dispatchEvent(String input) {
for (ISubscriber sub : this.getSubscribers()) {
sub.notifySubscriber(input);
}
From 734ce1c16edc9c4e92cb2661e7481bcd0d4afd59 Mon Sep 17 00:00:00 2001
From: Megadardery
Date: Tue, 3 Mar 2020 20:03:25 +0200
Subject: [PATCH 47/78] deleting unnecessary files
---
.idea/.gitignore | 2 --
.idea/.name | 1 -
.idea/misc.xml | 6 ------
.idea/modules.xml | 8 --------
.idea/vcs.xml | 6 ------
GitAssignmentObserver.iml | 12 ------------
6 files changed, 35 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
delete mode 100644 GitAssignmentObserver.iml
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index e7e9d11..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-# Default ignored files
-/workspace.xml
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
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
From ad8d2b8375e14bf4167a205319bd5d2586992579 Mon Sep 17 00:00:00 2001
From: Megadardery
Date: Tue, 3 Mar 2020 20:05:14 +0200
Subject: [PATCH 48/78] removing IDE files
---
.idea/.gitignore | 2 --
.idea/.name | 1 -
.idea/misc.xml | 6 ------
.idea/modules.xml | 8 --------
.idea/vcs.xml | 6 ------
5 files changed, 23 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 e7e9d11..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-# Default ignored files
-/workspace.xml
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 36b05b3c9092a726bcb8e12302ca220b2e2ebd0e Mon Sep 17 00:00:00 2001
From: mohamed magdy <36678529+devmagdyy@users.noreply.github.com>
Date: Tue, 3 Mar 2020 20:31:25 +0200
Subject: [PATCH 49/78] multiplicationSeries-20160219
i am edit my code .
---
.idea/workspace.xml | 47 ++++++++++++++++++++++++++++++++++
src/Multiplicationseriess.java | 2 +-
2 files changed, 48 insertions(+), 1 deletion(-)
create mode 100644 .idea/workspace.xml
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
new file mode 100644
index 0000000..b63905e
--- /dev/null
+++ b/.idea/workspace.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1583190009818
+
+
+ 1583190009818
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Multiplicationseriess.java b/src/Multiplicationseriess.java
index e401bae..9714ad0 100644
--- a/src/Multiplicationseriess.java
+++ b/src/Multiplicationseriess.java
@@ -2,7 +2,7 @@ public class Multiplicationseriess implements ISubscriber {
public int m(String n){
int result = 1;
int x = Integer.parseInt(n);
- for(int i=0; i<=x; i++){
+ for(int i=1; i<=x; i++){
result = result*i;
}
return result;
From 0f5a4c6c49972c0dcdd6732fb9ba7df280d93066 Mon Sep 17 00:00:00 2001
From: Mina Botros <36329091+Mina1998@users.noreply.github.com>
Date: Tue, 3 Mar 2020 20:56:52 +0200
Subject: [PATCH 50/78] Circle Volume Bonus
---
src/CircleVolume.java | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/src/CircleVolume.java b/src/CircleVolume.java
index a29073c..4c2269f 100644
--- a/src/CircleVolume.java
+++ b/src/CircleVolume.java
@@ -1,11 +1,17 @@
+public class CircleVolume extends DoubleSubscriber {
+ @Override
+ public void preProcess(int input) throws Exception {
+ System.out.print("Hello, I'm CircleVolume, and I'm notified with: " + input + " as radius. ");
+ if (input < 0) throw new Exception("Negative radius is invalid!");
+ }
-public class CircleVolume implements ISubscriber {
+ public double doCalculation(int input) {
+ return (4.0 / 3.0) * Math.PI * Math.pow(input, 3);
+ }
- @Override
- public void notifySubscriber(String input) {
- int radius = Integer.parseInt(input);
- double CircleVolume = (4.0/3.0) * Math.PI * Math.pow(radius, 3);
- System.out.println("The Volume of the Circle is : " + CircleVolume);
- }
+ @Override
+ public void printAnswer(double output) {
+ System.out.println("Circle Volume is: " + output);
+ }
}
From d3d7e7d6369e6c216a3d86202db086a8e762017b Mon Sep 17 00:00:00 2001
From: mohamed magdy <36678529+devmagdyy@users.noreply.github.com>
Date: Tue, 3 Mar 2020 20:58:04 +0200
Subject: [PATCH 51/78] Update workspace.xml
---
.idea/workspace.xml | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 7c8fb01..8cf1340 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,17 +2,17 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
From bdbc36bda57d7f5c3c78b0247dacfd6d57dbfa61 Mon Sep 17 00:00:00 2001
From: Megadardery
Date: Tue, 3 Mar 2020 20:58:05 +0200
Subject: [PATCH 52/78] removing unnecessary files
---
.idea/workspace.xml | 57 -------------------------------------------
src/SphereVolume.java | 32 ------------------------
2 files changed, 89 deletions(-)
delete mode 100644 .idea/workspace.xml
delete mode 100644 src/SphereVolume.java
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
deleted file mode 100644
index 7c8fb01..0000000
--- a/.idea/workspace.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1583190009818
-
-
- 1583190009818
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/SphereVolume.java b/src/SphereVolume.java
deleted file mode 100644
index db3453e..0000000
--- a/src/SphereVolume.java
+++ /dev/null
@@ -1,32 +0,0 @@
-import java.lang.Math;
-public class SphereVolume implements ISubscriber {
-
- private static double value = 4.0/3.0;
-
-
-
- public static void sphereVolume(double radius) {
- /*calculating the volume of a sphere requires two constant inputs and a variable one.
-
- 1- (variable)a radius (which is given).
- 2- (constant)Pi, which simply = 3.14 or 22/7.
- 3- (constant)the value (4/3).
-
- */
-
- double volume = value*(Math.PI)*Math.pow(radius, 3);
- System.out.println("The volume of a sphere with a given Radius of " + radius + "cm = " + volume + " cubic meters.");
-
-
- }
-
- @Override
- public void notifySubscriber(String input) {
- double value = Double.parseDouble(input);
- sphereVolume(value);
-
- }
-
-
-
-}
From 46d3da01c8cfcd771ae990ce374d4d7e404cd61e Mon Sep 17 00:00:00 2001
From: mohamed magdy <36678529+devmagdyy@users.noreply.github.com>
Date: Tue, 3 Mar 2020 20:58:59 +0200
Subject: [PATCH 53/78] Update workspace.xml
---
.idea/workspace.xml | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 8cf1340..0935907 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -1,19 +1,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
From 667924e679f86ccfeae7f6fa827e0701bace6ee3 Mon Sep 17 00:00:00 2001
From: Megadardery
Date: Tue, 3 Mar 2020 21:06:15 +0200
Subject: [PATCH 54/78] Merge preperation
---
src/Multiplicationseriess.java | 15 ---------------
src/SphereVolume.java | 30 ++++++++++++++++++++++++++++++
2 files changed, 30 insertions(+), 15 deletions(-)
delete mode 100644 src/Multiplicationseriess.java
create mode 100644 src/SphereVolume.java
diff --git a/src/Multiplicationseriess.java b/src/Multiplicationseriess.java
deleted file mode 100644
index 9714ad0..0000000
--- a/src/Multiplicationseriess.java
+++ /dev/null
@@ -1,15 +0,0 @@
-public class Multiplicationseriess implements ISubscriber {
- public int m(String n){
- int result = 1;
- int x = Integer.parseInt(n);
- for(int i=1; i<=x; i++){
- result = result*i;
- }
- return result;
- }
- @Override
- public void notifySubscriber(String input) {
- System.out.println("Hello, I am really a simple subscriber and I am notified with " + input);
- System.out.println("and my result is : " + m(input));
- }
-}
diff --git a/src/SphereVolume.java b/src/SphereVolume.java
new file mode 100644
index 0000000..87b936c
--- /dev/null
+++ b/src/SphereVolume.java
@@ -0,0 +1,30 @@
+import java.lang.Math;
+public class SphereVolume implements ISubscriber {
+
+ private static double value = 4.0/3.0;
+
+
+
+ public static void sphereVolume(int radius) {
+ /*calculating the volume of a sphere requires two constant inputs and a variable one.
+
+ 1- (variable)a radius (which is given).
+ 2- (constant)Pi, which simply = 3.14 or 22/7.
+ 3- (constant)the value (4/3).
+
+ */
+
+ double volume = value*(Math.PI)*Math.pow(radius, 3);
+ System.out.println("The volume of a sphere with a given Radius of " + radius + "cm = " + volume + " cubic meters.");
+
+
+ }
+
+ @Override
+ public void notifySubscriber(int input) {
+ sphereVolume(input);
+ }
+
+
+
+}
From 0f1bd83f44bcba77a38edf1cfe644326e7a51997 Mon Sep 17 00:00:00 2001
From: Fatima <44647655+fatima196@users.noreply.github.com>
Date: Tue, 3 Mar 2020 21:24:24 +0200
Subject: [PATCH 55/78] Update CircleCircumference.java
---
src/CircleCircumference.java | 43 ++++++++++++------------------------
1 file changed, 14 insertions(+), 29 deletions(-)
diff --git a/src/CircleCircumference.java b/src/CircleCircumference.java
index 4a0b7fb..1ba46c7 100644
--- a/src/CircleCircumference.java
+++ b/src/CircleCircumference.java
@@ -1,35 +1,20 @@
import java.util.Scanner;
-public class CircleCircumference implements ISubscriber {
+public class CircleCircumference extends DoubleSubscriber {
- @Override
- public void notifySubscriber(int input) {
- // TODO Auto-generated method stub
- System.out.println("Hello, I am CircleCircumference subscriber and I am notified with " + input);
- display(input);
- }
-
- void display(int input){ // accept input and check if valid or not then call get_CircleCircumference and display the result.
- double radius=0;
- try{ //check if the input can converted to double or not ..
- radius=input; // convert input String to double.
- }catch (NumberFormatException e) {
- System.out.println(" invalid input ");
- System.out.println(" "+ e.getMessage());
- return;
- }
- double circumference = get_CircleCircumference(radius);
- System.out.println(" Circumference of a Circle = " + circumference);
- }
-
- double get_CircleCircumference(double radius){ //calc CircleCircumference.
- double circumference;
- circumference = 2 * Math.PI * radius;
- return circumference;
+ @Override
+ public void preProcess(int input) throws Exception {
+ System.out.print("Hello, I'm CircleCircumference, and I'm notified with: " + input + " as radius. ");
+ if (input < 0) throw new Exception("Negative radius is invalid!"); }
+
+ @Override
+ public double doCalculation(int input) {
+ return 2 * Math.PI * input;
}
-
-
-
-
+
+ @Override
+ public void printAnswer(double output) {
+ System.out.println("Circle Circumference is: " + output);
+ }
}
From 92cefcf5047bc9e803733eabd96e81c221b758c2 Mon Sep 17 00:00:00 2001
From: Megadardery
Date: Tue, 3 Mar 2020 21:31:44 +0200
Subject: [PATCH 56/78] code cleanup and multiple choices in main
---
src/CircleArea.java | 21 +++++---------
src/CircleCircumference.java | 41 ++++++++++++---------------
src/CircleVolume.java | 12 ++++----
src/DoubleSubscriber.java | 5 +++-
src/ISubscriber.java | 2 +-
src/IntegerSubscriber.java | 5 +++-
src/Main.java | 25 ++++++++++++++---
src/ReallySimpleSubscriber.java | 10 +++----
src/SimpleSubscriber.java | 10 +++----
src/SphereArea.java | 26 ++++++++---------
src/SphereCircumference.java | 2 +-
src/SphereVolume.java | 25 ++++++++---------
src/SummationSeries.java | 12 ++++----
src/Topic.java | 49 ++++++++++++++++-----------------
src/TwoPowerN.java | 16 +++++------
15 files changed, 134 insertions(+), 127 deletions(-)
diff --git a/src/CircleArea.java b/src/CircleArea.java
index 93b7459..96ec312 100644
--- a/src/CircleArea.java
+++ b/src/CircleArea.java
@@ -1,20 +1,13 @@
public class CircleArea implements ISubscriber {
-
- @Override
- public void notifySubscriber(String input) {
- System.out.println("Hello, I am Circle Area and I am notified with " + input);
- int radius;
- try {
- radius = Integer.parseInt(input);
- if (radius < 0) {
- System.out.println("Radius is negative.");
- return;
- }
+ @Override
+ public void notifySubscriber(int input) {
+ System.out.println("Hello, I am Circle Area and I am notified with " + input);
- } catch (NumberFormatException ignored) {
- System.out.println("Radius is not a number.");
+ int radius = input;
+ if (radius < 0) {
+ System.out.println("Radius is negative.");
return;
}
@@ -22,6 +15,6 @@ public void notifySubscriber(String input) {
}
public double calculat(int input) {
- return Math.PI * input *input;
+ return Math.PI * input * input;
}
}
diff --git a/src/CircleCircumference.java b/src/CircleCircumference.java
index 4a0b7fb..38d9afa 100644
--- a/src/CircleCircumference.java
+++ b/src/CircleCircumference.java
@@ -1,35 +1,30 @@
-import java.util.Scanner;
-
public class CircleCircumference implements ISubscriber {
-
- @Override
- public void notifySubscriber(int input) {
- // TODO Auto-generated method stub
- System.out.println("Hello, I am CircleCircumference subscriber and I am notified with " + input);
- display(input);
- }
-
- void display(int input){ // accept input and check if valid or not then call get_CircleCircumference and display the result.
- double radius=0;
- try{ //check if the input can converted to double or not ..
- radius=input; // convert input String to double.
- }catch (NumberFormatException e) {
+
+ @Override
+ public void notifySubscriber(int input) {
+ // TODO Auto-generated method stub
+ System.out.println("Hello, I am CircleCircumference subscriber and I am notified with " + input);
+ display(input);
+ }
+
+ void display(int input) { // accept input and check if valid or not then call get_CircleCircumference and display the result.
+ double radius = 0;
+ try { //check if the input can converted to double or not ..
+ radius = input; // convert input String to double.
+ } catch (NumberFormatException e) {
System.out.println(" invalid input ");
- System.out.println(" "+ e.getMessage());
+ System.out.println(" " + e.getMessage());
return;
- }
+ }
double circumference = get_CircleCircumference(radius);
System.out.println(" Circumference of a Circle = " + circumference);
}
-
- double get_CircleCircumference(double radius){ //calc CircleCircumference.
+
+ double get_CircleCircumference(double radius) { //calc CircleCircumference.
double circumference;
circumference = 2 * Math.PI * radius;
return circumference;
}
-
-
-
-
+
}
diff --git a/src/CircleVolume.java b/src/CircleVolume.java
index a29073c..1356f61 100644
--- a/src/CircleVolume.java
+++ b/src/CircleVolume.java
@@ -1,11 +1,11 @@
public class CircleVolume implements ISubscriber {
- @Override
- public void notifySubscriber(String input) {
- int radius = Integer.parseInt(input);
- double CircleVolume = (4.0/3.0) * Math.PI * Math.pow(radius, 3);
- System.out.println("The Volume of the Circle is : " + CircleVolume);
- }
+ @Override
+ public void notifySubscriber(int input) {
+ int radius = input;
+ double CircleVolume = (4.0 / 3.0) * Math.PI * Math.pow(radius, 3);
+ System.out.println("The Volume of the Circle is : " + CircleVolume);
+ }
}
diff --git a/src/DoubleSubscriber.java b/src/DoubleSubscriber.java
index a1a5702..954466e 100644
--- a/src/DoubleSubscriber.java
+++ b/src/DoubleSubscriber.java
@@ -1,10 +1,13 @@
public abstract class DoubleSubscriber implements ISubscriber {
- public void notifySubscriber(int input) throws Exception{
+ public void notifySubscriber(int input) throws Exception {
preProcess(input);
double ans = doCalculation(input);
printAnswer(ans);
}
+
public abstract void preProcess(int input) throws Exception;
+
public abstract double doCalculation(int input);
+
public abstract void printAnswer(double output);
}
diff --git a/src/ISubscriber.java b/src/ISubscriber.java
index e3de552..bc7bb57 100644
--- a/src/ISubscriber.java
+++ b/src/ISubscriber.java
@@ -1,4 +1,4 @@
public interface ISubscriber {
- public abstract void notifySubscriber(int input) throws Exception;
+ public abstract void notifySubscriber(int input) throws Exception;
}
diff --git a/src/IntegerSubscriber.java b/src/IntegerSubscriber.java
index 2843c0d..32e28e3 100644
--- a/src/IntegerSubscriber.java
+++ b/src/IntegerSubscriber.java
@@ -1,10 +1,13 @@
public abstract class IntegerSubscriber implements ISubscriber {
- public void notifySubscriber(int input) throws Exception{
+ public void notifySubscriber(int input) throws Exception {
preProcess(input);
int ans = doCalculation(input);
printAnswer(ans);
}
+
public abstract void preProcess(int input) throws Exception;
+
public abstract int doCalculation(int input);
+
public abstract void printAnswer(int output);
}
diff --git a/src/Main.java b/src/Main.java
index f5a884d..ce811da 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -15,17 +15,34 @@ public class Main {
new SphereArea(),
};
public static void main(String[] args) {
+ Scanner sc = new Scanner(System.in);
+
Topic mathTopic = new Topic();
for (ISubscriber sub : subscribers) {
mathTopic.addSubscriber(sub);
}
- Scanner sc = new Scanner(System.in);
- String input = sc.next();
+
try{
- int n = Integer.parseInt(input);
- mathTopic.dispatchEvent(n);
+ for (int i = 0; i < subscribers.length; ++i) {
+ System.out.println((i+1) + " - " + subscribers[i].getClass().getName());
+ }
+ System.out.println("0 - Run all functions");
+
+ System.out.println("Choose your option:");
+ int choice = Integer.parseInt(sc.next());
+
+ System.out.println("Enter input number: ");
+ int n = Integer.parseInt(sc.next());
+
+ if (choice < 0 || choice > subscribers.length) throw new Exception("Invalid choice.");
+ if (choice != 0)
+ subscribers[choice-1].notifySubscriber(n);
+ else
+ mathTopic.dispatchEvent(n);
}catch(NumberFormatException ignored) {
System.out.println("Your input is not a valid integer.");
+ }catch(Exception ex){
+ System.out.println(ex.getMessage());
}
}
}
\ No newline at end of file
diff --git a/src/ReallySimpleSubscriber.java b/src/ReallySimpleSubscriber.java
index 33ae146..ea365e3 100644
--- a/src/ReallySimpleSubscriber.java
+++ b/src/ReallySimpleSubscriber.java
@@ -1,8 +1,8 @@
public class ReallySimpleSubscriber implements ISubscriber {
- @Override
- public void notifySubscriber(int input) {
- // TODO Auto-generated method stub
- System.out.println("Hello, I am really a simple subscriber and I am notified with " + input);
- }
+ @Override
+ public void notifySubscriber(int 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 bd70164..891cb93 100644
--- a/src/SimpleSubscriber.java
+++ b/src/SimpleSubscriber.java
@@ -1,9 +1,9 @@
public class SimpleSubscriber implements ISubscriber {
- @Override
- public void notifySubscriber(int input) {
- // TODO Auto-generated method stub
- System.out.println("Hello, I am a simple subscriber and I am notified with " + input);
- }
+ @Override
+ public void notifySubscriber(int 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
index 46d638f..2eef3ce 100644
--- a/src/SphereArea.java
+++ b/src/SphereArea.java
@@ -1,16 +1,16 @@
-public class SphereArea implements ISubscriber{
- @Override
- public void notifySubscriber(String input) {
-
-
- double radius = Integer.parseInt(input);
- double Area = 4*(Math.PI)*Math.pow(radius, 2);
- System.out.println("The Area of Sphere = " + Area +" square meters" );
-
-
- }
-
- }
+public class SphereArea implements ISubscriber {
+ @Override
+ public void notifySubscriber(int input) {
+
+
+ double radius = input;
+ double Area = 4 * (Math.PI) * Math.pow(radius, 2);
+ System.out.println("The Area of Sphere = " + Area + " square meters");
+
+
+ }
+
+}
diff --git a/src/SphereCircumference.java b/src/SphereCircumference.java
index 01747f8..6b6868c 100644
--- a/src/SphereCircumference.java
+++ b/src/SphereCircumference.java
@@ -1,4 +1,4 @@
-public class SphereCircumference extends DoubleSubscriber {
+public class SphereCircumference extends DoubleSubscriber {
@Override
public void preProcess(int input) throws Exception {
System.out.print("Hello, I'm SphereCircumference, and I'm notified with: " + input + " as radius. ");
diff --git a/src/SphereVolume.java b/src/SphereVolume.java
index 72dd7a3..c0171d2 100644
--- a/src/SphereVolume.java
+++ b/src/SphereVolume.java
@@ -1,11 +1,9 @@
-import java.lang.Math;
public class SphereVolume implements ISubscriber {
- private static double value = 4.0/3.0;
-
+ private static double value = 4.0 / 3.0;
-
- public static void sphereVolume(int radius) {
+
+ public static void sphereVolume(int radius) {
/*calculating the volume of a sphere requires two constant inputs and a variable one.
1- (variable)a radius (which is given).
@@ -14,17 +12,16 @@ public static void sphereVolume(int radius) {
*/
- double volume = value*(Math.PI)*Math.pow(radius, 3);
- System.out.println("The volume of a sphere with a given Radius of " + radius + "cm = " + volume + " cubic meters.");
-
-
- }
+ double volume = value * (Math.PI) * Math.pow(radius, 3);
+ System.out.println("The volume of a sphere with a given Radius of " + radius + "cm = " + volume + " cubic meters.");
+
- @Override
- public void notifySubscriber(int input) {
- sphereVolume(input);
- }
+ }
+ @Override
+ public void notifySubscriber(int input) {
+ sphereVolume(input);
+ }
}
diff --git a/src/SummationSeries.java b/src/SummationSeries.java
index e0f9465..e7fd0ef 100644
--- a/src/SummationSeries.java
+++ b/src/SummationSeries.java
@@ -1,10 +1,10 @@
public class SummationSeries implements ISubscriber {
- @Override
- public void notifySubscriber(String input) {
- int sum=((Integer.parseInt(input) * (Integer.parseInt(input)+1))) / 2 ;
- System.out.println("The summation of series = " + sum);
-
- }
+ @Override
+ public void notifySubscriber(int input) {
+ int sum = (input * (input + 1)) / 2;
+ System.out.println("The summation of series = " + sum);
+
+ }
}
diff --git a/src/Topic.java b/src/Topic.java
index 27c7832..f234958 100644
--- a/src/Topic.java
+++ b/src/Topic.java
@@ -2,29 +2,28 @@
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(int input) {
- for (ISubscriber sub : this.getSubscribers()) {
- try {
- sub.notifySubscriber(input);
- }
- catch(Exception ex){
- System.out.println(ex.getMessage());
- }
- }
- }
+
+ private List subscribers;
+
+ public Topic() {
+ subscribers = new ArrayList();
+ }
+
+ public void addSubscriber(ISubscriber sub) {
+ subscribers.add(sub);
+ }
+
+ public List getSubscribers() {
+ return subscribers;
+ }
+
+ public void dispatchEvent(int input) {
+ for (ISubscriber sub : this.getSubscribers()) {
+ try {
+ sub.notifySubscriber(input);
+ } catch (Exception ex) {
+ System.out.println(ex.getMessage());
+ }
+ }
+ }
}
diff --git a/src/TwoPowerN.java b/src/TwoPowerN.java
index 206f29d..e40979c 100644
--- a/src/TwoPowerN.java
+++ b/src/TwoPowerN.java
@@ -1,13 +1,13 @@
public class TwoPowerN implements ISubscriber {
- @Override
- public void notifySubscriber(String input) {
- int p = Integer.parseInt(input), res = 2;
+ @Override
+ public void notifySubscriber(int input) {
+ int p = input, res = 2;
- for(int i = 1 ; i < p ; i++){
- res += res;
- }
+ for (int i = 1; i < p; i++) {
+ res += res;
+ }
- System.out.println(res);
- }
+ System.out.println(res);
+ }
}
\ No newline at end of file
From fc037b748530afabdc4b2ba4cf3dd8a0ae7b2b28 Mon Sep 17 00:00:00 2001
From: Abdulelah <58626327+AbdulelahAdam@users.noreply.github.com>
Date: Tue, 3 Mar 2020 21:47:51 +0200
Subject: [PATCH 57/78] SphereVolume Bonus Version
---
src/SphereVolume.java | 41 ++++++++++++++++++++++++-----------------
1 file changed, 24 insertions(+), 17 deletions(-)
diff --git a/src/SphereVolume.java b/src/SphereVolume.java
index 8093423..950e542 100644
--- a/src/SphereVolume.java
+++ b/src/SphereVolume.java
@@ -1,27 +1,34 @@
-public class SphereVolume implements ISubscriber {
+import java.lang.Math;
+public class SphereVolume extends DoubleSubscriber {
+
+ private static double value = 4.0/3.0;
+
+ @Override
+ public void preProcess(int input) throws Exception {
+ System.out.print("Hello, I'm SphereVolume, and I'm notified with: " + input + " as radius. ");
+ if (input < 0) throw new Exception("Negative radius is invalid!");
+
+ }
- private static double value = 4.0 / 3.0;
- public static void sphereVolume(int radius) {
- /*calculating the volume of a sphere requires two constant inputs and a variable one.
-
- 1- (variable)a radius (which is given).
- 2- (constant)Pi, which simply = 3.14 or 22/7.
- 3- (constant)the value (4/3).
+ @Override
+ public double doCalculation(int input) {
+ return value*(Math.PI)*Math.pow(input, 3);
- */
+ }
+
- double volume = value * (Math.PI) * Math.pow(radius, 3);
- System.out.println("The volume of a sphere with a given Radius of " + radius + "cm = " + volume + " cubic meters.");
+ @Override
+ public void printAnswer(double output) {
+ System.out.println("Sphere Volume is: " + output);
+
+
+ }
- }
- @Override
- public void notifySubscriber(int input) {
- sphereVolume(input);
- }
+
-}
\ No newline at end of file
+}
From fa1a1ea24222f49182f53e982e930f437be48823 Mon Sep 17 00:00:00 2001
From: Marim-medhat <36182751+Marim-medhat@users.noreply.github.com>
Date: Tue, 3 Mar 2020 21:58:15 +0200
Subject: [PATCH 58/78] Update CircleArea.java
---
src/CircleArea.java | 34 ++++++++++++----------------------
1 file changed, 12 insertions(+), 22 deletions(-)
diff --git a/src/CircleArea.java b/src/CircleArea.java
index 93b7459..ae34a78 100644
--- a/src/CircleArea.java
+++ b/src/CircleArea.java
@@ -1,27 +1,17 @@
+public class CircleArea extends DoubleSubscriber {
+ @Override
+ public void preProcess(int input) throws Exception {
+ System.out.print("Hello, I'm CircleArea , and I'm notified with: " + input + " as radius. ");
+ if (input < 0) throw new Exception("Negative radius is invalid!"); }
-public class CircleArea implements ISubscriber {
- @Override
- public void notifySubscriber(String input) {
- System.out.println("Hello, I am Circle Area and I am notified with " + input);
-
- int radius;
- try {
- radius = Integer.parseInt(input);
- if (radius < 0) {
- System.out.println("Radius is negative.");
- return;
- }
-
- } catch (NumberFormatException ignored) {
- System.out.println("Radius is not a number.");
- return;
- }
-
- System.out.println("Radius is " + radius + ", Area is: " + calculat(radius));
+ @Override
+ public double doCalculation(int input) {
+ return Math.PI * input *input;
}
- public double calculat(int input) {
- return Math.PI * input *input;
- }
+ @Override
+ public void printAnswer(double output) {
+ System.out.println("Circle Area is: " + output);
+ }
}
From 564b9e5f44d6930710ab3367a59c7a8bb1decb41 Mon Sep 17 00:00:00 2001
From: mahmoud-mohamed-abozied
<36476250+mahmoud-mohamed-abozied@users.noreply.github.com>
Date: Tue, 3 Mar 2020 22:15:17 +0200
Subject: [PATCH 59/78] 20170270-SummationSeries-Adding Bonus
---
src/SummationSeries.java | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/src/SummationSeries.java b/src/SummationSeries.java
index e7fd0ef..36fd5d3 100644
--- a/src/SummationSeries.java
+++ b/src/SummationSeries.java
@@ -1,10 +1,19 @@
-public class SummationSeries implements ISubscriber {
-
- @Override
- public void notifySubscriber(int input) {
- int sum = (input * (input + 1)) / 2;
- System.out.println("The summation of series = " + sum);
+public class SummationSeries extends IntegerSubscriber {
+ @Override
+ public void preProcess(int input) throws Exception {
+ System.out.print("Hello, I'm SummationSeries, and I'm notified with: " + input + " as input. ");
+ if (input < 0) throw new Exception("Negative input is invalid!");
}
+ @Override
+ public int doCalculation(int input) {
+ return (input * (input + 1)) / 2;
+ }
+
+ @Override
+ public void printAnswer(int output) {
+ System.out.println("The Summation Series = " + output);
+ }
+
}
From d689404822db46130879b66773687dafd56298af Mon Sep 17 00:00:00 2001
From: Megadardery
Date: Tue, 3 Mar 2020 22:43:56 +0200
Subject: [PATCH 60/78] removing simple subscribers.
---
.gitignore | 5 ++-
src/Main.java | 78 ++++++++++++++++-----------------
src/ReallySimpleSubscriber.java | 8 ----
src/SimpleSubscriber.java | 9 ----
4 files changed, 42 insertions(+), 58 deletions(-)
delete mode 100644 src/ReallySimpleSubscriber.java
delete mode 100644 src/SimpleSubscriber.java
diff --git a/.gitignore b/.gitignore
index 539bdba..402b99f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -53,4 +53,7 @@ local.properties
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
-.worksheet
\ No newline at end of file
+.worksheet
+
+# IDE folders
+.idea/
\ No newline at end of file
diff --git a/src/Main.java b/src/Main.java
index 62a1f1a..8dc8592 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -1,49 +1,47 @@
import java.util.Scanner;
public class Main {
- private static ISubscriber subscribers [] = {
- new SimpleSubscriber(),
- new ReallySimpleSubscriber(),
- new MultiplicationSeries(),
- new CircleVolume(),
- new SphereCircumference(),
- new SphereVolume(),
- new CircleCircumference(),
- new SummationSeries(),
- new CircleArea(),
- new CircleVolume(),
- new TwoPowerN(),
- new SphereArea(),
- };
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
+ private static ISubscriber subscribers [] = {
+ new MultiplicationSeries(),
+ new CircleVolume(),
+ new SphereCircumference(),
+ new SphereVolume(),
+ new CircleCircumference(),
+ new SummationSeries(),
+ new CircleArea(),
+ new CircleVolume(),
+ new TwoPowerN(),
+ new SphereArea(),
+ };
+ public static void main(String[] args) {
+ Scanner sc = new Scanner(System.in);
- Topic mathTopic = new Topic();
- for (ISubscriber sub : subscribers) {
- mathTopic.addSubscriber(sub);
- }
+ Topic mathTopic = new Topic();
+ for (ISubscriber sub : subscribers) {
+ mathTopic.addSubscriber(sub);
+ }
- try{
- for (int i = 0; i < subscribers.length; ++i) {
- System.out.println((i+1) + " - " + subscribers[i].getClass().getName());
- }
- System.out.println("0 - Run all functions");
+ try{
+ for (int i = 0; i < subscribers.length; ++i) {
+ System.out.println((i+1) + " - " + subscribers[i].getClass().getName());
+ }
+ System.out.println("0 - Run all functions");
- System.out.println("Choose your option:");
- int choice = Integer.parseInt(sc.next());
+ System.out.println("Choose your option:");
+ int choice = Integer.parseInt(sc.next());
- System.out.println("Enter input number: ");
- int n = Integer.parseInt(sc.next());
+ System.out.println("Enter input number: ");
+ int n = Integer.parseInt(sc.next());
- if (choice < 0 || choice > subscribers.length) throw new Exception("Invalid choice.");
- if (choice != 0)
- subscribers[choice-1].notifySubscriber(n);
- else
- mathTopic.dispatchEvent(n);
- }catch(NumberFormatException ignored) {
- System.out.println("Your input is not a valid integer.");
- }catch(Exception ex){
- System.out.println(ex.getMessage());
- }
- }
+ if (choice < 0 || choice > subscribers.length) throw new Exception("Invalid choice.");
+ if (choice != 0)
+ subscribers[choice-1].notifySubscriber(n);
+ else
+ mathTopic.dispatchEvent(n);
+ }catch(NumberFormatException ignored) {
+ System.out.println("Your input is not a valid integer.");
+ }catch(Exception ex){
+ System.out.println(ex.getMessage());
+ }
+ }
}
\ No newline at end of file
diff --git a/src/ReallySimpleSubscriber.java b/src/ReallySimpleSubscriber.java
deleted file mode 100644
index ea365e3..0000000
--- a/src/ReallySimpleSubscriber.java
+++ /dev/null
@@ -1,8 +0,0 @@
-
-public class ReallySimpleSubscriber implements ISubscriber {
- @Override
- public void notifySubscriber(int 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 891cb93..0000000
--- a/src/SimpleSubscriber.java
+++ /dev/null
@@ -1,9 +0,0 @@
-public class SimpleSubscriber implements ISubscriber {
-
- @Override
- public void notifySubscriber(int input) {
- // TODO Auto-generated method stub
- System.out.println("Hello, I am a simple subscriber and I am notified with " + input);
- }
-
-}
From 7bd7c9f39ac69c33dc53325d807875995fd2afe0 Mon Sep 17 00:00:00 2001
From: Megadardery
Date: Tue, 3 Mar 2020 22:44:34 +0200
Subject: [PATCH 61/78] Update .gitignore
---
.gitignore | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 402b99f..03508cf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -56,4 +56,7 @@ local.properties
.worksheet
# IDE folders
-.idea/
\ No newline at end of file
+.idea/
+
+#iml
+GitAssignmentObserver.iml
\ No newline at end of file
From 168c6f5bdfe7f37ccff6c942ad4d1889fbb6da87 Mon Sep 17 00:00:00 2001
From: mohamed magdy <36678529+devmagdyy@users.noreply.github.com>
Date: Tue, 3 Mar 2020 23:05:13 +0200
Subject: [PATCH 62/78] 20160219-MultiplicationSeries-Adding-Bonus
Adding Bonus
---
.idea/.gitignore | 2 ++
.idea/git_assignment_team15.iml | 9 +++++++++
.idea/misc.xml | 4 ++++
.idea/modules.xml | 8 ++++++++
.idea/vcs.xml | 6 ++++++
src/MultiplicationSeries.java | 28 +++++++++++++++++-----------
6 files changed, 46 insertions(+), 11 deletions(-)
create mode 100644 .idea/.gitignore
create mode 100644 .idea/git_assignment_team15.iml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/modules.xml
create mode 100644 .idea/vcs.xml
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/git_assignment_team15.iml b/.idea/git_assignment_team15.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/.idea/git_assignment_team15.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..aa34541
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..1ae8cf0
--- /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/src/MultiplicationSeries.java b/src/MultiplicationSeries.java
index 01e5ace..7e130a2 100644
--- a/src/MultiplicationSeries.java
+++ b/src/MultiplicationSeries.java
@@ -1,17 +1,23 @@
-public class MultiplicationSeries implements ISubscriber {
-
- public int m(String n) {
- int x = Integer.parseInt(n);
+public class Multiplicationseriess implements IntegerSubscriber {
+ public int m(int n){
int result = 1;
- for (int i = 1; i <= x; i++) {
- result = result * i;
+ int x = Integer.parseInt(n);
+ for(int i=1; i<=x; i++){
+ result = result*i;
}
return result;
}
-
@Override
- public void notifySubscriber(String input) {
- System.out.print("Hello,I am a multiplication series and I am notified with" + input);
- System.out.print("and my result is : " + m(input));
+ public void preProcess(int input) {
+ System.out.println("Hello, I'm MultiplicationSeries, and I'm notified with: " + input + " as input. ");
+ if (input < 0) throw new Exception("Negative input is invalid!");
+ }
+ @Override
+ public int doCalculation(int input) {
+ return m(input);
+ }
+}
+ @Override
+ public void printAnswer(int output) {
+ System.out.println("The Multiplication Series = " + output);
}
-}
\ No newline at end of file
From 58a4e5a00825f4a2d12ab267c59c4302b1cf3acd Mon Sep 17 00:00:00 2001
From: Amr Magdy <36246549+amrmagdy12@users.noreply.github.com>
Date: Tue, 3 Mar 2020 23:08:04 +0200
Subject: [PATCH 63/78] 20170188-Fibonacci-Bonusadded
Updated with implemented methods for IntegerSubscriber..
---
src/Fibonacci.java | 35 --------------------------
src/company/Fibonacci.java | 51 ++++++++++++++++++++++++++++++++++++++
2 files changed, 51 insertions(+), 35 deletions(-)
delete mode 100644 src/Fibonacci.java
create mode 100644 src/company/Fibonacci.java
diff --git a/src/Fibonacci.java b/src/Fibonacci.java
deleted file mode 100644
index c85019e..0000000
--- a/src/Fibonacci.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.company ;
-public class Fibonacci implements ISubscriber {
- @Override
- public void notifySubscriber(int n) {
- int pascTriangle[][] = new int [n][n] ;
- pascTriangle[1][0] = 1;
- pascTriangle[1][1] = 1;
-
- if (n == 1 || n == 2) System.out.println("Result is:" +1) ;
- else {
- // drawing pascal's triangle as a base for Fibonnacii
- for (int i = 2; i <= n; i++) {
- pascTriangle[i][0] = 1;
- for (int j = 1; j <= i; j++) {
- pascTriangle[i][j] = pascTriangle[i - 1][j - 1] + pascTriangle[i - 1][j];
- }
- pascTriangle[i][i] = 1;
- }
-
- int i = n - 1;
- int j = 0;
- int result = 0;
-
- while (j <= i)
- {
- result += pascTriangle[i][j];
- i--;
- j++;
-
- }
-
- System.out.println("Result is:" +result) ;
- }
- }
-}
diff --git a/src/company/Fibonacci.java b/src/company/Fibonacci.java
new file mode 100644
index 0000000..8810480
--- /dev/null
+++ b/src/company/Fibonacci.java
@@ -0,0 +1,51 @@
+package company;
+public class Fibonacci extends IntegerSubscriber{
+
+ @Override
+ public void preprocess(int input) throws Exception {
+
+ if(input < 1 ) throw new Exception("0 and Negative values are invalid ") ;
+
+ System.out.println("I'am Fibonnacii and I'am notified with >> " + input);
+ }
+
+ @Override
+ public int doCalculation(int n) {
+ int pascTriangle[][] = new int [n][n] ;
+ pascTriangle[1][0] = 1;
+ pascTriangle[1][1] = 1;
+
+ if (n == 1 || n == 2) return 1 ;
+ else {
+ // drawing pascal's triangle as a base for Fibonnacii
+ for (int i = 2; i < n; i++) {
+ pascTriangle[i][0] = 1;
+ for (int j = 1; j <= i; j++) {
+ pascTriangle[i][j] = pascTriangle[i - 1][j - 1] + pascTriangle[i - 1][j];
+ }
+ pascTriangle[i][i] = 1;
+ }
+
+ int i = n - 1;
+ int j = 0;
+ int result = 0;
+
+ while (j <= i)
+ {
+ result += pascTriangle[i][j];
+ i--;
+ j++;
+
+ }
+
+ return result ;
+
+ }
+ }
+
+ @Override
+ public void printAnswer(int out) {
+
+ System.out.println("the answer is " + out );
+ }
+}
From 2493ee02c756ba15a833b9b1be5947a798188a0c Mon Sep 17 00:00:00 2001
From: mohamed magdy <36678529+devmagdyy@users.noreply.github.com>
Date: Tue, 3 Mar 2020 23:24:52 +0200
Subject: [PATCH 64/78] 20160219-MultiplicationSeries-Adding-Bonus
---
.gitignore | 4 +++-
.idea/.gitignore | 2 --
.idea/git_assignment_team15.iml | 9 ---------
.idea/misc.xml | 4 ----
.idea/modules.xml | 8 --------
.idea/vcs.xml | 6 ------
6 files changed, 3 insertions(+), 30 deletions(-)
delete mode 100644 .idea/.gitignore
delete mode 100644 .idea/git_assignment_team15.iml
delete mode 100644 .idea/misc.xml
delete mode 100644 .idea/modules.xml
delete mode 100644 .idea/vcs.xml
diff --git a/.gitignore b/.gitignore
index 539bdba..06af90c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -53,4 +53,6 @@ local.properties
# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
-.worksheet
\ No newline at end of file
+.worksheet
+*.xml
+*.xml
diff --git a/.idea/.gitignore b/.idea/.gitignore
deleted file mode 100644
index e7e9d11..0000000
--- a/.idea/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-# Default ignored files
-/workspace.xml
diff --git a/.idea/git_assignment_team15.iml b/.idea/git_assignment_team15.iml
deleted file mode 100644
index d6ebd48..0000000
--- a/.idea/git_assignment_team15.iml
+++ /dev/null
@@ -1,9 +0,0 @@
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
deleted file mode 100644
index aa34541..0000000
--- a/.idea/misc.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 1ae8cf0..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 15d488b37d278ab7ca6b58a1bb94a8f9ca6e096d Mon Sep 17 00:00:00 2001
From: mohamed magdy <36678529+devmagdyy@users.noreply.github.com>
Date: Tue, 3 Mar 2020 23:38:20 +0200
Subject: [PATCH 65/78] 20160219-MultiplicationSeries-Adding-Bonus
---
src/MultiplicationSeries.java | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)
diff --git a/src/MultiplicationSeries.java b/src/MultiplicationSeries.java
index 7e130a2..d3a4244 100644
--- a/src/MultiplicationSeries.java
+++ b/src/MultiplicationSeries.java
@@ -1,12 +1,5 @@
-public class Multiplicationseriess implements IntegerSubscriber {
- public int m(int n){
- int result = 1;
- int x = Integer.parseInt(n);
- for(int i=1; i<=x; i++){
- result = result*i;
- }
- return result;
- }
+public class MultiplicationSeries implements IntegerSubscriber {
+
@Override
public void preProcess(int input) {
System.out.println("Hello, I'm MultiplicationSeries, and I'm notified with: " + input + " as input. ");
@@ -14,7 +7,11 @@ public void preProcess(int input) {
}
@Override
public int doCalculation(int input) {
- return m(input);
+ int result = 1;
+ for(int i=1; i<=input; i++){
+ result = result*i;
+ }
+ return result;
}
}
@Override
From 356660f8d6fb19af4cccb18b7affc68c66e5368c Mon Sep 17 00:00:00 2001
From: Amr Magdy <36246549+amrmagdy12@users.noreply.github.com>
Date: Tue, 3 Mar 2020 23:43:08 +0200
Subject: [PATCH 66/78] Updated-with-bonus
---
src/company/Fibonacci.java | 11 +++++------
src/company/Main.java | 18 ++++++++++++++++++
2 files changed, 23 insertions(+), 6 deletions(-)
create mode 100644 src/company/Main.java
diff --git a/src/company/Fibonacci.java b/src/company/Fibonacci.java
index 8810480..82f11eb 100644
--- a/src/company/Fibonacci.java
+++ b/src/company/Fibonacci.java
@@ -11,13 +11,13 @@ public void preprocess(int input) throws Exception {
@Override
public int doCalculation(int n) {
- int pascTriangle[][] = new int [n][n] ;
- pascTriangle[1][0] = 1;
- pascTriangle[1][1] = 1;
if (n == 1 || n == 2) return 1 ;
- else {
- // drawing pascal's triangle as a base for Fibonnacii
+
+ int pascTriangle[][] = new int [n][n] ;
+
+ // drawing pascal's triangle as a base for Fibonnacii
+
for (int i = 2; i < n; i++) {
pascTriangle[i][0] = 1;
for (int j = 1; j <= i; j++) {
@@ -41,7 +41,6 @@ public int doCalculation(int n) {
return result ;
}
- }
@Override
public void printAnswer(int out) {
diff --git a/src/company/Main.java b/src/company/Main.java
new file mode 100644
index 0000000..effeda9
--- /dev/null
+++ b/src/company/Main.java
@@ -0,0 +1,18 @@
+package company;
+
+import java.util.Scanner;
+
+public class Main {
+ private static IntegerSubscriber subscribers [] = {
+ new Fibonacci(),
+ };
+ public static void main(String[] args) throws Exception{
+ Topic mathTopic = new Topic();
+ for (ISubscriber sub : subscribers) {
+ mathTopic.addSubscriber(sub);
+ }
+ Scanner sc = new Scanner(System.in);
+ int input = sc.nextInt() ;
+ mathTopic.dispatchEvent(input);
+ }
+}
From 05736f6e286ed7c63ca3854146189e52b220b7b3 Mon Sep 17 00:00:00 2001
From: mohamed magdy <36678529+devmagdyy@users.noreply.github.com>
Date: Tue, 3 Mar 2020 23:43:32 +0200
Subject: [PATCH 67/78] 20160219MultiplicationSeries-Adding-Bonus
---
src/MultiplicationSeries.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/MultiplicationSeries.java b/src/MultiplicationSeries.java
index d3a4244..c12a20d 100644
--- a/src/MultiplicationSeries.java
+++ b/src/MultiplicationSeries.java
@@ -1,6 +1,6 @@
public class MultiplicationSeries implements IntegerSubscriber {
- @Override
+ @Override
public void preProcess(int input) {
System.out.println("Hello, I'm MultiplicationSeries, and I'm notified with: " + input + " as input. ");
if (input < 0) throw new Exception("Negative input is invalid!");
From cb6e0583279a60d3dc3cc8e9cc5e4d8bfdf2f787 Mon Sep 17 00:00:00 2001
From: Amr Magdy <36246549+amrmagdy12@users.noreply.github.com>
Date: Tue, 3 Mar 2020 23:48:54 +0200
Subject: [PATCH 68/78] Revert "Updated-with-bonus"
This reverts commit 356660f8d6fb19af4cccb18b7affc68c66e5368c.
---
src/company/Fibonacci.java | 11 ++++++-----
src/company/Main.java | 18 ------------------
2 files changed, 6 insertions(+), 23 deletions(-)
delete mode 100644 src/company/Main.java
diff --git a/src/company/Fibonacci.java b/src/company/Fibonacci.java
index 82f11eb..8810480 100644
--- a/src/company/Fibonacci.java
+++ b/src/company/Fibonacci.java
@@ -11,13 +11,13 @@ public void preprocess(int input) throws Exception {
@Override
public int doCalculation(int n) {
-
- if (n == 1 || n == 2) return 1 ;
-
int pascTriangle[][] = new int [n][n] ;
+ pascTriangle[1][0] = 1;
+ pascTriangle[1][1] = 1;
- // drawing pascal's triangle as a base for Fibonnacii
-
+ if (n == 1 || n == 2) return 1 ;
+ else {
+ // drawing pascal's triangle as a base for Fibonnacii
for (int i = 2; i < n; i++) {
pascTriangle[i][0] = 1;
for (int j = 1; j <= i; j++) {
@@ -41,6 +41,7 @@ public int doCalculation(int n) {
return result ;
}
+ }
@Override
public void printAnswer(int out) {
diff --git a/src/company/Main.java b/src/company/Main.java
deleted file mode 100644
index effeda9..0000000
--- a/src/company/Main.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package company;
-
-import java.util.Scanner;
-
-public class Main {
- private static IntegerSubscriber subscribers [] = {
- new Fibonacci(),
- };
- public static void main(String[] args) throws Exception{
- Topic mathTopic = new Topic();
- for (ISubscriber sub : subscribers) {
- mathTopic.addSubscriber(sub);
- }
- Scanner sc = new Scanner(System.in);
- int input = sc.nextInt() ;
- mathTopic.dispatchEvent(input);
- }
-}
From 5ee3bd52fb1e7d3321937c0de81cc74aa86c30d6 Mon Sep 17 00:00:00 2001
From: Amr Magdy <36246549+amrmagdy12@users.noreply.github.com>
Date: Tue, 3 Mar 2020 23:49:07 +0200
Subject: [PATCH 69/78] Updated-with-bonus
---
src/Fibonacci.java | 50 ++++++++++++++++++++++++++++++++++++++++++++++
src/Main.java | 7 +++----
2 files changed, 53 insertions(+), 4 deletions(-)
create mode 100644 src/Fibonacci.java
diff --git a/src/Fibonacci.java b/src/Fibonacci.java
new file mode 100644
index 0000000..82f11eb
--- /dev/null
+++ b/src/Fibonacci.java
@@ -0,0 +1,50 @@
+package company;
+public class Fibonacci extends IntegerSubscriber{
+
+ @Override
+ public void preprocess(int input) throws Exception {
+
+ if(input < 1 ) throw new Exception("0 and Negative values are invalid ") ;
+
+ System.out.println("I'am Fibonnacii and I'am notified with >> " + input);
+ }
+
+ @Override
+ public int doCalculation(int n) {
+
+ if (n == 1 || n == 2) return 1 ;
+
+ int pascTriangle[][] = new int [n][n] ;
+
+ // drawing pascal's triangle as a base for Fibonnacii
+
+ for (int i = 2; i < n; i++) {
+ pascTriangle[i][0] = 1;
+ for (int j = 1; j <= i; j++) {
+ pascTriangle[i][j] = pascTriangle[i - 1][j - 1] + pascTriangle[i - 1][j];
+ }
+ pascTriangle[i][i] = 1;
+ }
+
+ int i = n - 1;
+ int j = 0;
+ int result = 0;
+
+ while (j <= i)
+ {
+ result += pascTriangle[i][j];
+ i--;
+ j++;
+
+ }
+
+ return result ;
+
+ }
+
+ @Override
+ public void printAnswer(int out) {
+
+ System.out.println("the answer is " + out );
+ }
+}
diff --git a/src/Main.java b/src/Main.java
index 5187553..effeda9 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -1,13 +1,12 @@
-package com.company;
+package company;
import java.util.Scanner;
public class Main {
- private static ISubscriber subscribers [] = {
- new SimpleSubscriber(),
+ private static IntegerSubscriber subscribers [] = {
new Fibonacci(),
};
- public static void main(String[] args) {
+ public static void main(String[] args) throws Exception{
Topic mathTopic = new Topic();
for (ISubscriber sub : subscribers) {
mathTopic.addSubscriber(sub);
From 2c40605deaf245358db716f04df026a32ece06f3 Mon Sep 17 00:00:00 2001
From: Amr Magdy <36246549+amrmagdy12@users.noreply.github.com>
Date: Tue, 3 Mar 2020 23:51:32 +0200
Subject: [PATCH 70/78] Delete Fibonacci.java
---
src/company/Fibonacci.java | 51 --------------------------------------
1 file changed, 51 deletions(-)
delete mode 100644 src/company/Fibonacci.java
diff --git a/src/company/Fibonacci.java b/src/company/Fibonacci.java
deleted file mode 100644
index 8810480..0000000
--- a/src/company/Fibonacci.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package company;
-public class Fibonacci extends IntegerSubscriber{
-
- @Override
- public void preprocess(int input) throws Exception {
-
- if(input < 1 ) throw new Exception("0 and Negative values are invalid ") ;
-
- System.out.println("I'am Fibonnacii and I'am notified with >> " + input);
- }
-
- @Override
- public int doCalculation(int n) {
- int pascTriangle[][] = new int [n][n] ;
- pascTriangle[1][0] = 1;
- pascTriangle[1][1] = 1;
-
- if (n == 1 || n == 2) return 1 ;
- else {
- // drawing pascal's triangle as a base for Fibonnacii
- for (int i = 2; i < n; i++) {
- pascTriangle[i][0] = 1;
- for (int j = 1; j <= i; j++) {
- pascTriangle[i][j] = pascTriangle[i - 1][j - 1] + pascTriangle[i - 1][j];
- }
- pascTriangle[i][i] = 1;
- }
-
- int i = n - 1;
- int j = 0;
- int result = 0;
-
- while (j <= i)
- {
- result += pascTriangle[i][j];
- i--;
- j++;
-
- }
-
- return result ;
-
- }
- }
-
- @Override
- public void printAnswer(int out) {
-
- System.out.println("the answer is " + out );
- }
-}
From 9e5f5798b487dcb43916c5330c2f03e1b3fc7c32 Mon Sep 17 00:00:00 2001
From: Amr Magdy <36246549+amrmagdy12@users.noreply.github.com>
Date: Wed, 4 Mar 2020 00:33:25 +0200
Subject: [PATCH 71/78] syntax-updated
preprocess-to-preProcess
---
src/Fibonacci.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Fibonacci.java b/src/Fibonacci.java
index 82f11eb..fbd143c 100644
--- a/src/Fibonacci.java
+++ b/src/Fibonacci.java
@@ -2,7 +2,7 @@
public class Fibonacci extends IntegerSubscriber{
@Override
- public void preprocess(int input) throws Exception {
+ public void preProcess(int input) throws Exception {
if(input < 1 ) throw new Exception("0 and Negative values are invalid ") ;
From 52fdbb3d65adca247d421e4b7084361138c8341f Mon Sep 17 00:00:00 2001
From: Amr Magdy <36246549+amrmagdy12@users.noreply.github.com>
Date: Thu, 5 Mar 2020 20:35:28 +0200
Subject: [PATCH 72/78] Update Fibonacci.java
---
src/Fibonacci.java | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/Fibonacci.java b/src/Fibonacci.java
index fbd143c..8fb5672 100644
--- a/src/Fibonacci.java
+++ b/src/Fibonacci.java
@@ -1,4 +1,3 @@
-package company;
public class Fibonacci extends IntegerSubscriber{
@Override
From f5567984762b2028f8e49ee6f0d7332ca50f5b3d Mon Sep 17 00:00:00 2001
From: Amr Magdy <36246549+amrmagdy12@users.noreply.github.com>
Date: Thu, 5 Mar 2020 20:38:32 +0200
Subject: [PATCH 73/78] Update Main.java
---
src/Main.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/src/Main.java b/src/Main.java
index effeda9..a47a517 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -1,9 +1,7 @@
-package company;
-
import java.util.Scanner;
public class Main {
- private static IntegerSubscriber subscribers [] = {
+ private static ISubscriber subscribers [] = {
new Fibonacci(),
};
public static void main(String[] args) throws Exception{
From 635d69d11abcfac9edce9ac1125b29d5522b9a4e Mon Sep 17 00:00:00 2001
From: Amr Magdy <36246549+amrmagdy12@users.noreply.github.com>
Date: Thu, 5 Mar 2020 20:43:10 +0200
Subject: [PATCH 74/78] Updated
---
src/Main.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/Main.java b/src/Main.java
index a47a517..f7e593c 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -4,7 +4,7 @@ public class Main {
private static ISubscriber subscribers [] = {
new Fibonacci(),
};
- public static void main(String[] args) throws Exception{
+ public static void main(String[] args){
Topic mathTopic = new Topic();
for (ISubscriber sub : subscribers) {
mathTopic.addSubscriber(sub);
From 7ea0a0354ca73a2baff9a076ca42b4280c1949e7 Mon Sep 17 00:00:00 2001
From: Megadardery
Date: Thu, 5 Mar 2020 23:26:42 +0200
Subject: [PATCH 75/78] merge-main
---
src/Main.java | 59 ++++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 47 insertions(+), 12 deletions(-)
diff --git a/src/Main.java b/src/Main.java
index f7e593c..60dbeb9 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -1,16 +1,51 @@
import java.util.Scanner;
public class Main {
- private static ISubscriber subscribers [] = {
+ private static ISubscriber subscribers [] = {
+ new MultiplicationSeries(),
+ new SummationSeries(),
+
+ new CircleCircumference(),
+ new CircleArea(),
+ new CircleVolume(),
+
+ new SphereCircumference(),
+ new SphereArea(),
+ new SphereVolume(),
+
new Fibonacci(),
- };
- public static void main(String[] args){
- Topic mathTopic = new Topic();
- for (ISubscriber sub : subscribers) {
- mathTopic.addSubscriber(sub);
- }
- Scanner sc = new Scanner(System.in);
- int input = sc.nextInt() ;
- mathTopic.dispatchEvent(input);
- }
-}
+ new TwoPowerN(),
+
+ };
+ public static void main(String[] args) {
+ Scanner sc = new Scanner(System.in);
+
+ Topic mathTopic = new Topic();
+ for (ISubscriber sub : subscribers) {
+ mathTopic.addSubscriber(sub);
+ }
+
+ try{
+ for (int i = 0; i < subscribers.length; ++i) {
+ System.out.println((i+1) + " - " + subscribers[i].getClass().getName());
+ }
+ System.out.println("0 - Run all functions");
+
+ System.out.println("Choose your option:");
+ int choice = Integer.parseInt(sc.next());
+
+ System.out.println("Enter input number: ");
+ int n = Integer.parseInt(sc.next());
+
+ if (choice < 0 || choice > subscribers.length) throw new Exception("Invalid choice.");
+ if (choice != 0)
+ subscribers[choice-1].notifySubscriber(n);
+ else
+ mathTopic.dispatchEvent(n);
+ }catch(NumberFormatException ignored) {
+ System.out.println("Your input is not a valid integer.");
+ }catch(Exception ex){
+ System.out.println(ex.getMessage());
+ }
+ }
+}
\ No newline at end of file
From a8483ab306207394c64ae5661f9a6cf7146fffb0 Mon Sep 17 00:00:00 2001
From: Megadardery
Date: Thu, 5 Mar 2020 23:36:10 +0200
Subject: [PATCH 76/78] merge attempt
---
src/Fibonacci.java | 49 ++++++++++++++++++++++++++++++++++++++++++++++
src/Main.java | 13 +++++++-----
2 files changed, 57 insertions(+), 5 deletions(-)
create mode 100644 src/Fibonacci.java
diff --git a/src/Fibonacci.java b/src/Fibonacci.java
new file mode 100644
index 0000000..8fb5672
--- /dev/null
+++ b/src/Fibonacci.java
@@ -0,0 +1,49 @@
+public class Fibonacci extends IntegerSubscriber{
+
+ @Override
+ public void preProcess(int input) throws Exception {
+
+ if(input < 1 ) throw new Exception("0 and Negative values are invalid ") ;
+
+ System.out.println("I'am Fibonnacii and I'am notified with >> " + input);
+ }
+
+ @Override
+ public int doCalculation(int n) {
+
+ if (n == 1 || n == 2) return 1 ;
+
+ int pascTriangle[][] = new int [n][n] ;
+
+ // drawing pascal's triangle as a base for Fibonnacii
+
+ for (int i = 2; i < n; i++) {
+ pascTriangle[i][0] = 1;
+ for (int j = 1; j <= i; j++) {
+ pascTriangle[i][j] = pascTriangle[i - 1][j - 1] + pascTriangle[i - 1][j];
+ }
+ pascTriangle[i][i] = 1;
+ }
+
+ int i = n - 1;
+ int j = 0;
+ int result = 0;
+
+ while (j <= i)
+ {
+ result += pascTriangle[i][j];
+ i--;
+ j++;
+
+ }
+
+ return result ;
+
+ }
+
+ @Override
+ public void printAnswer(int out) {
+
+ System.out.println("the answer is " + out );
+ }
+}
diff --git a/src/Main.java b/src/Main.java
index 8dc8592..d5d2e1c 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -3,15 +3,18 @@
public class Main {
private static ISubscriber subscribers [] = {
new MultiplicationSeries(),
+ new SummationSeries(),
+
+ new CircleCircumference(),
+ new CircleArea(),
new CircleVolume(),
+
new SphereCircumference(),
+ new SphereArea(),
new SphereVolume(),
- new CircleCircumference(),
- new SummationSeries(),
- new CircleArea(),
- new CircleVolume(),
+
+ new Fibonacci(),
new TwoPowerN(),
- new SphereArea(),
};
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
From 740da0d8c4d36ee2820cb23acc5af9776f5cb4b2 Mon Sep 17 00:00:00 2001
From: Megadardery
Date: Thu, 5 Mar 2020 23:46:13 +0200
Subject: [PATCH 77/78] reformatting, loop input, fixes
---
src/Main.java | 49 +++++++++++++++++++++--------------
src/MultiplicationSeries.java | 14 +++++-----
src/TwoPowerN.java | 2 +-
3 files changed, 38 insertions(+), 27 deletions(-)
diff --git a/src/Main.java b/src/Main.java
index b58f661..3587ba3 100644
--- a/src/Main.java
+++ b/src/Main.java
@@ -1,21 +1,22 @@
import java.util.Scanner;
public class Main {
- private static ISubscriber subscribers [] = {
+ private static ISubscriber subscribers[] = {
new MultiplicationSeries(),
new SummationSeries(),
-
+
new CircleCircumference(),
new CircleArea(),
new CircleVolume(),
-
+
new SphereCircumference(),
new SphereArea(),
new SphereVolume(),
-
+
new Fibonacci(),
new TwoPowerN(),
};
+
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
@@ -24,26 +25,34 @@ public static void main(String[] args) {
mathTopic.addSubscriber(sub);
}
- try{
- for (int i = 0; i < subscribers.length; ++i) {
- System.out.println((i+1) + " - " + subscribers[i].getClass().getName());
- }
- System.out.println("0 - Run all functions");
+ try {
+ while (true) {
- System.out.println("Choose your option:");
- int choice = Integer.parseInt(sc.next());
- System.out.println("Enter input number: ");
- int n = Integer.parseInt(sc.next());
+ for (int i = 0; i < subscribers.length; ++i) {
+ System.out.println((i + 1) + " - " + subscribers[i].getClass().getName());
+ }
+ System.out.println("0 - Run all functions");
+ System.out.println("X - Exit application");
- if (choice < 0 || choice > subscribers.length) throw new Exception("Invalid choice.");
- if (choice != 0)
- subscribers[choice-1].notifySubscriber(n);
- else
- mathTopic.dispatchEvent(n);
- }catch(NumberFormatException ignored) {
+ System.out.println("Choose your option:");
+ String input = sc.next();
+ if (input.equals("X")) break;
+ int choice = Integer.parseInt(input);
+
+ System.out.println("Enter input number: ");
+ int n = Integer.parseInt(sc.next());
+
+ if (choice < 0 || choice > subscribers.length) throw new Exception("Invalid choice.");
+ if (choice != 0)
+ subscribers[choice - 1].notifySubscriber(n);
+ else
+ mathTopic.dispatchEvent(n);
+
+ }
+ } catch (NumberFormatException ignored) {
System.out.println("Your input is not a valid integer.");
- }catch(Exception ex){
+ } catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
diff --git a/src/MultiplicationSeries.java b/src/MultiplicationSeries.java
index c12a20d..89a3c7f 100644
--- a/src/MultiplicationSeries.java
+++ b/src/MultiplicationSeries.java
@@ -1,20 +1,22 @@
-public class MultiplicationSeries implements IntegerSubscriber {
+public class MultiplicationSeries extends IntegerSubscriber {
- @Override
- public void preProcess(int input) {
+ @Override
+ public void preProcess(int input) throws Exception {
System.out.println("Hello, I'm MultiplicationSeries, and I'm notified with: " + input + " as input. ");
if (input < 0) throw new Exception("Negative input is invalid!");
}
+
@Override
public int doCalculation(int input) {
int result = 1;
- for(int i=1; i<=input; i++){
- result = result*i;
+ for (int i = 1; i <= input; i++) {
+ result = result * i;
}
return result;
}
-}
+
@Override
public void printAnswer(int output) {
System.out.println("The Multiplication Series = " + output);
}
+}
\ No newline at end of file
diff --git a/src/TwoPowerN.java b/src/TwoPowerN.java
index e40979c..6fd5f82 100644
--- a/src/TwoPowerN.java
+++ b/src/TwoPowerN.java
@@ -8,6 +8,6 @@ public void notifySubscriber(int input) {
res += res;
}
- System.out.println(res);
+ System.out.println("Two power N is " + res);
}
}
\ No newline at end of file
From 3b2c92db52e600023e184c961891010aedb76abd Mon Sep 17 00:00:00 2001
From: Ahmed Dardery
Date: Fri, 6 Mar 2020 00:09:32 +0200
Subject: [PATCH 78/78] Create README.md
---
README.md | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 README.md
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..100deff
--- /dev/null
+++ b/README.md
@@ -0,0 +1,14 @@
+# Git Assignment for Team 15
+
+| Name | ID | Task | Completed? | Bonus Design? |
+| ----------- | ------------ | ----- | ---------- | ------------- |
+| @Moustafa878 | 20170285 | SphereArea | :heavy_check_mark: | :x: |
+| @devmagdyy | 20160219 | MultiplicationSeries | :heavy_check_mark: | :heavy_check_mark: |
+| @amrmagdy12 | 20170188 | Fibonacci | :heavy_check_mark: | :heavy_check_mark: |
+| @Marim-medhat | 20170282 | CircleArea | :heavy_check_mark: | :heavy_check_mark: |
+| @AbdulelahAdam | 20170416 | SphereVolume | :heavy_check_mark: | :heavy_check_mark: |
+| @mahmoud-mohamed-abozied | 20170270 | SummationSeries | :heavy_check_mark: | :heavy_check_mark: |
+| @Abdulazizsayed | 20170154 | 2PowerN | :heavy_check_mark: | :x: |
+| @ahmed-dardery | 20170034 | SphereCircumference | :heavy_check_mark: | :heavy_check_mark: |
+| @Mina1998 | 20170307 | CircleVolume | :heavy_check_mark: | :heavy_check_mark: |
+| @fatima196 | 20170193 | CircleCircumference | :heavy_check_mark: | :heavy_check_mark: |