src/Reader.java
/**
     * Returns a two-dimensional string array
     */
Returns a two-dimensional string array
Returns a two - dimensional string array
public String[][] highestscores() {
        if (this.names == null || this.scores == null) {
            return null;
        }
        Object[] temp = this.names.toArray();
        String[] a = new String[temp.length];
        for (int i = 0; i < a.length; i++) {
            a[i] = (String) temp[i];
        }
        Object[] temp1 = this.scores.toArray();
        Integer[] arr = new Integer[temp1.length];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = (Integer) temp1[i];
        }
        String[][] s = new String[names.size()][2];
        if (a.length == 0 || a == null || arr.length == 0 || arr == null || 
                a.length != arr.length) {
            return null;
        }
        for (int i = 0; i < arr.length; i++) {     
            for (int j = i + 1; j < arr.length; j++) {     
                if (arr[i] < arr[j]) {    
                    Integer tempo = arr[i];    
                    arr[i] = arr[j];    
                    arr[j] = tempo;
                    String tempi = a[i];
                    a[i] = a[j];
                    a[j] = tempi;
                }     
            }     
        }           
        for (int i = 0; i < names.size(); i++) {
            s[i][0] = a[i];
            s[i][1] = String.valueOf(arr[i]);
        }
        return s;
    }
public String [ ] [ ] highestscores ( ) { if ( this . names == null || this . scores == null ) { return null ; } Object [ ] temp = this . names . toArray ( ) ; String [ ] a = new String [ temp . length ] ; for ( int i = 0 ; i < a . length ; i ++ ) { a [ i ] = ( String ) temp [ i ] ; } Object [ ] temp1 = this . scores . toArray ( ) ; Integer [ ] arr = new Integer [ temp1 . length ] ; for ( int i = 0 ; i < arr . length ; i ++ ) { arr [ i ] = ( Integer ) temp1 [ i ] ; } String [ ] [ ] s = new String [ names . size ( ) ] [ 2 ] ; if ( a . length == 0 || a == null || arr . length == 0 || arr == null || a . length != arr . length ) { return null ; } for ( int i = 0 ; i < arr . length ; i ++ ) { for ( int j = i + 1 ; j < arr . length ; j ++ ) { if ( arr [ i ] < arr [ j ] ) { Integer tempo = arr [ i ] ; arr [ i ] = arr [ j ] ; arr [ j ] = tempo ; String tempi = a [ i ] ; a [ i ] = a [ j ] ; a [ j ] = tempi ; } } } for ( int i = 0 ; i < names . size ( ) ; i ++ ) { s [ i ] [ 0 ] = a [ i ] ; s [ i ] [ 1 ] = String . valueOf ( arr [ i ] ) ; } return s ; }
Returns a two-dimensional string array
Returns a two - dimensional string array