Skip to content

Java filename changes for Verlet / bogosort / bubblesort #577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 23, 2019
Merged
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
4 changes: 2 additions & 2 deletions contents/bogo_sort/bogo_sort.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" %}
Expand Down Expand Up @@ -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" %}
Expand Down
4 changes: 2 additions & 2 deletions contents/bubble_sort/bubble_sort.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" %}
Expand Down Expand Up @@ -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" %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
8 changes: 3 additions & 5 deletions contents/monte_carlo_integration/code/java/MonteCarlo.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//submitted by DominikRafacz
import java.util.Random;

public class MonteCarlo {
Expand All @@ -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;

Expand All @@ -28,7 +27,6 @@ public static double monteCarlo(int samples) {
}
}

double estimation = 4.0 * piCount / samples;
return estimation;
return 4.0 * piCount / samples;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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" %}
Expand Down
20 changes: 3 additions & 17 deletions contents/verlet_integration/code/java/Verlet.java
Original file line number Diff line number Diff line change
@@ -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) {

Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions contents/verlet_integration/code/java/VerletValues.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
7 changes: 4 additions & 3 deletions contents/verlet_integration/verlet_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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" %}
Expand Down Expand Up @@ -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" %}
Expand Down Expand Up @@ -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" %}
Expand Down Expand Up @@ -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)
Expand Down