ComS 228 Fall 2005
Homework 1

Objectives:

A single game of ten-pin bowling is made up of ten frames. At the start of a frame, ten pins are freshly set up; the bowler tries to knock the pins over by rolling a heavy ball into them. If all ten pins are knocked over on the bowler's first try, it is called a strike and an X is marked on the scorecard in the first slot for that frame. Otherwise, the number of pins knocked down (0-9) during the first try are marked down in the first slot and the bowler has a second try. If all the remaining pins are knocked down during the second try, that is called a spare and the second slot on the scorecard is marked with a /. If the bowler doesn't knock down all the pins by their second try, then that is called an open frame and the number of pins knocked down during the second try is written down in the second slot for that frame on the scorecard.

Calculating the score for a frame is tricky, and can be automated by a computer.

Some things to notice:

In this programming assignment, you will be writing a class to handle the matchup between two teams of bowlers. Each team consists of the same number of bowlers, defined by a constant called TEAMSIZE. Each player bowls 10 frames (plus extra rolls as necessary), and all their scores are added together to get their team score. The team with the highest score wins the matchup.

To start this assignment, download the BowlingMatch.h file. Other than possibly changing the value of TEAMSIZE for testing purposes, do not change anything in BowlingMatch.h. In particular, don't change the prototypes for any of the member functions, as the TA will rely on them for testing. You should also download BowlingMatch.cpp. Put all of your code for this HW in BowlingMatch.cpp. In this file, you should implement all the functions specified in BowlingMatch.h. Additionally, if you want to write your own helper functions, you can write them as non-member functions and put their prototypes and implementations where indicated in BowlingMatch.cpp.

One of the constructors reads in the players' frames from a file. The input file should be formated as follows:

Here is an example of a correctly formatted input file: match.dat.

The printMatch() function needs to output the data in a nice-looking format. Here's the format:

The table constains a column of width 20, and for each frame, a column of width 4. The text in all columns should be right-justified. The table begins with a header row, with "Frame" in the first column and the numbers 1 to 10 in the next 10 columns. Then, for each player, the table contains the following: Here is an example output showing what the printMatch() function should display for the match.dat file given above.

You may download a sample program that tests the BowlingMatch class: hw1test.cpp. Remember that this is sample test code only; it does not fully test your implementation and fully-testing your code is part of the assignment. Also, remember that part of the points for this assignment will depend on documentation and programming style, as discussed in the first recitations.

To help you handle compiling multiple files, you can download a Makefile for this assignment and sample test code. To compile all your code, just type "make" at the command line.

When you are ready to submit your programming assignment: