// Path: COSC111/src/edu/java/cosc111/samples/concurrency/Counter.java
// public interface Counter {
//     public int increment();    
//     public int getCount();    
//     public boolean isMaxed();
// }


import edu.java.cosc111.samples.concurrency.Counter;
import java.util.concurrent.ThreadLocalRandom;

    }
    //Pre-condition: nCurCount <= MAX_COUNT
    //Post-condition: nCurCount <= MAX_COUNT, nCurCount has increased by 1
    @Override
    public int increment(){
        if(!isMaxed()){
            delay();
            nCurCount = nCurCount + 1;
            
        }   
        
        assert(nCurCount<=MAX_COUNT);
        
        return nCurCount;
    }
    
    @Override
    public int getCount(){
        return nCurCount;
    }
    
    @Override
    public boolean isMaxed(){
        return nCurCount == MAX_COUNT;
    }
    
    private void delay(){
        ThreadLocalRandom r = ThreadLocalRandom.current();
        try {
            //Simulate long computation

// Path: COSC111/src/edu/java/cosc111/samples/concurrency/Counter.java
// public interface Counter {
//     public int increment();    
//     public int getCount();    
//     public boolean isMaxed();
// }


// Path: COSC111/src/edu/java/cosc111/samples/concurrency/unsync/UnsyncCounter.java
import edu.java.cosc111.samples.concurrency.Counter;
import java.util.concurrent.ThreadLocalRandom;

    }
    //Pre-condition: nCurCount <= MAX_COUNT
    //Post-condition: nCurCount <= MAX_COUNT, nCurCount has increased by 1
    @Override
    public int increment(){
        if(!isMaxed()){
            delay();
            nCurCount = nCurCount + 1;
            
        }   
        
        assert(nCurCount<=MAX_COUNT);
        
        return nCurCount;
    }
    
    @Override
    public int getCount(){
        return nCurCount;
    }
    
    @Override
    public boolean isMaxed(){
        return nCurCount == MAX_COUNT;
    }
    
    private void delay(){
        ThreadLocalRandom r = ThreadLocalRandom.current();
        try {
            //Simulate long computation

            Thread.sleep(r.nextLong(1000L, 1500L));
