CIS501 Exercise: Factory Methods Download and unzip Lec11FM.zip. Study the class diagram, which shows how to use the FM pattern for reading/writing files. Notice that methods closeRead and closeWrite are *private*. Notice the delegate, CloseOp. Open the VS Solution ReaderWriter. Read the code for the factory methods, openRead and openWrite, to see how the delegate is used. Now rebuild and demo the code: Write some lines to the file, close, and then try to make both RThreads read the file at the same time --- it doesn't work! Repair class FileController so that both RThread objects can read the file at the same time. =============================================== RECAP of Thursday's exercise with factory methods: When a RThread reads the lines of the file, it uses its own FileReader object, constructed by the factory method, public FileReader makeReader(CloseOp c); Parameter c is bound to a delegate (method) holding "clean-up" code that must execute when the FileReader is told to close(). The protocol goes: 1. RThread asks FileController to openRead() and receives in return a handle to a FileReader. 2. RThread repeatedly asks its FileReader to read(). 3. When finished, RThread tells its FileReader to close(). The latter executes a call to FileController.closeRead() via the delegate.