Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 882f810

Browse files
committedAug 24, 2017
Chapter 03 codes updated.
1 parent d377d7c commit 882f810

File tree

7 files changed

+7
-8
lines changed

7 files changed

+7
-8
lines changed
 

‎03-Probability-Simulation/02-More-about-the-Money-Experiment/src/AlgoFrame.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public AlgoFrame(String title){
4040
public int getCanvasHeight(){return canvasHeight;}
4141

4242
// data
43-
int[] money;
43+
private int[] money;
4444
public void render(int[] money){
4545
this.money = money;
4646
repaint();

‎03-Probability-Simulation/03-Get-PI-with-Monte-Carlo/src/AlgoFrame.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ public AlgoFrame(String title){
3333
public int getCanvasHeight(){return canvasHeight;}
3434

3535
// data
36-
Circle circle;
37-
LinkedList<Point> points;
36+
private Circle circle;
37+
private LinkedList<Point> points;
3838
public void render(Circle circle, LinkedList<Point> points){
3939
this.circle = circle;
4040
this.points = points;

‎03-Probability-Simulation/03-Get-PI-with-Monte-Carlo/src/Circle.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import java.awt.*;
2-
import javax.swing.*;
32

43
public class Circle {
54

@@ -16,6 +15,6 @@ public Circle(int x, int y, int r){
1615
public int getR(){ return r; }
1716

1817
public boolean contain(Point p){
19-
return Math.pow(p.getX() - x, 2) + Math.pow(p.getY() - y, 2) <= r*r;
18+
return Math.pow(p.x - x, 2) + Math.pow(p.y - y, 2) <= r*r;
2019
}
2120
}

‎03-Probability-Simulation/04-Create-Data-Model/src/AlgoFrame.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public AlgoFrame(String title){
3333
public int getCanvasHeight(){return canvasHeight;}
3434

3535
// data
36-
MonteCarloPiData data;
36+
private MonteCarloPiData data;
3737
public void render(MonteCarloPiData data){
3838
this.data = data;
3939
repaint();

‎03-Probability-Simulation/04-Create-Data-Model/src/Circle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ public Circle(int x, int y, int r){
1616
public int getR(){ return r; }
1717

1818
public boolean contain(Point p){
19-
return Math.pow(p.getX() - x, 2) + Math.pow(p.getY() - y, 2) <= r*r;
19+
return Math.pow(p.x - x, 2) + Math.pow(p.y - y, 2) <= r*r;
2020
}
2121
}

‎03-Probability-Simulation/05-Pi-Estimation-Without-Rendering/src/Circle.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ public Circle(int x, int y, int r){
1616
public int getR(){ return r; }
1717

1818
public boolean contain(Point p){
19-
return Math.pow(p.getX() - x, 2) + Math.pow(p.getY() - y, 2) <= r*r;
19+
return Math.pow(p.x - x, 2) + Math.pow(p.y - y, 2) <= r*r;
2020
}
2121
}
298 KB
Binary file not shown.

0 commit comments

Comments
 (0)
Please sign in to comment.