Princeton-普林斯顿-算法-第一题-Percolation

被打击了,自以为傲的跑通了算法题,传上去居然才拿到12分,需要慢慢修改了,良好的代码习惯还是很难养成的。
here is the code:


import java.util.Random;
import java.lang.*;

import edu.princeton.cs.algs4.StdStats;
import edu.princeton.cs.algs4.Stopwatch;

public class PercolationStats {
    private int count_in;
//  private int count_out;
    private int n;
    private int trials;
    private double[] array;

    private Random random  = new Random();
//  private Percolation a = new Percolation(n);

    public PercolationStats(int n, int trials)    // perform trials independent experiments on an n-by-n grid
    {  
        array = new double[trials];
        this.n = n;
        this.trials = trials;
        for(int i=0;i<trials;i++)
        {
            Percolation a = new Percolation(n);
            count_in = 0;
            while(true)
            {
                int row= random.nextInt(n);
                int col = random.nextInt(n);
                if(a.isOpen(row, col))          
                {
                    continue;
                }
                a.open(row, col);
                count_in++; 

                if(a.percolates())
                {
                    break;
                }
            }
            array[i] = (double)count_in/(n*n);

        }
    }

        public double mean()                          // sample mean of percolation threshold
        {
            return StdStats.mean(array);
        }

        public double stddev()                        // sample standard deviation of percolation threshold
        {
            return StdStats.stddev(array);
        }

        public double confidenceLo()                  // low  endpoint of 95% confidence interval
        {
            return this.mean()-1.96*this.stddev()/Math.sqrt(this.trials);
        }
        public double confidenceHi()                  // high endpoint of 95% confidence interval
        {
            return this.mean()+1.96*this.stddev()/Math.sqrt(this.trials);
        }

        public static void main(String[] args)    // test client (described below)
        {
            Stopwatch timer = new Stopwatch();

            PercolationStats test = new PercolationStats(200,100);  //n,T

            double time = timer.elapsedTime();
            System.out.println("elapsedTime:"+time);
            System.out.println("mean                            =   "+test.mean());
            System.out.println("stddev                          =   "+test.stddev());
            System.out.println("95% confidence interval =   "+test.confidenceLo()+", "+test.confidenceHi());
        }

}
See the Assessment Guide for information on how to interpret this report.

Assessment Summary

Compilation:  PASSED
Checkstyle:   FAILED (109 warnings)
Findbugs:     FAILED (1 warning)
API:          PASSED

Correctness:  0/26 tests passed
Memory:       0/8 tests passed
Timing:       4/9 tests passed

Aggregate score: 11.11% [Correctness: 65%, Memory: 10%, Timing: 25%, Style: 0%]

Assessment Details

The following files were submitted:
----------------------------------
total 12K
-rw-r--r-- 1 3.4K Dec 16 15:50 Percolation.java
-rw-r--r-- 1 2.0K Dec 16 15:50 PercolationStats.java
-rw-r--r-- 1 2.5K Dec 16 15:50 studentSubmission.zip


********************************************************************************
*  COMPILING                                                                   *
********************************************************************************


% javac Percolation.java
*-----------------------------------------------------------

% javac PercolationStats.java
*-----------------------------------------------------------


================================================================


% checkstyle *.java
*-----------------------------------------------------------
Percolation.java:1:8: Unused import statement for 'edu.princeton.cs.algs4.StdRandom'. [UnusedImports]
Percolation.java:2:8: Unused import statement for 'edu.princeton.cs.algs4.StdStats'. [UnusedImports]
Percolation.java:5: Do not use .* in import statements. [AvoidStarImport]
Percolation.java:10:1: File contains tab characters (this is the first instance). Configure your editor to replace tabs with spaces. [FileTabCharacter]
Percolation.java:11:17: The instance variable 'N' must start with a lowercase letter and use camelCase. [MemberName]
Percolation.java:12:21: ',' is not followed by whitespace. [WhitespaceAfter]
Percolation.java:21:22: '(' is preceded with whitespace. [MethodParamPad]
Percolation.java:21:27: The local (or parameter) variable 'row' has the same name as an instance variable. Use a different name. [HiddenField]
Percolation.java:21:36: The local (or parameter) variable 'col' has the same name as an instance variable. Use a different name. [HiddenField]
Percolation.java:32:11: 'if' is not followed by whitespace. [WhitespaceAround]
Percolation.java:32:13: '<' is not preceded with whitespace. [WhitespaceAround]
Percolation.java:32:14: '<' is not followed by whitespace. [WhitespaceAround]
Percolation.java:33:19: 'if' is not followed by whitespace. [WhitespaceAround]
Percolation.java:33:21: '>' is not preceded with whitespace. [WhitespaceAround]
Percolation.java:33:22: '>' is not followed by whitespace. [WhitespaceAround]
Percolation.java:36:31: The local (or parameter) variable 'row' has the same name as an instance variable. Use a different name. [HiddenField]
Percolation.java:36:40: The local (or parameter) variable 'col' has the same name as an instance variable. Use a different name. [HiddenField]
Percolation.java:38:9: Conditional logic can be removed. [SimplifyBooleanReturn]
Percolation.java:38:11: 'if' is not followed by whitespace. [WhitespaceAround]
Percolation.java:44:31: The local (or parameter) variable 'row' has the same name as an instance variable. Use a different name. [HiddenField]
Percolation.java:44:40: The local (or parameter) variable 'col' has the same name as an instance variable. Use a different name. [HiddenField]
Percolation.java:46:9: Conditional logic can be removed. [SimplifyBooleanReturn]
Percolation.java:46:11: 'if' is not followed by whitespace. [WhitespaceAround]
Percolation.java:55:12: 'for' is not followed by whitespace. [WhitespaceAround]
Percolation.java:55:18: '=' is not preceded with whitespace. [WhitespaceAround]
Percolation.java:55:19: '=' is not followed by whitespace. [WhitespaceAround]
Percolation.java:55:21: ';' is not followed by whitespace. [WhitespaceAfter]
Percolation.java:55:22: '<' is not preceded with whitespace. [WhitespaceAround]
Percolation.java:55:23: '<' is not followed by whitespace. [WhitespaceAround]
Percolation.java:55:25: ';' is not followed by whitespace. [WhitespaceAfter]
Percolation.java:57:16: 'for' is not followed by whitespace. [WhitespaceAround]
Percolation.java:57:22: '=' is not preceded with whitespace. [WhitespaceAround]
Percolation.java:57:23: '=' is not followed by whitespace. [WhitespaceAround]
Percolation.java:57:25: ';' is not followed by whitespace. [WhitespaceAfter]
Percolation.java:57:26: '<' is not preceded with whitespace. [WhitespaceAround]
Percolation.java:57:27: '<' is not followed by whitespace. [WhitespaceAround]
Percolation.java:57:29: ';' is not followed by whitespace. [WhitespaceAfter]
Percolation.java:65:12: 'for' is not followed by whitespace. [WhitespaceAround]
Percolation.java:65:18: '=' is not preceded with whitespace. [WhitespaceAround]
Percolation.java:65:19: '=' is not followed by whitespace. [WhitespaceAround]
Percolation.java:65:21: ';' is not followed by whitespace. [WhitespaceAfter]
Percolation.java:65:22: '<' is not preceded with whitespace. [WhitespaceAround]
Percolation.java:65:23: '<' is not followed by whitespace. [WhitespaceAround]
Percolation.java:65:25: ';' is not followed by whitespace. [WhitespaceAfter]
Percolation.java:67:16: 'for' is not followed by whitespace. [WhitespaceAround]
Percolation.java:67:22: '=' is not preceded with whitespace. [WhitespaceAround]
Percolation.java:67:23: '=' is not followed by whitespace. [WhitespaceAround]
Percolation.java:67:25: ';' is not followed by whitespace. [WhitespaceAfter]
Percolation.java:67:26: '<' is not preceded with whitespace. [WhitespaceAround]
Percolation.java:67:27: '<' is not followed by whitespace. [WhitespaceAround]
Percolation.java:67:29: ';' is not followed by whitespace. [WhitespaceAfter]
Percolation.java:79:39: ',' is not followed by whitespace. [WhitespaceAfter]
Percolation.java:80:39: ',' is not followed by whitespace. [WhitespaceAfter]
Percolation.java:81:30: ',' is not followed by whitespace. [WhitespaceAfter]
Percolation.java:82:30: ',' is not followed by whitespace. [WhitespaceAfter]
Percolation.java:84:19: '=' is not preceded with whitespace. [WhitespaceAround]
Percolation.java:84:20: '=' is not followed by whitespace. [WhitespaceAround]
Percolation.java:84:22: ';' is not followed by whitespace. [WhitespaceAfter]
Percolation.java:84:23: '<' is not preceded with whitespace. [WhitespaceAround]
Percolation.java:84:24: '<' is not followed by whitespace. [WhitespaceAround]
Percolation.java:84:26: ';' is not followed by whitespace. [WhitespaceAfter]
Percolation.java:87:16: 'for' is not followed by whitespace. [WhitespaceAround]
Percolation.java:87:22: '=' is not preceded with whitespace. [WhitespaceAround]
Percolation.java:87:23: '=' is not followed by whitespace. [WhitespaceAround]
Percolation.java:87:25: ';' is not followed by whitespace. [WhitespaceAfter]
Percolation.java:87:26: '<' is not preceded with whitespace. [WhitespaceAround]
Percolation.java:87:27: '<' is not followed by whitespace. [WhitespaceAround]
Percolation.java:87:29: ';' is not followed by whitespace. [WhitespaceAfter]
Percolation.java:89:19: 'if' is not followed by whitespace. [WhitespaceAround]
Percolation.java:104:13: The local variable 'count_in' must start with a lowercase letter and use camelCase. [LocalVariableName]
Percolation.java:105:13: The local variable 'count_out' must start with a lowercase letter and use camelCase. [LocalVariableName]
Percolation.java:109:12: 'for' is not followed by whitespace. [WhitespaceAround]
Percolation.java:109:14: '=' is not preceded with whitespace. [WhitespaceAround]
Percolation.java:109:15: '=' is not followed by whitespace. [WhitespaceAround]
Percolation.java:109:18: ';' is not followed by whitespace. [WhitespaceAfter]
Percolation.java:109:25: '+=' is not preceded with whitespace. [WhitespaceAround]
Percolation.java:109:27: '+=' is not followed by whitespace. [WhitespaceAround]
Percolation.java:109:29: '{' is not preceded with whitespace. [WhitespaceAround]
Percolation.java:111:16: 'for' is not followed by whitespace. [WhitespaceAround]
Percolation.java:111:22: '=' is not preceded with whitespace. [WhitespaceAround]
Percolation.java:111:23: '=' is not followed by whitespace. [WhitespaceAround]
Percolation.java:111:25: ';' is not followed by whitespace. [WhitespaceAfter]
Percolation.java:111:26: '<' is not preceded with whitespace. [WhitespaceAround]
Percolation.java:111:27: '<' is not followed by whitespace. [WhitespaceAround]
Percolation.java:111:34: ';' is not followed by whitespace. [WhitespaceAfter]
Percolation.java:114:22: 'while' is not followed by whitespace. [WhitespaceAround]
Percolation.java:117:28: '=' is not preceded with whitespace. [WhitespaceAround]
Percolation.java:119:23: 'if' is not followed by whitespace. [WhitespaceAround]
Percolation.java:126:23: 'if' is not followed by whitespace. [WhitespaceAround]
Percolation.java:133:29: '+=' is not followed by whitespace. [WhitespaceAround]
Percolation.java:141:39: Typecast is not followed by whitespace. [WhitespaceAfter]
PercolationStats.java:2: Do not use .* in import statements. [AvoidStarImport]
PercolationStats.java:2:1: Unnecessary import statement for 'java.lang.*' because it is from the package 'java.lang'. [RedundantImport]
PercolationStats.java:8:1: File contains tab characters (this is the first instance). Configure your editor to replace tabs with spaces. [FileTabCharacter]
PercolationStats.java:8:17: The instance variable 'count_in' must start with a lowercase letter and use camelCase. [MemberName]
PercolationStats.java:22:12: 'for' is not followed by whitespace. [WhitespaceAround]
PercolationStats.java:22:18: '=' is not preceded with whitespace. [WhitespaceAround]
PercolationStats.java:22:19: '=' is not followed by whitespace. [WhitespaceAround]
PercolationStats.java:22:21: ';' is not followed by whitespace. [WhitespaceAfter]
PercolationStats.java:22:22: '<' is not preceded with whitespace. [WhitespaceAround]
PercolationStats.java:22:23: '<' is not followed by whitespace. [WhitespaceAround]
PercolationStats.java:22:30: ';' is not followed by whitespace. [WhitespaceAfter]
PercolationStats.java:26:18: 'while' is not followed by whitespace. [WhitespaceAround]
PercolationStats.java:28:24: '=' is not preceded with whitespace. [WhitespaceAround]
PercolationStats.java:30:19: 'if' is not followed by whitespace. [WhitespaceAround]
PercolationStats.java:37:19: 'if' is not followed by whitespace. [WhitespaceAround]
PercolationStats.java:42:32: Typecast is not followed by whitespace. [WhitespaceAfter]
PercolationStats.java:70:62: ',' is not followed by whitespace. [WhitespaceAfter]
PercolationStats.java:70:71: '//' or '/*' is not followed by whitespace. [IllegalTokenText]
Checkstyle ends with 109 errors.

================================================================


% findbugs *.class
*-----------------------------------------------------------
M P URF_UNREAD_FIELD UrF: The instance (or static) variable 'n' is never read. Consider removing it from the class.  At PercolationStats.java:[line 20]
Warnings generated: 1

================================================================


Testing the APIs of your programs.
*-----------------------------------------------------------
Percolation:

PercolationStats:

================================================================


******************************************************************************
*  TESTING CORRECTNESS
******************************************************************************

Testing methods in Percolation
*-----------------------------------------------------------
Running 15 total tests.

Tests 1 through 8 create a Percolation object using your code, then repeatedly
open sites by calling open(). After each call to open(), we check the return
values of isOpen(i, j) for every (i, j), the return value of percolates(),
and the return value of isFull(i, j) for every (i, j), in that order.

Except as noted, a site is opened at most once.

Test 1: Open predetermined list of sites using file inputs
  *  filename = input6.txt
     java.lang.ArrayIndexOutOfBoundsException: 36

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.check(TestPercolation.java:82)
     TestPercolation.file(TestPercolation.java:102)
     TestPercolation.test1(TestPercolation.java:166)
     TestPercolation.main(TestPercolation.java:684)

     - failed before any calls to isOpen()
  *  filename = input8.txt
     java.lang.ArrayIndexOutOfBoundsException: 64

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.check(TestPercolation.java:82)
     TestPercolation.file(TestPercolation.java:102)
     TestPercolation.test1(TestPercolation.java:167)
     TestPercolation.main(TestPercolation.java:684)

     - failed before any calls to isOpen()
  *  filename = input8-no.txt
     java.lang.ArrayIndexOutOfBoundsException: 64

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.check(TestPercolation.java:82)
     TestPercolation.file(TestPercolation.java:102)
     TestPercolation.test1(TestPercolation.java:168)
     TestPercolation.main(TestPercolation.java:684)

     - failed before any calls to isOpen()
  *  filename = input10-no.txt
     java.lang.ArrayIndexOutOfBoundsException: 100

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.check(TestPercolation.java:82)
     TestPercolation.file(TestPercolation.java:102)
     TestPercolation.test1(TestPercolation.java:169)
     TestPercolation.main(TestPercolation.java:684)

     - failed before any calls to isOpen()
  *  filename = greeting57.txt
     java.lang.ArrayIndexOutOfBoundsException: 3249

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.check(TestPercolation.java:82)
     TestPercolation.file(TestPercolation.java:102)
     TestPercolation.test1(TestPercolation.java:170)
     TestPercolation.main(TestPercolation.java:684)

     - failed before any calls to isOpen()
  *  filename = heart25.txt
     java.lang.ArrayIndexOutOfBoundsException: 625

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.check(TestPercolation.java:82)
     TestPercolation.file(TestPercolation.java:102)
     TestPercolation.test1(TestPercolation.java:171)
     TestPercolation.main(TestPercolation.java:684)

     - failed before any calls to isOpen()
==> FAILED

Test 2: Open random sites until just before system percolates
  *  n = 3
     java.lang.ArrayIndexOutOfBoundsException: 9

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.check(TestPercolation.java:82)
     TestPercolation.random(TestPercolation.java:184)
     TestPercolation.test2(TestPercolation.java:210)
     TestPercolation.main(TestPercolation.java:686)

     - failed after call 0 to isOpen()
  *  n = 5
     java.lang.ArrayIndexOutOfBoundsException: 25

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.check(TestPercolation.java:82)
     TestPercolation.random(TestPercolation.java:184)
     TestPercolation.test2(TestPercolation.java:211)
     TestPercolation.main(TestPercolation.java:686)

     - failed after call 0 to isOpen()
  *  n = 10
     java.lang.ArrayIndexOutOfBoundsException: 100

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.check(TestPercolation.java:82)
     TestPercolation.random(TestPercolation.java:184)
     TestPercolation.test2(TestPercolation.java:212)
     TestPercolation.main(TestPercolation.java:686)

     - failed after call 0 to isOpen()
  *  n = 10
     java.lang.ArrayIndexOutOfBoundsException: 100

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.check(TestPercolation.java:82)
     TestPercolation.random(TestPercolation.java:184)
     TestPercolation.test2(TestPercolation.java:213)
     TestPercolation.main(TestPercolation.java:686)

     - failed after call 0 to isOpen()
  *  n = 20
     java.lang.ArrayIndexOutOfBoundsException: 400

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.check(TestPercolation.java:82)
     TestPercolation.random(TestPercolation.java:184)
     TestPercolation.test2(TestPercolation.java:214)
     TestPercolation.main(TestPercolation.java:686)

     - failed after call 0 to isOpen()
  *  n = 20
     java.lang.ArrayIndexOutOfBoundsException: 400

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.check(TestPercolation.java:82)
     TestPercolation.random(TestPercolation.java:184)
     TestPercolation.test2(TestPercolation.java:215)
     TestPercolation.main(TestPercolation.java:686)

     - failed after call 0 to isOpen()
  *  n = 50
     java.lang.ArrayIndexOutOfBoundsException: 2500

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.check(TestPercolation.java:82)
     TestPercolation.random(TestPercolation.java:184)
     TestPercolation.test2(TestPercolation.java:216)
     TestPercolation.main(TestPercolation.java:686)

     - failed after call 0 to isOpen()
  *  n = 50
     java.lang.ArrayIndexOutOfBoundsException


     - failed after call 0 to isOpen()
==> FAILED

Test 3: Opens predetermined sites for n = 1 and n = 2 (corner case test)
  *  filename = input1.txt
     java.lang.ArrayIndexOutOfBoundsException


     - failed before any calls to isOpen()
  *  filename = input1-no.txt
     java.lang.ArrayIndexOutOfBoundsException


     - failed before any calls to isOpen()
  *  filename = input2.txt
     java.lang.ArrayIndexOutOfBoundsException


     - failed before any calls to isOpen()
  *  filename = input2-no.txt
     java.lang.ArrayIndexOutOfBoundsException


     - failed before any calls to isOpen()
==> FAILED

Test 4: Check for backwash with predetermined sites
  *  filename = input20.txt
     java.lang.ArrayIndexOutOfBoundsException


     - failed before any calls to isOpen()
  *  filename = input10.txt
     java.lang.ArrayIndexOutOfBoundsException


     - failed before any calls to isOpen()
  *  filename = input50.txt
     java.lang.ArrayIndexOutOfBoundsException


     - failed before any calls to isOpen()
  *  filename = jerry47.txt
     java.lang.ArrayIndexOutOfBoundsException


     - failed before any calls to isOpen()
==> FAILED

Test 5: Check for backwash with predetermined sites that have
        multiple percolating paths
  *  filename = input3.txt
     java.lang.ArrayIndexOutOfBoundsException


     - failed before any calls to isOpen()
  *  filename = input4.txt
     java.lang.ArrayIndexOutOfBoundsException


     - failed before any calls to isOpen()
  *  filename = input7.txt
     java.lang.ArrayIndexOutOfBoundsException


     - failed before any calls to isOpen()
==> FAILED

Test 6: Predetermined sites with long percolating path
  *  filename = snake13.txt
     java.lang.ArrayIndexOutOfBoundsException


     - failed before any calls to isOpen()
  *  filename = snake101.txt
     java.lang.ArrayIndexOutOfBoundsException


     - failed before any calls to isOpen()
==> FAILED

Test 7: Opens every site
  *  filename = input5.txt
     java.lang.ArrayIndexOutOfBoundsException


     - failed before any calls to isOpen()
==> FAILED

Test 8: Open random sites until just before system percolates,
        allowing open() to be called on a site more than once
  *  n = 3
     java.lang.ArrayIndexOutOfBoundsException


     - failed after call 0 to isOpen()
  *  n = 5
     java.lang.ArrayIndexOutOfBoundsException


     - failed after call 0 to isOpen()
  *  n = 10
     java.lang.ArrayIndexOutOfBoundsException


     - failed after call 0 to isOpen()
  *  n = 10
     java.lang.ArrayIndexOutOfBoundsException


     - failed after call 0 to isOpen()
  *  n = 20
     java.lang.ArrayIndexOutOfBoundsException


     - failed after call 0 to isOpen()
  *  n = 20
     java.lang.ArrayIndexOutOfBoundsException


     - failed after call 0 to isOpen()
  *  n = 50
     java.lang.ArrayIndexOutOfBoundsException


     - failed after call 0 to isOpen()
  *  n = 50
     java.lang.ArrayIndexOutOfBoundsException


     - failed after call 0 to isOpen()
==> FAILED

Test 9: Check that IndexOutOfBoundsException is thrown if (i, j) is out of bounds
  *  n = 10, (i, j) = (0, 6)
     - java.lang.IndexOutOfBoundsException not thrown for open()
     - java.lang.IndexOutOfBoundsException not thrown for isOpen()
     - java.lang.IndexOutOfBoundsException not thrown for isFull()
  *  n = 10, (i, j) = (12, 6)
  *  n = 10, (i, j) = (11, 6)
  *  n = 10, (i, j) = (6, 0)
     - java.lang.IndexOutOfBoundsException not thrown for open()
     - java.lang.IndexOutOfBoundsException not thrown for isOpen()
     - java.lang.IndexOutOfBoundsException not thrown for isFull()
  *  n = 10, (i, j) = (6, 12)
     - java.lang.IndexOutOfBoundsException not thrown for open()
     - java.lang.IndexOutOfBoundsException not thrown for isOpen()
     - java.lang.IndexOutOfBoundsException not thrown for isFull()
  *  n = 10, (i, j) = (6, 11)
     - java.lang.IndexOutOfBoundsException not thrown for open()
     - java.lang.IndexOutOfBoundsException not thrown for isOpen()
     - java.lang.IndexOutOfBoundsException not thrown for isFull()
==> FAILED

Test 10: Check that IllegalArgumentException is thrown if N <= 0 in constructor
  *  n = -10
     - java.lang.IllegalArgumentException not thrown
  *  n = -1
     - java.lang.IllegalArgumentException not thrown
  *  n = 0
     - java.lang.IllegalArgumentException not thrown
==> FAILED

Test 11: Create multiple Percolation objects at the same time
         (to make sure you didn't store data in static variables)
     java.lang.ArrayIndexOutOfBoundsException: 100

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.check(TestPercolation.java:82)
     TestPercolation.twoPercolations(TestPercolation.java:407)
     TestPercolation.test11(TestPercolation.java:436)
     TestPercolation.main(TestPercolation.java:704)

     java.lang.ArrayIndexOutOfBoundsException: 100

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.check(TestPercolation.java:82)
     TestPercolation.twoPercolations(TestPercolation.java:407)
     TestPercolation.test11(TestPercolation.java:437)
     TestPercolation.main(TestPercolation.java:704)

     java.lang.ArrayIndexOutOfBoundsException: 400

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.check(TestPercolation.java:82)
     TestPercolation.twoPercolations(TestPercolation.java:407)
     TestPercolation.test11(TestPercolation.java:438)
     TestPercolation.main(TestPercolation.java:704)

==> FAILED

Test 12: Open predetermined list of sites using file inputs,
         but change the order in which methods are called
  *  filename = input8.txt;  order =     isFull(),     isOpen(), percolates()
     isFull(1, 1) returns wrong value [after 1 site opened]
     - student   = true
     - reference = false
  *  filename = input8.txt;  order =     isFull(), percolates(),     isOpen()
     isFull(1, 1) returns wrong value [after 1 site opened]
     - student   = true
     - reference = false
  *  filename = input8.txt;  order =     isOpen(),     isFull(), percolates()
     java.lang.ArrayIndexOutOfBoundsException: 64

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.file(TestPercolation.java:148)
     TestPercolation.test12(TestPercolation.java:450)
     TestPercolation.main(TestPercolation.java:706)

  *  filename = input8.txt;  order =     isOpen(), percolates(),     isFull()
     java.lang.ArrayIndexOutOfBoundsException: 64

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.file(TestPercolation.java:149)
     TestPercolation.test12(TestPercolation.java:451)
     TestPercolation.main(TestPercolation.java:706)

  *  filename = input8.txt;  order = percolates(),     isOpen(),     isFull()
     java.lang.ArrayIndexOutOfBoundsException: 64

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.file(TestPercolation.java:150)
     TestPercolation.test12(TestPercolation.java:452)
     TestPercolation.main(TestPercolation.java:706)

  *  filename = input8.txt;  order = percolates(),     isFull(),     isOpen()
     isFull(1, 1) returns wrong value [after 1 site opened]
     - student   = true
     - reference = false
==> FAILED

Test 13: Call all methods in random order until just before system percolates
  *  n = 3
     java.lang.ArrayIndexOutOfBoundsException: 9

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.randomCallsUntilPercolation(TestPercolation.java:493)
     TestPercolation.test13(TestPercolation.java:541)
     TestPercolation.main(TestPercolation.java:708)

     - sequence of operations was:
         percolation.isOpen(i, j) for each i and j
  *  n = 5
     java.lang.ArrayIndexOutOfBoundsException: 25

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.randomCallsUntilPercolation(TestPercolation.java:493)
     TestPercolation.test13(TestPercolation.java:542)
     TestPercolation.main(TestPercolation.java:708)

     - sequence of operations was:
         percolation.isOpen(i, j) for each i and j
  *  n = 7
     java.lang.ArrayIndexOutOfBoundsException: 50

     Percolation.open(Percolation.java:25)
     TestPercolation.randomCallsUntilPercolation(TestPercolation.java:487)
     TestPercolation.test13(TestPercolation.java:543)
     TestPercolation.main(TestPercolation.java:708)

     - sequence of operations was:
         percolation.open(4, 1)
         percolation.percolates()
  *  n = 10
     java.lang.ArrayIndexOutOfBoundsException: 100

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.randomCallsUntilPercolation(TestPercolation.java:493)
     TestPercolation.test13(TestPercolation.java:544)
     TestPercolation.main(TestPercolation.java:708)

     - sequence of operations was:
         percolation.isOpen(i, j) for each i and j
  *  n = 20
     java.lang.ArrayIndexOutOfBoundsException: 400

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.randomCallsUntilPercolation(TestPercolation.java:493)
     TestPercolation.test13(TestPercolation.java:545)
     TestPercolation.main(TestPercolation.java:708)

     - sequence of operations was:
         percolation.isOpen(i, j) for each i and j
  *  n = 50
     java.lang.ArrayIndexOutOfBoundsException: 2500

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.randomCallsUntilPercolation(TestPercolation.java:493)
     TestPercolation.test13(TestPercolation.java:546)
     TestPercolation.main(TestPercolation.java:708)

     - sequence of operations was:
         percolation.open(46, 40)
         percolation.isOpen(i, j) for each i and j
==> FAILED

Test 14: Call all methods in random order until almost all sites are open,
         but with inputs not prone to backwash
  *  n = 3
     isFull(1, 1) returns wrong value [after 2 sites opened]
     - student   = true
     - reference = false
     - failed on trial 1 of 40
  *  n = 5
     isFull(1, 1) returns wrong value [after 0 sites opened]
     - student   = true
     - reference = false
     - failed on trial 1 of 20
  *  n = 7
     java.lang.ArrayIndexOutOfBoundsException: 49

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.randomCallsNoBackwash(TestPercolation.java:578)
     TestPercolation.test14(TestPercolation.java:602)
     TestPercolation.main(TestPercolation.java:710)

  *  n = 10
     java.lang.ArrayIndexOutOfBoundsException: 100

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.randomCallsNoBackwash(TestPercolation.java:578)
     TestPercolation.test14(TestPercolation.java:603)
     TestPercolation.main(TestPercolation.java:710)

  *  n = 20
     java.lang.ArrayIndexOutOfBoundsException: 400

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.randomCallsNoBackwash(TestPercolation.java:578)
     TestPercolation.test14(TestPercolation.java:604)
     TestPercolation.main(TestPercolation.java:710)

  *  n = 50
     isFull(1, 1) returns wrong value [after 1 site opened]
     - student   = true
     - reference = false
     - failed on trial 1 of 1
==> FAILED

Test 15: Call all methods in random order until all sites are open,
         allowing open() to be called on a site more than once
         (these inputs are prone to backwash)
  *  n = 3
     java.lang.ArrayIndexOutOfBoundsException: 9

     Percolation.isOpen(Percolation.java:38)
     TestPercolation.checkIsOpen(TestPercolation.java:46)
     TestPercolation.randomCalls(TestPercolation.java:632)
     TestPercolation.test15(TestPercolation.java:655)
     TestPercolation.main(Te

...

WARNING: the grading output was truncated due to excessive length.
Typically, this is because you have a method that has an unanticipated side effect
(such as printing to standard output or throwing an exception). A large amount of output
can also arise from failing many tests.
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值