Spring 2003.
(Sections 02 & 03 only) |
Program # 6, Option #2
Due by 9 p.m., Wednesday of Week # 10. |
||
|
Results from the mayor's race have been reported by each precinct as follows:
Precinct: | Candidate A | Candidate B | Candidate C | Candidate D |
---|---|---|---|---|
1 | 192 | 48 | 206 | 37 |
2 | 147 | 90 | 312 | 21 |
3 | 186 | 12 | 121 | 38 |
4 | 114 | 21 | 408 | 39 |
5 | 267 | 13 | 382 | 29 |
Write a program that will handle the above data (and be general enough to handle similar data sets of varing, but relatively small, sizes) in the following ways:
java Elections <electionData.txt
java ElectionNews <electionData.txt
Note: It is possible to write a solution to this problem that does not use an object-oriented approach. If that's all you can manage, go ahead and do that, and you'll still be able to earn a minimally passing grade if that much at least is done well. (Even if you take that approach, you are still expected to develop and use appropriate methods: I can't imagine your needing more than about ten different methods, but you should be able to come up with at least four or five good ones.) If you want to have a chance at earning full marks on this final assignment of the term, however, you've got to do it by instantiating an Election object with relevant instance data and methods, along with creating a separate ElectionNews driver class to direct the display of an Election's results. (Here again, you'll need a range of methods. Some obviously go into the Election class, and require an Election object's private instance data to be able to work; others could be written either as additional support methods for an Election object, or they could be static methods in the ElectionNews driver class that invoke the object's public accessor methods to get any necessary data. At this point, early in your computer science career, you may develop the "other methods" whichever way fits your understanding so far: in future courses, you'll learn about ways to make decisions in order to optimize your design.)
Your program(s) should, of course, both work and exhibit good design (including but not limited to: good problem decomposition, use of meaningful identifiers, appropriate use of encapsulation involving both included and imported methods, etc.) and superb documentation.
Use the "handin" facility available from your Central Unix account on Polylog1 to submit these required files to the Pgm6 folder for your section:
Minimal Option (without object-oriented design):
Advanced Option (with an object-oriented approach):
Whichever option you choose, your source code is expected to be well-documented, including any information the grader or I may need to know about how to run your program.
Do not submit the corresponding .class file (the course account does not have enough space for all of those!); instead, we'll automatically compile them from the .java files you do submit. Note that you must use the exact names specified above for our automatic processes to work. If your filenames differ in any way from those indicated, or if your files do not compile, they will not be graded.
It is expected that your source code will contain full internal documentation. Use the standard comment block at the beginning of the program for your design specifications and other general information. Use comments throughout your programs to clarify to anyone reading your program what you are doing at each step along the way. If you have additional comments to make, you may submit a supplemental README document, in plain text format, but its existence must be documented in the program file you submit. If you don't understand the expectations here: talk with some classmates, see your instructor during her regular office hours, or make an appointment with your instructor for a time well in advance of the due date.
Back: | This Instructor's CSC-101 HomePage |
Up: | This Instructor's HomePage |
Thanks to John Dalbey for his reference to this problem! This lab was adapted from his, which he reports as originating at: