diff --git a/contents/bogo_sort/bogo_sort.md b/contents/bogo_sort/bogo_sort.md index 2cc4f3a44..5b4eca980 100644 --- a/contents/bogo_sort/bogo_sort.md +++ b/contents/bogo_sort/bogo_sort.md @@ -22,7 +22,7 @@ In code, it looks something like this: {% sample lang="c" %} [import:25-29, lang:"c"](code/c/bogo_sort.c) {% sample lang="java" %} -[import:2-6, lang:"java"](code/java/bogo.java) +[import:2-6, lang:"java"](code/java/Bogo.java) {% sample lang="js" %} [import:11-15, lang:"javascript"](code/javascript/bogo.js) {% sample lang="py" %} @@ -90,7 +90,7 @@ We are done here! {% sample lang="c" %} [import, lang:"c"](code/c/bogo_sort.c) {% sample lang="java" %} -[import, lang:"java"](code/java/bogo.java) +[import, lang:"java"](code/java/Bogo.java) {% sample lang="js" %} [import, lang:"javascript"](code/javascript/bogo.js) {% sample lang="py" %} diff --git a/contents/bogo_sort/code/java/bogo.java b/contents/bogo_sort/code/java/Bogo.java similarity index 100% rename from contents/bogo_sort/code/java/bogo.java rename to contents/bogo_sort/code/java/Bogo.java diff --git a/contents/bubble_sort/bubble_sort.md b/contents/bubble_sort/bubble_sort.md index 15e180e33..6781c3621 100644 --- a/contents/bubble_sort/bubble_sort.md +++ b/contents/bubble_sort/bubble_sort.md @@ -17,7 +17,7 @@ This means that we need to go through the vector $$\mathcal{O}(n^2)$$ times with {% sample lang="c8" %} [import:39-63, lang:"chip-8"](code/chip8/bubblesort.c8) {% sample lang="java" %} -[import:2-12, lang:"java"](code/java/bubble.java) +[import:2-12, lang:"java"](code/java/Bubble.java) {% sample lang="kotlin" %} [import:1-11, lang:"kotlin"](code/kotlin/BubbleSort.kt) {% sample lang="js" %} @@ -90,7 +90,7 @@ Trust me, there are plenty of more complicated algorithms that do precisely the {% sample lang="c8" %} [import, lang:"chip-8"](code/chip8/bubblesort.c8) {% sample lang="java" %} -[import, lang:"java"](code/java/bubble.java) +[import, lang:"java"](code/java/Bubble.java) {% sample lang="kotlin" %} [import, lang:"kotlin"](code/kotlin/BubbleSort.kt) {% sample lang="js" %} diff --git a/contents/bubble_sort/code/java/bubble.java b/contents/bubble_sort/code/java/Bubble.java similarity index 99% rename from contents/bubble_sort/code/java/bubble.java rename to contents/bubble_sort/code/java/Bubble.java index 2c6e06ba1..3ece7c965 100644 --- a/contents/bubble_sort/code/java/bubble.java +++ b/contents/bubble_sort/code/java/Bubble.java @@ -11,7 +11,6 @@ static void bubbleSort(int[] arr) { } } - public static void main(String[] args) { int[] test = new int[]{20, -3, 50, 1, -6, 59}; diff --git a/contents/monte_carlo_integration/code/java/MonteCarlo.java b/contents/monte_carlo_integration/code/java/MonteCarlo.java index b5c53faef..61d54c2e3 100644 --- a/contents/monte_carlo_integration/code/java/MonteCarlo.java +++ b/contents/monte_carlo_integration/code/java/MonteCarlo.java @@ -1,4 +1,3 @@ -//submitted by DominikRafacz import java.util.Random; public class MonteCarlo { @@ -9,12 +8,12 @@ public static void main(String[] args) { System.out.printf("Percent error: " + 100 * Math.abs(piEstimation - Math.PI) / Math.PI); } - //function to check whether point (x,y) is in unit circle + // function to check whether point (x,y) is in unit circle private static boolean inCircle(double x, double y) { return x * x + y * y < 1; } - //function to calculate estimation of pi + // function to calculate estimation of pi public static double monteCarlo(int samples) { int piCount = 0; @@ -28,7 +27,6 @@ public static double monteCarlo(int samples) { } } - double estimation = 4.0 * piCount / samples; - return estimation; + return 4.0 * piCount / samples; } } diff --git a/contents/monte_carlo_integration/monte_carlo_integration.md b/contents/monte_carlo_integration/monte_carlo_integration.md index d01a8ba50..436794269 100644 --- a/contents/monte_carlo_integration/monte_carlo_integration.md +++ b/contents/monte_carlo_integration/monte_carlo_integration.md @@ -58,7 +58,7 @@ each point is tested to see whether it's in the circle or not: {% sample lang="r" %} [import:2-6, lang:"r"](code/r/monte_carlo.R) {% sample lang="java" %} -[import:13-15, lang:"java"](code/java/MonteCarlo.java) +[import:12-14, lang:"java"](code/java/MonteCarlo.java) {% sample lang="swift" %} [import:1-3, lang:"swift"](code/swift/monte_carlo.swift) {% sample lang="py" %} diff --git a/contents/verlet_integration/code/java/Verlet.java b/contents/verlet_integration/code/java/Verlet.java index 6d102809b..b7494d65f 100644 --- a/contents/verlet_integration/code/java/Verlet.java +++ b/contents/verlet_integration/code/java/Verlet.java @@ -1,14 +1,3 @@ -// Submitted by lolatomroflsinnlos -public class VerletValues { - public double time; - public double vel; - - public VerletValues(double time, double vel) { - this.time = time; - this.vel = vel; - } -} - public class Verlet { static double verlet(double pos, double acc, double dt) { @@ -44,8 +33,7 @@ static VerletValues stormer_verlet(double pos, double acc, double dt) { vel += acc*dt; } - VerletValues stormerVerlet = new VerletValues(time, vel); - return stormerVerlet; + return new VerletValues(time, vel); } static VerletValues velocity_verlet(double pos, double acc, double dt) { @@ -58,10 +46,8 @@ static VerletValues velocity_verlet(double pos, double acc, double dt) { time += dt; pos += vel*dt + 0.5*acc * dt * dt; vel += acc*dt; - } - - VerletValues velocityVerlet = new VerletValues(time, vel); - return velocityVerlet; + } + return new VerletValues(time, vel); } public static void main(String[] args) { diff --git a/contents/verlet_integration/code/java/VerletValues.java b/contents/verlet_integration/code/java/VerletValues.java new file mode 100644 index 000000000..8dc5ceb84 --- /dev/null +++ b/contents/verlet_integration/code/java/VerletValues.java @@ -0,0 +1,9 @@ +public class VerletValues { + public double time; + public double vel; + + public VerletValues(double time, double vel) { + this.time = time; + this.vel = vel; + } +} diff --git a/contents/verlet_integration/verlet_integration.md b/contents/verlet_integration/verlet_integration.md index 9b994cdaf..a3811be1a 100644 --- a/contents/verlet_integration/verlet_integration.md +++ b/contents/verlet_integration/verlet_integration.md @@ -37,7 +37,7 @@ Here is what it looks like in code: {% sample lang="c" %} [import:3-14, lang:"c"](code/c/verlet.c) {% sample lang="java" %} -[import:13-28, lang:"java"](code/java/Verlet.java) +[import:2-17, lang:"java"](code/java/Verlet.java) {% sample lang="py" %} [import:1-10, lang:"python"](code/python/verlet.py) {% sample lang="hs" %} @@ -91,7 +91,7 @@ However, the error for this is $$\mathcal{O}(\Delta t)$$, which is quite poor, b {% sample lang="c" %} [import:16-31, lang:"c"](code/c/verlet.c) {% sample lang="java" %} -[import:30-49, lang:"java"](code/java/Verlet.java) +[import:19-37, lang:"java"](code/java/Verlet.java) {% sample lang="py" %} [import:12-23, lang:"python"](code/python/verlet.py) {% sample lang="hs" %} @@ -159,7 +159,7 @@ Here is the velocity Verlet method in code: {% sample lang="c" %} [import:33-43, lang:"c"](code/c/verlet.c) {% sample lang="java" %} -[import:51-65, lang:"java"](code/java/Verlet.java) +[import:39-51, lang:"java"](code/java/Verlet.java) {% sample lang="py" %} [import:25-34, lang:"python"](code/python/verlet.py) {% sample lang="hs" %} @@ -213,6 +213,7 @@ Both of these methods work simply by iterating timestep-by-timestep and can be w {% sample lang="c" %} [import, lang:"c"](code/c/verlet.c) {% sample lang="java" %} +[import, lang:"java"](code/java/VerletValues.java) [import, lang:"java"](code/java/Verlet.java) {% sample lang="py" %} [import, lang:"python"](code/python/verlet.py)