Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions .idea/.name

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

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.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/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.

100 changes: 100 additions & 0 deletions .idea/workspace.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>
20 changes: 20 additions & 0 deletions src/LucasSeries.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
public class LucasSeries implements ISubscriber {
@Override
public void notifySubscriber(String input) {
try {
int LucasIndex = Integer.parseInt(input);
System.out.println("Lucas Number is: " + Lucas(LucasIndex));
} catch (Exception e) {
System.out.println("Error: " + e.getMessage());
}
}

int Lucas(int idx) throws Exception {
if (idx <= 0) throw new Exception("Error: Lucas applied only for positive numbers.");
return Lucas(idx, 1, 2); // Lucas series 2 1 3 4 7 11 18 29
}

private int Lucas(int idx, int value, int previous) {
return (idx == 1 ? previous : Lucas(idx - 1, previous + value, value));
}
}
4 changes: 2 additions & 2 deletions src/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

public class Main {
private static ISubscriber subscribers [] = {
new SimpleSubscriber(),
new ReallySimpleSubscriber(),
new SphereArea(), new LucasSeries() , new SphereCircumference()

};
public static void main(String[] args) {
Topic mathTopic = new Topic();
Expand Down
8 changes: 0 additions & 8 deletions src/ReallySimpleSubscriber.java

This file was deleted.

10 changes: 0 additions & 10 deletions src/SimpleSubscriber.java

This file was deleted.

13 changes: 13 additions & 0 deletions src/SphereArea.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class SphereArea implements ISubscriber {
static float pi = 3.14159f;
@Override
public void notifySubscriber(String input) {

double Radius = Double.valueOf(input);
System.out.println( "Sphere Area = "+Calculate_Area(Radius));
}
double Calculate_Area(double radius){
return (4 * pi * radius * radius);
}

}
18 changes: 18 additions & 0 deletions src/SphereCircumference.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
public class SphereCircumference implements ISubscriber{
@Override
public void notifySubscriber(String input)
{
try
{
double radius = Double.parseDouble(input);

double circumference = (2 * Math.PI * radius);

System.out.println("Sphere Circumference = " + circumference);
}
catch (Exception e)
{
System.out.println("Exception: " + e);
}
}
}