Subversion Repositories programming

Rev

Rev 30 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 30 Rev 31
Line 5... Line 5...
5
 
5
 
6
class Driver {
6
class Driver {
7
    public static void main ( String [] args ) throws Exception {
7
    public static void main ( String [] args ) throws Exception {
8
    
8
    
9
        System.out.println( test_12_2() );
9
        System.out.println( test_12_2() );
-
 
10
        System.out.println( test_12_3() );
-
 
11
        System.out.println( test_12_4() );
-
 
12
        System.out.println( test_12_5() );
10
    
13
 
11
    } //end main
14
    } //end main
12
 
15
 
13
    public static BinaryTree createTestTree() {
16
    public static BinaryTree createTestTree() {
14
        BinaryTree treeB = new BinaryTree("B");
17
        BinaryTree treeB = new BinaryTree("B");
15
        BinaryTree treeD = new BinaryTree("D");
18
        BinaryTree treeD = new BinaryTree("D");
Line 29... Line 32...
29
        if( correctResult.equals(experimentalResult) )
32
        if( correctResult.equals(experimentalResult) )
30
            return "test_12_2: PASSED";
33
            return "test_12_2: PASSED";
31
 
34
 
32
        return "test_12_2: *** FAILED ***";
35
        return "test_12_2: *** FAILED ***";
33
    }
36
    }
-
 
37
    
-
 
38
    public static String test_12_3() {
-
 
39
        BinaryTree treeA = createTestTree();
-
 
40
        BinaryTree treeAleft = treeA.getLeft();
-
 
41
 
-
 
42
        if( treeA.isLeaf() == false && treeAleft.isLeaf() == true )
-
 
43
            return "test_12_3: PASSED";
-
 
44
 
-
 
45
        return "test_12_3: *** FAILED ***";
-
 
46
    }
-
 
47
 
-
 
48
    public static String test_12_4() {
-
 
49
        BinaryTree treeA = createTestTree();
-
 
50
        int correctResult = 5;
-
 
51
        int experimentalResult = treeA.size();
-
 
52
 
-
 
53
        if( correctResult == experimentalResult )
-
 
54
            return "test_12_4: PASSED";
-
 
55
 
-
 
56
        return "test_12_4: *** FAILED ***";
-
 
57
    }
34
 
58
 
-
 
59
    public static String test_12_5() {
-
 
60
        BinaryTree treeA = createTestTree();
-
 
61
        int correctResult = 2;
-
 
62
        int experimentalResult = treeA.height();
-
 
63
 
-
 
64
        if( correctResult == experimentalResult )
-
 
65
            return "test_12_5: PASSED";
-
 
66
 
-
 
67
        return "test_12_5: *** FAILED ***";
-
 
68
    }
35
 
69
 
36
} //end class Driver
70
} //end class Driver
37
 
71
 
38
/*
72
/*
39
      BufferedReader kb = new BufferedReader(
73
      BufferedReader kb = new BufferedReader(