Project 1: Polymorphic I/O

Objective

 

Gain experience with byte-level data file processing in serializing polymorphic collections.

Estimated Time to Completion:  4-15 hours (depending upon experience and debugging skills)

Task

 

Given the classes Printable, Int, Float, and String from lecture 1, write a program that creates a polymorphic collection of Ints, Floats, and Strings (must have two of each and a minimum of 10 total – you pick the values).  This program should then write the data out as a text file (readable using Notepad, etc.), write the data out as a binary file (readable using a hex editor), clear the collection, and finally load the data into the collection from the binary file.

 

You must do the following:

 

50%    Write the main algorithm that creates the collection (vector is fine) of 10 elements – a mixture of Ints, Floats, & Strings.

 

60%    Write a function that saves the collection in a text file (and modify the main algorithm to call this function).

 

80%    Write a function that saves the collection in a binary file (and modify the main algorithm to call this function).

 

100%  Write a function to load the collection from a binary file (and modify the main algorithm to call this function after clearing the collection).  Be sure to print the newly-loaded collection after it's been loaded to verify correctness.

Deliverable

 

CPP file which compiles and works as defined above.

 

Any file that doesn’t compile or terminates “ugly” will receive no credit.

 

Hints

 

  1. You'll most likely have to modify one or more of the classes that I gave you (Printable, Int, Float, String), so feel free to do so.  Of course, if your solution bypasses this, that's fine too… it's not a requirement that you modify them.
  2. Keep in mind that when you are reading in a string from a binary file, you'll have to determine when the string ends; they aren't fixed in length!
  3. Typecasting will be your friend (or nemesis! J) for this project.
  4. You can see my running solution and the example text and binary files with which to compare your solution.

Sample Solution

 

Project 2: Win32 GDI

Objective

 

Gain experience with the Win32 GDI including message handling and BitBlt'ing from an external bitmap file;

Estimated Time to Completion:  15 hours

Task

 

Given the file prj2.h, write a program that displays two "battleship" grids in a a non-resizable window.

 

You must do the following:

 

50%    Implement the Win32 shell application which opens a non-resizable window with a black background. This window should have a system menu which allows minimization, move, and close.

 

75%    Draw two 8x8 grids to the screen and display titles for each grid.

 

100%    Load the 128x32 bitmap from an external file and bitblt the 32x32 icons into each grid location based upon the value in the prj2.h grid variables.

 

Deliverable

 

C file which compiles and works as defined above.

A 128x32 BMP file.

 

Any file that doesn’t compile or terminates “ugly” will receive no credit.

 

Hints

 

  1. Be aware that the grid variables are COLUMN MAJOR, so make sure that your output reflects this.
  2. You can see my running solution which uses the test.bmp file with which to compare your solution.

Extra Credit

If you'd like 15% extra credit, store the board arrays in a text file and load the information from the file when you create the application. In order to get this extra credit, you'll have to turn in an additional file: your "board" file which will contain the board information for the player's and the opponents board. In addition, you must have a commented-out section of your code showing that you were able to generate this board file from the array (effectively writing the data to the file from the array); it should be commented out b/c I don't need to see it run - I'll just validate that your created file was made from your application. Good luck!

Sample Solution

Project 3: Multithreaded MergeSort

Objective

 

Gain experience with Win32 threads API and the MergeSort algorithm

Estimated Time to Completion:  15 hours

Task

 

Given the file lecture_11.cpp as a starting point, write multithreaded version of MergeSort that spawns a new thread for each "half" of it's work. These threads should process their "halves," and when they are finished, the control thread (relative!) should then merge the two halves together.

 

You must do the following:

 

50%    Read in the int array data from file specified by argv[1] (with appropriate error checking). The first num in the file defines how large the array should be. The remaining nums are the data (thus if N is the first num in the data file, then there should be N nums to follow it for a total of N+1 nums in the file)

 

75%    Correct implementation of Multithreaded MergeSort procedure

 

100%    Correct memory and handle management. Style plays a big part of this project, so spend time getting it all "cleanly" implemented.

 

Deliverable

 

CPP file which compiles and works as defined above.

(I'll use my own data file, so be sure to conform to the standard)

 

Any file that doesn’t compile or terminates “ugly” will receive no credit.

 

Hints

 

  1. This project will be run from the command line since it takes in command line arguments.
  2. Be sure to correctly allocate memory and free it when you're done. Be careful with handles too!
  3. You can see my running solution which uses the data.txt file with which to compare your solution.

Extra Credit

If you'd like 10% extra credit, do an O() analysis of your multithreaded MergeSort. Be sure to discuss theoretical upper bound with respect to thread overhead. Note that this extra credit is only possible if you correctly implement the algorithm.

Sample Solution

Project 4: Scattered, Smothered, Covered Bits

Objective

 

Gain experience with bitwise operators

Estimated Time to Completion:  10-20 hours

Task

 

Waffle house claims to have over 844,739 (or 22,020,090 if you look at their PDF-version of their menu) ways to make "the finest hamburgers around."  Your task is to model the burger information in as small a space as possible using bit-level data manipulation.  First, construct a way of storing all of the various burger options at the bit level.  Second, write a module that takes in a "burger info" variable and displays the information in an English format that a short-order cook could understand.  Finally, in your main algorithm, generate 2000 burgers and validate that they are valid burgers (b/c depending upon how you write your program, it's possible to generate a non-valid burger).

 

Here are the burger options (as I see them):

 

Note that if you get a triple, each meat can be cooked different (i.e. you can get one patty medium, one well, and the other medium rare - or any combination of the above "cookedness").  Also, if you get more than one patty, you have the option of that many slices of cheese - so a double could have no, one, or two slices of cheese.  Be careful to consider all the possibilities here!

 

You must do the following:

 

50%    Define all of the needed bit-level constants and/or data structures to store the burger information

 

75%    Write the PrintBurger module

 

100%  Generate 2000 valid burgers and display them to the screen

 

Deliverable

 

CPP file which compiles and works as defined above.

 

You must use WebSubmit to submit this assignment

 

Any file that doesn’t compile or terminates “ugly” will receive no credit.

 

Hints

 

  1. Start small and make sure that you "get" bitwise operators and bit masking with the bitwise OR operation
  2. You can see my running solution if you'd like an example of possible output... but remember that the burgers are random, so don't try to duplicate what you get from my program; also note that I've got some different options like pepper/salt, so don't worry if your options are different from mine.

Extra Credit

If you'd like 10% extra credit, describe exactly how many burger combinations there are in your solution.  Tell me how you'd calculate this mathematically, and also tell me how you can determine this by looking at your program and the bit-level information.  There should be a difference; explain why there is this difference between the mathematical calculated value and the bit-determined value.

Sample Solution