Compsci 100, Fall 2009, Blobs

Questions based on blob code whose operation is described.

In initializing a BlobModel two copies of the grid are created: myGrid and myCopy. The code in BlobModel.blobFill fills myGrid with characters representing blobs, removing the asterisks representing data that appeared before blobs were counted and replacing the asterisks with either blob-representing characters or with whitespace if the data aren't part of a blob.

  1. In method process of BlobModel what's the purpose of the System.arraycopy code?
    
    
    
    
    
    
    
    
    
    
  2. Explain the line below (part of the else {} code) in the process method.
       blobFill(j,k,bcount+1, BLOB_OFF);
    
    
    
    
    
    
    
    
    
    
    
  3. Modify the code in BlobModel.process to display only one blob: the largest blob found.
    
    
    
    
    
    
    
    
    
    
    
    
    
    

  4. Explain why a String would be a worse choice in BlobModel.display than the StringBuilder local variable used for building up asterisks and whitespace.
    
    
    
    
    
    
    
    
    
    
    
  5. In BlobModel.process this line occurs int minSize = Integer.parseInt((String) o); explain what parseInt does and why the cast is needed.