600.108 Intro Programming Lab Week 9 THIS IS YOUR LAST WEEK TO WORK WITH THIS PARTNER - MAKE IT A GOOD ONE! PROBLEM STATEMENT (THIS IS A TWO WEEK LAB PROJECT): Imagine that you have a bunch of pictures stored on your computer, and you have just bought some frames at the store. The main purpose of our labs this week and next week are to help you match your pictures to the frames (to make presents for your friends), by storing their data in two separate collections through a program. You will also need to update the collections. There is no limit to how many pictures or frames your system might need to handle in these collections eventually. Your main driver program will have two components. The first will be to get input data for the pictures and the frames in the existing collections. The second component will consist of a series of operations to update the collections and match pictures to frames as described below. Instead of using a menu driven program, for this application we will have a transaction file that lists all the requested operations and their associated data to make it easier to test the solution repeatedly. First your main program should read a text file containing data for the pictures that your program will use. Ask the user for the name of this input file. This will contain data for a collection of pictures, one picture per line, in the string format used in lab 7 (Description [width,height] in pixels). Then ask the user for the name of a frames input file. This will contain data for one frame on each line. The data for one frame is the width and height of the opening (given as real # inches), and a letter indicating how the frame can be oriented. An 'S' indicates that the frame has a single mode which means that the width can only be the horizontal dimension and the height is vertical only. A 'D' indicates a dual mode frame, which can be used with the dimensions swapped as well. (Invalid modes should be treated as an S.) The second component of your main program will be to process a series of transactions. All the data for the transactions will come from a file named "transactions.txt", one transaction per line. Your program must simply process all the transactions in the file. Many of these requests will be satisfied, but some will be invalid and produce error messages instead. Each transaction will be indicated by a type code, which will be followed in some cases by additional required data. The transactions may be repeated several times and occur in any order. Here are the operations that span the labs for both weeks: F - Display the list of frames on the screen, each with a unique ID number. A - Add another frame to the collection. This transaction line should include the width, height and mode (D or S) of the frame, all separated by spaces. For example: A 8.5 11 S P - Print the list of pictures to the screen, each with a unique ID number, in order from smallest perimeter to largest perimeter. Include the perimeters as part of the output to make it easy to verify the ordering. D - Delete a picture from the collection, based on it's subject matter (case insensitive). For example: D sleeping CAT This transaction should produce an error message if the subject cannot be found. M - Match a picture to a particular frame, given the current resolution. Use IDs to identify the specific picture and frame you are trying to match. Take into account whether it is a Single or Dual mode frame, and output yes or no as the result. This produces an error message if a picture or frame ID is invalid. R - Figure out what resolution is needed in order for the current largest Picture to fit into a particular frame, given the frame ID. Output the result and make that the new current resolution. An error message is generated if the frame ID is invalid. PHASE 1 (Analysis): Create three sample input files: pictures.txt, frames.txt and transactions.txt, that will completely test and demonstrate the functionality of your program. Be sure to include data that will cause each error message to get displayed at least once. PHASE 2 (Design): Make a list of all the classes your solution needs in order to work, and describe how they relate to each other. You can do this in words or pictures. The only operations that should happen in main are the input and transaction handling. All the work of creating and building the collections and manipulating individual pictures and frames should be done in more specific classes. PHASE 3 (Coding): Download the Picture (from lab 7) and Frame (lab 9) classes from the course website. Create a FrameCollection class to organize and encapsulate the processing to create and display a group of frame objects. Think about what methods will be needed by main and the various transactions, such as adding an object to the collection. There is no limit on how many Frames the collection could hold, so you have to be able to increase the size of the collection if necessary. Then create a very similar class PictureCollection to hold all the Picture objects. At this point only include basic creating and displaying methods, not anything too complex. PHASE 4 (Coding): Write your main program, using the input files you created in PHASE 1 and the class files you have started in PHASE 3 but not yet written completely. In main you should create the picture and frame collections and fill them with the data from the input files. Main should also read (but not yet process) the transaction input file. PHASE 5: Update the Picture, Frame, and collection classes to include any methods needed by main that you don't already have. Add the processing needed to implement transactions F and A. The rest of the program will be done next week! ************************************************** MAKE SURE YOU DELETE YOUR FILES OFF THE LAB COMPUTER WHEN DONE, FAILURE TO DO SO IS AN ETHICS VIOLATION! **************************************************