001package algs15.perc;
002
003//import stdlib.*;
004//import algs15.*;
005
006// Uncomment the import statements above.
007
008// You can test this using InteractivePercolationVisualizer and PercolationVisualizer
009// All methods should make at most a constant number of calls to a UF data structure.
010// You can use more than one UF data structure.
011// You can assume that N>1
012//
013// Note that you can print out a UF structure using its toString method.
014// You can also use the toGraphviz method to draw the UF.
015// These may be useful for debugging.
016// Try calling them whenever you open a new square.
017public class Percolation {
018        int N;
019        boolean[] open;
020        // TODO: more fields to add here
021        public Percolation(int N) {
022                if (N < 2) throw new IllegalArgumentException();
023                this.N = N;
024                this.open = new boolean[N*N];
025                // TODO: more to do here
026        }
027        // open site (row i, column j) if it is not already
028        public void open(int i, int j) {
029                int x = i*N+j;
030                if (!open[x]) {
031                        open[x] = true;
032                        // TODO: more to do here.
033                }
034        }
035        // is site (row i, column j) open?
036        public boolean isOpen(int i, int j) {
037                return open[i*N+j];
038        }
039        // is site (row i, column j) full?
040        public boolean isFull(int i, int j) {
041                // TODO
042                return false;
043        }
044        // does the system percolate?
045        public boolean percolates() {
046                // TODO
047                return false;
048        }
049}