Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
15fbb8a
Setting threads and adding Sphere area class
Disidious Nov 23, 2019
72cc86d
Added Circle Area
Nov 23, 2019
e5be084
Merge pull request #1 from MohamedAAbdelwahab/master
Disidious Nov 23, 2019
a60817a
Circle Circumference function implemented
Nov 23, 2019
b525315
added class body
Nov 23, 2019
f056626
added circumference object in main
Nov 23, 2019
59d2700
Merge pull request #2 from Kerberos-666/goodboybranch
Disidious Nov 23, 2019
61e3292
Added class summation series.
BouSenna Nov 23, 2019
36e2609
Added summation series object in main.
BouSenna Nov 23, 2019
168eed7
Cast input from double to integer.
BouSenna Nov 23, 2019
0dbf74b
Merge pull request #3 from BouSenna/master
eddsanity Nov 24, 2019
f8399a7
Added MultiplicationSeries Class
Nov 24, 2019
6dca8e4
Update MultiplicationSeries.java
Youssef-Hammad Nov 24, 2019
5ba609d
Update Main.java
Youssef-Hammad Nov 24, 2019
afed22d
Merge pull request #4 from Youssef-Hammad/master
eddsanity Nov 24, 2019
91fe3cb
Added .travis.yml Added ObserverTest and MainTest classes Changed all…
Disidious Nov 24, 2019
e50d086
test
Disidious Nov 24, 2019
24ac725
test2
Disidious Nov 24, 2019
bcc16fc
Merge pull request #6 from Kerberos-666/travis
BouSenna Nov 24, 2019
3345810
Added tests to MultiplicationSeries
Nov 25, 2019
4e9ee11
Update MultiplicationSeries.java
Youssef-Hammad Nov 25, 2019
44fcde9
Update SphereArea.java
Youssef-Hammad Nov 25, 2019
547ab4d
Delete GitAssignmentObserver.iml
Youssef-Hammad Nov 25, 2019
8a2f27b
Delete .gitignore
Youssef-Hammad Nov 25, 2019
1f22e41
Delete .name
Youssef-Hammad Nov 25, 2019
f8ac458
Delete misc.xml
Youssef-Hammad Nov 25, 2019
c8225b2
Delete modules.xml
Youssef-Hammad Nov 25, 2019
413ecbd
Delete vcs.xml
Youssef-Hammad Nov 25, 2019
2dd8fc3
Merge pull request #7 from Kerberos-666/badboybranch
BouSenna Nov 25, 2019
bc6696e
Update CircleArea.java
MohamedAAbdelwahab Nov 25, 2019
5711cb8
Update CircleArea.java
MohamedAAbdelwahab Nov 25, 2019
06ebfb2
modified Circumference function for Travis testing
Nov 25, 2019
3ae345c
Merge pull request #10 from Kerberos-666/badboybranch
Disidious Nov 25, 2019
5fa8d01
Added LucasSeries
alimasry Nov 25, 2019
3097e38
Updated LucasSeries
alimasry Nov 25, 2019
f9b1cc6
fixed typo
alimasry Nov 25, 2019
a2955e1
Merge pull request #14 from Kerberos-666/ali
Youssef-Hammad Nov 25, 2019
ac7049e
Updated summation series class
BouSenna Nov 25, 2019
9299d2e
Add files via upload
nura229 Nov 25, 2019
102096e
updated .gitignore
alimasry Nov 25, 2019
74dfc83
Add files via upload
nura229 Nov 25, 2019
1ff4fcd
removed .class files
alimasry Nov 25, 2019
e40a979
Merge pull request #15 from Kerberos-666/SummationSeriesBranch
Youssef-Hammad Nov 25, 2019
ca65549
Merge branch 'master' into ali
alimasry Nov 25, 2019
e932e18
Merge pull request #16 from Kerberos-666/ali
Youssef-Hammad Nov 25, 2019
64f5e62
Merge branch 'master' into nuran
eddsanity Nov 25, 2019
5b43464
Merge pull request #17 from Kerberos-666/nuran
alimasry Nov 25, 2019
678739f
Updates Main and MainTest classes
Disidious Nov 25, 2019
1730f56
Merge pull request #18 from Kerberos-666/fady
alimasry Nov 25, 2019
55f50b5
initial commit
AlyMarwan Nov 25, 2019
cfd62f0
Update Fibonacci.java
Disidious Nov 25, 2019
b553783
Update Fibonacci.java
Disidious Nov 25, 2019
6354ce4
Update Fibonacci.java
Disidious Nov 25, 2019
02bcc30
Merge pull request #19 from Kerberos-666/AM
Youssef-Hammad Nov 25, 2019
098ad86
add twoPowerN
Nov 26, 2019
9af6e91
add new power of n
Nov 26, 2019
42e33bf
add power
Nov 26, 2019
4ff3b5c
removed duplicate folder
Disidious Nov 26, 2019
95b61f9
Merge pull request #20 from Kerberos-666/newtwoPowerN
Youssef-Hammad Nov 26, 2019
031600f
Updated Main to take input in a loop
Disidious Nov 26, 2019
debb94e
Merge pull request #22 from Kerberos-666/fady
BouSenna Nov 26, 2019
bd8ac81
Update SphereArea.java
saraadam311461 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
12 changes: 6 additions & 6 deletions .classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
</classpath>
113 changes: 57 additions & 56 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,56 +1,57 @@
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# PyDev specific (Python IDE for Eclipse)
*.pydevproject

# CDT-specific (C/C++ Development Tooling)
.cproject

# CDT- autotools
.autotools

# Java annotation processor (APT)
.factorypath

# PDT-specific (PHP Development Tools)
.buildpath

# sbteclipse plugin
.target

# Tern plugin
.tern-project

# TeXlipse plugin
.texlipse

# STS (Spring Tool Suite)
.springBeans

# Code Recommenders
.recommenders/

# Annotation Processing
.apt_generated/
.apt_generated_test/

# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
*.class
local.properties
.settings/
.loadpath
.recommenders

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# PyDev specific (Python IDE for Eclipse)
*.pydevproject

# CDT-specific (C/C++ Development Tooling)
.cproject

# CDT- autotools
.autotools

# Java annotation processor (APT)
.factorypath

# PDT-specific (PHP Development Tools)
.buildpath

# sbteclipse plugin
.target

# Tern plugin
.tern-project

# TeXlipse plugin
.texlipse

# STS (Spring Tool Suite)
.springBeans

# Code Recommenders
.recommenders/

# Annotation Processing
.apt_generated/
.apt_generated_test/

# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet
34 changes: 17 additions & 17 deletions .project
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>GitAssignmentObserver</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>GitAssignmentObserver</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: bash
install: true
jdk: orcalejdk13
before_script: cd src
script:
- javac MainTest.java
- java MainTest

22 changes: 22 additions & 0 deletions src/CircleArea.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
public class CircleArea extends ThreadSubscriber implements ObserverTest {
double input;

@Override
public void notifySubscriber() {
input = topic.getInput();
System.out.println("Area of the circle is "+execute()+" in centimetres squared");

}

@Override
public String execute() {
String res = String.valueOf(3.14159265359*input*input);
return res;
}

@Override
public Boolean test() {
input = 1;
return execute().equals("3.14159265359");
}
}
21 changes: 21 additions & 0 deletions src/CircleCircumference.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
public class CircleCircumference extends ThreadSubscriber implements ObserverTest {
double input;

@Override
public void notifySubscriber()
{
input = topic.getInput();
System.out.println("Circle Circumference: " + execute());
}

@Override
public String execute() {
return String.valueOf(2 * input * 3.14);
}

@Override
public Boolean test() {
input = 0.5;
return execute().equals("3.14");
}
}
27 changes: 27 additions & 0 deletions src/CircleVolum.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
public class CircleVolum extends ThreadSubscriber implements ObserverTest
{
double input;

public void notifySubscriber() {
input=topic.getInput();
System.out.println("Volume = " + execute());
}
@Override
public String execute()
{
double volume= (4*22*input*input*input)/(3*7);

String result=String.valueOf(volume);

return result;
}
@Override
public Boolean test() {
input = 5;
if (execute().equals("523.8095238095239"))
return true;
else
return false;

}
}
39 changes: 39 additions & 0 deletions src/Fibonacci.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
public class Fibonacci extends ThreadSubscriber implements ObserverTest {
double input;
@Override
public void notifySubscriber() {
input = topic.getInput();
System.out.println("Result of Fibonacci series at "+input+": "+execute());
}
@Override
public String execute() {
int num1 = 0;
int num2 = 1;
int sum = 0;
if(input<=1)
sum = (int)input;
for(int i=1 ; i < input ; i++) {
sum = num1 + num2;
num1 = num2;
num2 = sum;
}
String str = String.valueOf(sum);

return str;
}
@Override

public Boolean test() {
input = 4;
if(!execute().equals("3")) {
return false;
}
input = 10;
if(!execute().equals("55")) {
return false;
}
return true;

}
}

3 changes: 2 additions & 1 deletion src/ISubscriber.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

public interface ISubscriber {
public abstract void notifySubscriber(String input);
public abstract void notifySubscriber();
public abstract String execute();
}
30 changes: 30 additions & 0 deletions src/LucasSeries.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
public class LucasSeries extends ThreadSubscriber implements ObserverTest {
double input;

@Override
public void notifySubscriber() {
input = topic.getInput();
System.out.println("Lucas Series of " + (int) input + " = " + execute());
}

@Override
public String execute() {
if ((int) input == 0)
return "2";

int fn_2 = 2, fn_1 = 1;
for (int i = 2; i <= (int) input; ++i) {
int temp = fn_1;
fn_1 = fn_1 + fn_2;
fn_2 = temp;
}

return String.valueOf(fn_1);
}

@Override
public Boolean test() {
input = 5;
return execute().equals("11");
}
}
47 changes: 30 additions & 17 deletions src/Main.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
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);
}
}
import java.util.Scanner;

public class Main {

public static void main(String[] args) {
while(true) {
ThreadSubscriber subscribers [] = {
new SphereArea() ,
new CircleArea(),
new CircleCircumference(),
new SummationSeries(),
new MultiplicationSeries(),
new CircleVolum(),
new LucasSeries(),
new Fibonacci(),
new twoPowerN()
};

Topic mathTopic = new Topic();
for (ThreadSubscriber sub : subscribers) {
mathTopic.addSubscriber(sub);
sub.setTopic(mathTopic);
}
Scanner sc = new Scanner(System.in);
double input = sc.nextDouble();
mathTopic.setInput(input);
mathTopic.dispatchEvent();
}
}
}
24 changes: 24 additions & 0 deletions src/MainTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
public class MainTest {
private static ObserverTest subscribers [] = {
new SphereArea() ,
new CircleArea(),
new CircleCircumference(),
new SummationSeries(),
new MultiplicationSeries(),
new CircleVolum(),
new LucasSeries(),
new Fibonacci(),
new twoPowerN()

};

public static void main(String[] args) {
for (ObserverTest sub : subscribers){
Boolean res = sub.test();
if(res!=null && res==false){
System.exit(1);
}
}
}
}

Loading