build a simple spam filter prototype
[IRC.git] / Robust / src / Benchmarks / Prefetch / MicroBenchmarks / Cell.java
1 /*************************************************************************
2 *  Compilation:  javac Cell.java
3 *  Execution:    java Cell
4 *  
5 *
6 *************************************************************************/
7
8 public class Cell {
9   private boolean spin;   // up (true) or down (false)
10
11   public Cell(boolean spin) { 
12     this.spin = spin;
13   }
14
15   // random spin - up with probability p
16   public Cell(double p) { 
17     spin = (Math.random() < p);
18   }
19
20   // flip the spin
21   public void flip() { spin = !spin; }
22
23   // +1 if up, -1 if down
24   public double magnetization() {
25     if (spin) return +1.0;
26     else      return -1.0;
27   }
28
29   // draw cell according to value of spin
30   public void draw(double x, double y) {
31     /*
32     if (spin) StdDraw.setPenColor(StdDraw.WHITE);
33     else      StdDraw.setPenColor(StdDraw.BLUE);
34     StdDraw.filledSquare(x, y, 1);
35     */
36   }
37
38   // string representation
39   public String toString() {
40     if (spin) return "+";
41     else      return "-";
42   }
43
44
45
46   public static void main(String[] args) {
47   }
48