3/4/08

To Notes

CSC 212 -- 3/4/08

 

Review Question

  1. Find the errors?

    Scanner s = new Scanner("flights.txt");
    String origToFind = s.nextLine( );
    for(int i = 0; i <= f.length && f[i] != null; j++)
        if (f.getOrig( ) == origToFind)
            System.out.println(f.arrive);
    
    Ans:
    1. The Scanner constructor call should pass not pass in "flights.txt", it should pass in new FileReader("flights.txt");

    2. f.length should be f.length -1.

    3. j++ should be i++.

    4. Don't use == for comparing strings, use equals like this
      if (f.getOrig( ).equals(origToFind))

    5. Don't use f.arrive (arrive is private), use f.getArrive( ).

 

Project Proj6

 

Abstract Classes

 

Interfaces

 

Recursion

 

Practice Problems

  1. Predict the order in which the cells in this maze are searched.

  2. Predict the order in which the cells in this region are filled with the FloodFill algorithm.

  3. Use the QuickSort algorithm to sort this list: