Subversion Repositories programming

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
28 irasnyd 1
// Written by Ira Snyder
2
// Due Date: 11-15-2004
3
// Project #3
4
import java.io.*;
5
 
6
class Driver {
29 irasnyd 7
    public static void main ( String [] args ) throws Exception {
8
 
9
        System.out.println( test_12_2() );
10
 
11
    } //end main
28 irasnyd 12
 
30 irasnyd 13
    public static BinaryTree createTestTree() {
29 irasnyd 14
        BinaryTree treeB = new BinaryTree("B");
15
        BinaryTree treeD = new BinaryTree("D");
16
        BinaryTree treeE = new BinaryTree("E");
17
        BinaryTree treeC = new BinaryTree("C",treeD,treeE);
18
        BinaryTree treeA = new BinaryTree("A",treeB,treeC);
19
 
30 irasnyd 20
        return treeA;
21
    }
22
 
23
    public static String test_12_2() {
24
        BinaryTree treeA = createTestTree();
25
 
29 irasnyd 26
        String experimentalResult = treeA.toString();
27
        String correctResult = "((B),A,((D),C,(E)))";
28
 
30 irasnyd 29
        if( correctResult.equals(experimentalResult) )
30
            return "test_12_2: PASSED";
31
 
32
        return "test_12_2: *** FAILED ***";
29 irasnyd 33
    }
34
 
35
 
28 irasnyd 36
} //end class Driver
37
 
38
/*
39
      BufferedReader kb = new BufferedReader(
40
                              new InputStreamReader(System.in));
41
 
42
 
43
      BufferedReader br = new BufferedReader(
44
                              new InputStreamReader(
45
                                  new FileInputStream(filename)));
46
 
47
      PrintStream ps = new PrintStream(
48
                           new FileOutputStream(
49
                               new File(filename)));
50
 
51
*/
52