BYU football is going to have a great season this year. You are going to write a program to compute statistics for the team so they can tell how well they did.


You need to design a class and use instances of that class to hold information about the performance of each team during the season. You should be able to read in data from a file that contains the scores of football games during the season. You should then be able to call functions on the objects to determine the following statistics:

  1. Which team won the most games during the season and should be the champion?
  2. Which team scored the most points in a single game during the season and how many points did they score?
  3. Which team scored the most points during the whole season and how many points did they score?

Think before programming

This lab is very similar to the midterm in terms of what you are being asked to do programmatically. You must read in a file and then create instances of a class (which you will design) to organize and store the data from the file in a logical way. For example, if I were reading in a file containing information about the usage of computers on campus, I would probably create a “Computer” class which stores a name or identifier for a computer as well as counts for numberOfUsers, numberOfErrorsFound, numberOfHoursUsed, or perhaps some booleans like isCurrentlyOperational, isOpenAccessComputer, requiresLogin, etc. You will need to decide what class you will design for your data and what data to store in that class in order to be able to answer the questions above.

This lab, like the midterm, is setup so that the requirements should indicate the order in which you implement the functionality of your program. If you look below, the first requirement is to create your own test case file. Once you do that, you already have 3 points. Proper format is important throughout, but should be there from the beginning. There's another 3 points. Start with an empty, functioning program and add the first coded functionality: prompting the user for the filename. Make sure the program works. Another 2 points. So far we haven't done anything too difficult and you've already earned 25% of the points.

Continue on, creating your class, adding data members and functions to your class and so on, one step at a time (making sure the program runs before going on to each next step). For each step you complete, you will earn more points until the program is complete. This way not only do you feel better because you can see your score going up, but you also have a guide to where to go next at each stage of implementation. The requirements on the midterm will be set up this way and will be very similar in nature to those you see for this lab.

Hint: You should have a Team class. As explained in the computer example above, you should think about what class would make most sense to answer the questions required for this lab. Notice the questions are asking “Which team…?” or “Which team…?”. That's a good sign you need a Team class.

Think about classes as things that emulate the real world. Each team should keep track of its own information, and not necessarily information about other teams, just like the real world. You can create multiple instances of this Team object, just as there are many different teams in the real world. As you think through how teams function in real life, you'll be able to put together a Team object for this lab.


Your input will be the name of a file. You need to have an interface (i.e. prompt the user and get input) that will allow the user to specify a file name.

The file you read in will have the following format:

Game Number Team Name Score Team Name Score
1 BYU 14 OldMiss 13
2 BYU 16 UTA 17

You can download the pass-off file here (right-click).


You should be able to answer the summary statistics questions above. Maybe you will think of some additional statistics that you feel better characterize the season. For extra credit, you are free to add other functions that can be called on your objects.

Finding a Maximum value

Answering the questions above will require you to find the maximum value over a set of values. How do you as a human being find the maximum value? How would you implement this in code? If you're struggling, see page 159 for a clue as to how to do this.

Getting Help

If you get stuck:

  1. Write down several different objects that seem to fit the data. Write down the methods for each of those objects and diagram the calls that would need to occur to answer each of the questions. If the object design seems cumbersome, try another way of grouping the data.
  2. We really want you to come up with the design, so you are free to ask the TAs questions about related problems, but dont ask them to design the objects for you.
  3. As a last resort if you need help from a TA (and you are working in the lab), please use the help request queue:

I need more than this

Think about how you might create multiple classes that interact. Remember that the words “has a” indicate when an object might contain other objects. If you want an extra challenge, try creating a second class and use it together with your first class to answer questions that would be difficult to answer without the second class.

Pass-off procedure

When you have your program working, you will need to show it to a TA.

Put yourself in the help request queue to pass off:

The TA will evaluate your code based on the following criteria:

  1. Did you include test cases in your own test case file to make sure each piece of your code was correct? Explore some different test case categories. (3 points) - For the midterm you will need to know about “test case categories”. By this we mean, explore cases that you expect the program would need to handle in different ways. For example, the program will likely need to handle the case where a team shows up once in the file (i.e. just a constructor), and a team that shows up more than once (i.e. requires updating an existing object). Border cases, such as when the totalTeamPoints is 0 or the highestScoreSoFar is 0 are always good test case categories.
  2. Did you format your code as shown in the book and in class, with separate lines, comments, indenting, and good variable naming? (3 points)
  3. Did you ask the user for a filename? (2 points)
  4. Did you write your own class definition - You should have a Team class (p. 393)? (4 points)
  5. Does your class have data members to store the data? (3 points)
  6. Does your class have accessor methods? (3 points)
  7. Does your class have at least one mutator method? (2 points)
  8. Do you keep a vector to store new instances of your class? (3 points)
  9. Did you correctly identify the team that won the most games and print the number of games they won? (3 points)
  10. Did you correctly identify the team that scored the most points in a single game and print out the points? (3 points)
  11. Did you correctly identify the team that scored the most points during the whole season and the number of points? (3 points)

Extra credit: Find a new significant statistic and implement it in your code? (3 point)

LDAP: couldn't connect to LDAP server
cs-142/teams.txt · Last modified: 2015/01/07 08:58 by ryancha
Back to top
CC Attribution-Share Alike 4.0 International = chi`s home Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0