Skip to content

Commit 37e2607

Browse files
berquistleios
authored andcommitted
Java filename changes for Verlet / bogosort / bubblesort (#577)
* Change filename for Java implementation of Verlet integration * Change filename for Java implementation of bogosort * Change filename for Java implementation of bubble sort * Remove extra assignment in Java implementation of Monte Carlo
1 parent ef8cb6b commit 37e2607

File tree

9 files changed

+24
-31
lines changed

9 files changed

+24
-31
lines changed

contents/bogo_sort/bogo_sort.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ In code, it looks something like this:
2222
{% sample lang="c" %}
2323
[import:25-29, lang:"c"](code/c/bogo_sort.c)
2424
{% sample lang="java" %}
25-
[import:2-6, lang:"java"](code/java/bogo.java)
25+
[import:2-6, lang:"java"](code/java/Bogo.java)
2626
{% sample lang="js" %}
2727
[import:11-15, lang:"javascript"](code/javascript/bogo.js)
2828
{% sample lang="py" %}
@@ -90,7 +90,7 @@ We are done here!
9090
{% sample lang="c" %}
9191
[import, lang:"c"](code/c/bogo_sort.c)
9292
{% sample lang="java" %}
93-
[import, lang:"java"](code/java/bogo.java)
93+
[import, lang:"java"](code/java/Bogo.java)
9494
{% sample lang="js" %}
9595
[import, lang:"javascript"](code/javascript/bogo.js)
9696
{% sample lang="py" %}

contents/bubble_sort/bubble_sort.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ This means that we need to go through the vector $$\mathcal{O}(n^2)$$ times with
1717
{% sample lang="c8" %}
1818
[import:39-63, lang:"chip-8"](code/chip8/bubblesort.c8)
1919
{% sample lang="java" %}
20-
[import:2-12, lang:"java"](code/java/bubble.java)
20+
[import:2-12, lang:"java"](code/java/Bubble.java)
2121
{% sample lang="kotlin" %}
2222
[import:1-11, lang:"kotlin"](code/kotlin/BubbleSort.kt)
2323
{% sample lang="js" %}
@@ -90,7 +90,7 @@ Trust me, there are plenty of more complicated algorithms that do precisely the
9090
{% sample lang="c8" %}
9191
[import, lang:"chip-8"](code/chip8/bubblesort.c8)
9292
{% sample lang="java" %}
93-
[import, lang:"java"](code/java/bubble.java)
93+
[import, lang:"java"](code/java/Bubble.java)
9494
{% sample lang="kotlin" %}
9595
[import, lang:"kotlin"](code/kotlin/BubbleSort.kt)
9696
{% sample lang="js" %}

contents/bubble_sort/code/java/bubble.java renamed to contents/bubble_sort/code/java/Bubble.java

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ static void bubbleSort(int[] arr) {
1111
}
1212
}
1313

14-
1514
public static void main(String[] args) {
1615
int[] test = new int[]{20, -3, 50, 1, -6, 59};
1716

contents/monte_carlo_integration/code/java/MonteCarlo.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
//submitted by DominikRafacz
21
import java.util.Random;
32

43
public class MonteCarlo {
@@ -9,12 +8,12 @@ public static void main(String[] args) {
98
System.out.printf("Percent error: " + 100 * Math.abs(piEstimation - Math.PI) / Math.PI);
109
}
1110

12-
//function to check whether point (x,y) is in unit circle
11+
// function to check whether point (x,y) is in unit circle
1312
private static boolean inCircle(double x, double y) {
1413
return x * x + y * y < 1;
1514
}
1615

17-
//function to calculate estimation of pi
16+
// function to calculate estimation of pi
1817
public static double monteCarlo(int samples) {
1918
int piCount = 0;
2019

@@ -28,7 +27,6 @@ public static double monteCarlo(int samples) {
2827
}
2928
}
3029

31-
double estimation = 4.0 * piCount / samples;
32-
return estimation;
30+
return 4.0 * piCount / samples;
3331
}
3432
}

contents/monte_carlo_integration/monte_carlo_integration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ each point is tested to see whether it's in the circle or not:
5858
{% sample lang="r" %}
5959
[import:2-6, lang:"r"](code/r/monte_carlo.R)
6060
{% sample lang="java" %}
61-
[import:13-15, lang:"java"](code/java/MonteCarlo.java)
61+
[import:12-14, lang:"java"](code/java/MonteCarlo.java)
6262
{% sample lang="swift" %}
6363
[import:1-3, lang:"swift"](code/swift/monte_carlo.swift)
6464
{% sample lang="py" %}

contents/verlet_integration/code/java/Verlet.java

+3-17
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
// Submitted by lolatomroflsinnlos
2-
public class VerletValues {
3-
public double time;
4-
public double vel;
5-
6-
public VerletValues(double time, double vel) {
7-
this.time = time;
8-
this.vel = vel;
9-
}
10-
}
11-
121
public class Verlet {
132
static double verlet(double pos, double acc, double dt) {
143

@@ -44,8 +33,7 @@ static VerletValues stormer_verlet(double pos, double acc, double dt) {
4433
vel += acc*dt;
4534
}
4635

47-
VerletValues stormerVerlet = new VerletValues(time, vel);
48-
return stormerVerlet;
36+
return new VerletValues(time, vel);
4937
}
5038

5139
static VerletValues velocity_verlet(double pos, double acc, double dt) {
@@ -58,10 +46,8 @@ static VerletValues velocity_verlet(double pos, double acc, double dt) {
5846
time += dt;
5947
pos += vel*dt + 0.5*acc * dt * dt;
6048
vel += acc*dt;
61-
}
62-
63-
VerletValues velocityVerlet = new VerletValues(time, vel);
64-
return velocityVerlet;
49+
}
50+
return new VerletValues(time, vel);
6551
}
6652

6753
public static void main(String[] args) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class VerletValues {
2+
public double time;
3+
public double vel;
4+
5+
public VerletValues(double time, double vel) {
6+
this.time = time;
7+
this.vel = vel;
8+
}
9+
}

contents/verlet_integration/verlet_integration.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Here is what it looks like in code:
3737
{% sample lang="c" %}
3838
[import:3-14, lang:"c"](code/c/verlet.c)
3939
{% sample lang="java" %}
40-
[import:13-28, lang:"java"](code/java/Verlet.java)
40+
[import:2-17, lang:"java"](code/java/Verlet.java)
4141
{% sample lang="py" %}
4242
[import:1-10, lang:"python"](code/python/verlet.py)
4343
{% sample lang="hs" %}
@@ -91,7 +91,7 @@ However, the error for this is $$\mathcal{O}(\Delta t)$$, which is quite poor, b
9191
{% sample lang="c" %}
9292
[import:16-31, lang:"c"](code/c/verlet.c)
9393
{% sample lang="java" %}
94-
[import:30-49, lang:"java"](code/java/Verlet.java)
94+
[import:19-37, lang:"java"](code/java/Verlet.java)
9595
{% sample lang="py" %}
9696
[import:12-23, lang:"python"](code/python/verlet.py)
9797
{% sample lang="hs" %}
@@ -159,7 +159,7 @@ Here is the velocity Verlet method in code:
159159
{% sample lang="c" %}
160160
[import:33-43, lang:"c"](code/c/verlet.c)
161161
{% sample lang="java" %}
162-
[import:51-65, lang:"java"](code/java/Verlet.java)
162+
[import:39-51, lang:"java"](code/java/Verlet.java)
163163
{% sample lang="py" %}
164164
[import:25-34, lang:"python"](code/python/verlet.py)
165165
{% sample lang="hs" %}
@@ -213,6 +213,7 @@ Both of these methods work simply by iterating timestep-by-timestep and can be w
213213
{% sample lang="c" %}
214214
[import, lang:"c"](code/c/verlet.c)
215215
{% sample lang="java" %}
216+
[import, lang:"java"](code/java/VerletValues.java)
216217
[import, lang:"java"](code/java/Verlet.java)
217218
{% sample lang="py" %}
218219
[import, lang:"python"](code/python/verlet.py)

0 commit comments

Comments
 (0)