Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
70a46c5
adding multiplication series class 20170204
Leenahessam Mar 1, 2020
0504174
Merge pull request #1 from Leenahessam/MultiplicationSeries20170204
Leenahessam Mar 1, 2020
f1ee481
aading lucasSeries class
Mar 1, 2020
99e4503
Merge pull request #2 from Leenahessam/LucasSeries20170125
theseifhassan Mar 1, 2020
35cd69d
https://github.com/Leenahessam/git_assignment_initial/tree/SphereVolu…
lubnahassan Mar 1, 2020
54d1d83
Merge pull request #3 from Leenahessam/SphereVolume20170202
Leenahessam Mar 1, 2020
65191f9
removing unneeded folder
Mar 1, 2020
2bf343f
Merge pull request #4 from Leenahessam/LucasSeries20170125
Leenahessam Mar 1, 2020
520f8da
added class twoPowerN
OsamaElneshwy Mar 2, 2020
ec0a980
Merge pull request #5 from Leenahessam/twoPowerN-20170041
Leenahessam Mar 2, 2020
cca0169
adding an opject of the twoPowerN class in main class
Mar 2, 2020
bee1a78
Merge pull request #6 from Leenahessam/LucasSeries20170125
Leenahessam Mar 2, 2020
0dc91f2
ball volume
saraadel414 Mar 2, 2020
f5438fc
Merge pull request #7 from Leenahessam/ballvolume-20170108
Leenahessam Mar 2, 2020
819f00b
update lucasSeries class
Leenahessam Mar 2, 2020
e21e2fa
update MultiplicationSeries class
Leenahessam Mar 2, 2020
a9347af
Adding CircleCercumference class
AbdelrahmanMohamedd Mar 2, 2020
e4110f0
Merge pull request #8 from Leenahessam/CircleCercumference20170148
Leenahessam Mar 2, 2020
5fcf5fc
adding a user menu to the main class
Mar 2, 2020
1d4e453
Merge pull request #9 from Leenahessam/LucasSeries20170125
Leenahessam Mar 2, 2020
526edc6
add SphereArea class and changes to main ID:20150011
sa3iid Mar 2, 2020
d69de0e
adding CricelArea class
NadiaAmer Mar 2, 2020
4105a81
Merge pull request #10 from Leenahessam/sphereArea20150011
Leenahessam Mar 3, 2020
1644301
Merge branch 'master' into CircalArea-20170382
Leenahessam Mar 3, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions GitAssignmentObserver.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/bin" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="inheritedJdk" />
</component>
</module>
13 changes: 13 additions & 0 deletions src/BallVolume.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

public class BallVolume implements ISubscriber {

@Override
public void notifySubscriber(String input) {

double r=Double.parseDouble(input);
double volume= (4*22*r*r*r)/(3*7);

System.out.println("Ball Volume is:" +volume);
}

}
15 changes: 15 additions & 0 deletions src/CircleArea.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@


public class CircleArea implements ISubscriber {


@Override
public void notifySubscriber(String input) {
double pi = 3.14 , res;
int r = Integer.parseInt(input);
res = pi *(r*r);
System.out.println("Area of circle:" + res );
}
}


12 changes: 12 additions & 0 deletions src/CircleCircumference.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public class CircleCircumference implements ISubscriber
{
@Override
public void notifySubscriber(String input)
{
Double radius = Double.parseDouble(input);
Double res = 2*Math.PI*radius;
System.out.println("circleCircumference is "+res );

}

}
32 changes: 32 additions & 0 deletions src/LucasSeries.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

public class LucasSeries implements ISubscriber{

@Override
public void notifySubscriber(String input) {
try {
int n = Integer.parseInt(input);
for(int i=1;i<=n;i++)
{
System.out.print(printSeries(i)+" ");
}
System.out.println("");
} catch (NumberFormatException e) {
System.out.println("Enter a valid input");
}



}
public int printSeries(int input)
{
if(input==1||input==0)
{
return 2;
}
if(input==2)
{
return 1;
}
return printSeries(input-1)+printSeries(input-2);
}
}
87 changes: 74 additions & 13 deletions src/Main.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,78 @@
import java.util.Scanner;

public class Main {
private static ISubscriber subscribers [] = {
new SimpleSubscriber(),
new ReallySimpleSubscriber(),
};
public static void main(String[] args) {
Topic mathTopic = new Topic();
for (ISubscriber sub : subscribers) {
mathTopic.addSubscriber(sub);
}
Scanner sc = new Scanner(System.in);
String input = sc.next();
mathTopic.dispatchEvent(input);
}
private static ISubscriber subscribers [] = {
new SimpleSubscriber(),
new ReallySimpleSubscriber(),
new MultiplicationSeries(),
new LucasSeries(),
new SphereVolume(),
new BallVolume(),
new twoPowerN(),
new CircleCircumference(),
new SphereArea(),
new CircleArea()

//please add your object here
};
public static void main(String[] args) {
Topic mathTopic = new Topic();
System.out.println("Enter 0 to execute all");
System.out.println("1-SimpleSubscriber\n" +
"2-ReallySimpleSubscriber\n3-MultiplicationSeries\n4-LucasSeries\n" +
"5-SphereVolume\n6-BallVolume\n7-twoPowerN\n8-CircleCircumference");
Scanner choice = new Scanner(System.in);
System.out.println("Enter your choice: ");
int c = choice.nextInt();
if(c==0) {

for (ISubscriber sub : subscribers) {
mathTopic.addSubscriber(sub);
}

}
else if(c==1)
{
mathTopic.addSubscriber(subscribers[0]);
}
else if(c==2)
{
mathTopic.addSubscriber(subscribers[1]);
}
else if(c==3)
{
mathTopic.addSubscriber(subscribers[2]);
}
else if(c==4)
{
mathTopic.addSubscriber(subscribers[3]);
}
else if(c==5)
{
mathTopic.addSubscriber(subscribers[4]);
}
else if(c==6)
{
mathTopic.addSubscriber(subscribers[5]);
}
else if(c==7)
{
mathTopic.addSubscriber(subscribers[6]);
}
else if(c==8) {
mathTopic.addSubscriber(subscribers[7]);
}
else if (c==9){
mathTopic.addSubscriber(subscribers[8]);
}

//please call your method as the above calls here


Scanner sc = new Scanner(System.in);
System.out.println("Enter your input: ");
String input = sc.next();
mathTopic.dispatchEvent(input);

}
}
31 changes: 31 additions & 0 deletions src/MultiplicationSeries.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@



public class MultiplicationSeries implements ISubscriber {
private int count;
private int product = 1;
@Override
public void notifySubscriber(String input) {
count = Integer.parseInt(input);
try {
System.out.println(MultSeries(count));
}
catch (NumberFormatException e) {
System.out.println(e.getMessage());
}

}
int MultSeries (int num)
{
int number = 1;
for (int i=0; i<num ; i++)
{
product*=number;
number++;
}
return product;
}
}



7 changes: 7 additions & 0 deletions src/SphereArea.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
public class SphereArea implements ISubscriber {
@Override
public void notifySubscriber(String input) {
int radius = Integer.parseInt(input);
System.out.println("The sphere area is "+4*radius*radius*3.14);
}
}
10 changes: 10 additions & 0 deletions src/SphereVolume.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
public class SphereVolume implements ISubscriber
{
@Override
public void notifySubscriber(String radius)
{
double Result =0.0;
Result = (Math.pow(Double.parseDouble(radius),3)*4/3*Math.PI); // pi = 22/7
System.out.println("The Sphere Volume --> "+Result);
}
}
12 changes: 12 additions & 0 deletions src/twoPowerN.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
public class twoPowerN implements ISubscriber
{
@Override
public void notifySubscriber(String input)
{
Double x = Double.parseDouble(input);
Double result = Math.pow(2,x);
System.out.println("2 Power "+x+" = "+result );

}

}