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:
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.
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.
If you get stuck:
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.
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: http://taohelpqueue.appspot.com/requesthelp/YPK364KMSA5U5QF55UCL8LQ3JHCS5C
The TA will evaluate your code based on the following criteria:
Extra credit: Find a new significant statistic and implement it in your code? (3 point)