CPSC 231:
ASSIGNMENT 7 (Due Friday June 18: Worth 6%)
New Concepts to be applied for the assignment
-
Records, arrays of records
-
Files/storage of information
-
Sorting information
Assignment description (Cars! Cars! Cars!)
For this assignment you are to write a
Pascal program that allows a person to track a list of their favorite models of
cars. In the input file each type of car will be described by six fields with each field residing on a
separate line in the following order:
- Manufacturer of the car
- Car model
- Price in Canadian dollars
- Acceleration
- Top speed
- Category of car
After the six fields a
blank line (which of course contains an end-of-line marker) will separate the information for this
type of car from the fields of the next
car. For example:
Chrysler
Talon
24000
6.5
240
sports
<BLANK LINE>
Chrysler
Laser
20000
6.5
240
sports
Description of the fields
1. Manufacturer
This is the name of the company that produces the
car and it will be a string up to 80 characters in length.
2. Car model
This is the name of the car and again it will
take the form of a string that won't exceed 80 characters.
3. Price
This field will be a real value and exclude
the dollar sign but include the decimal.
4. Acceleration
This is the number of seconds required to
reach 60 miles per hour from a standing start.
5. Top speed
This is the maximum speed of the vehicle in
kilometers
6. Category
This field classifies the car into different
types of categories. The value in front of the slash indicates the string
used in the data file while the value after the slash provides a full
description of that category.
sports/Sports car
jeep/Jeep
luxury/Luxury car
truck/Truck
Relevant files
The input file for this assignment is called "carData"
and contains the full list of cars. The program that you submit must be
able to handle as this list as input. For your own testing purposes you can use a
smaller version of this file called "reducedData". In addition, I will
soon put in the assignment directory an executable program, called "cars",
that reads the car list from a file and displays it back to the screen (to
provide you with an example output style). Your program is to read in the
information for the car's from the file and store it an array of records.
From there you program should be able to perform some basic list management
features which are described in the next section.
Grading: Working submissions
Make sure you clearly indicate in your README file which
grade level that you think you have completed for this assignment. This
should be followed by a list of the features that you have implemented in your
program. As was the case with the previous assignment, failure to provide
this information will result in a grade reduction of one letter step e.g.,
"A" to "A-".
e.g., Assignment for James Tam
"B" level assignment
Features completed:
1) All the requirements of a
"C" level assignment
2) The ability to display all cars of particular category
3)
The ability to add a car to
the list
4)
The ability to delete an existing car from the list
Basic Assignment Submission: C level assignment:
Your program reads the information from file into the array and you display the
contents of that array
onscreen with write's and writeln statements. The
output must be displayed in a neat and legible format file (run the executable
program for an example of formatted output).
Also, your program must be able to write the list back to an output file called
"modifiedCarData". In addition, the assignment must be properly
documented and must follow a good programming standard in order to qualify for a
"C" grade. Similar to the previous assignment, your program has menu
driven interface. The basic program should display a menu similar to the
one shown below:
Menu options for your car collection
(d)isplay collection
(l)oad a collection from disk
(s)ave a collection to disk
(q)uit program
You should add additional menu options as you implement the extra features
that are listed below.
Extra features
Completion of each of these extra features will result in the increase of a
"one step" increase in your grade e.g., C to C+. Except for
features two, four and six you
can complete as many of the features below as you wish in whatever combination
that you desire. In the case of those three features you must have
completed feature two before you can get credit for feature four or
six. Successful
completion of all seven features will make you eligible for an A+ (other
assignment requirements must have been fulfilled as well).
Feature one (Alphabetize the list):
Sort the list into alphabetical order
according to the model
of the car.
Feature two (Find additional details about a car):
The user of the program can type in the model to
find additional information about that car . If the car is not in the list,
then your program should indicate that the car could not be found under that
name. If the car is in the list, then your program will display additional
details about that car (all six fields of that car will be displayed onscreen).
Feature three (Present all cars within a category):
This feature allows the user of the program
to display onscreen only the cars that belong to a specific category (sports
car, truck, jeep or luxury car).
If you have already completed feature one,
then the car will be presented in
alphabetical order, otherwise they will presented in the order in which they
currently appear in the array.
Feature four (Edit car information - requires that you have already
completed feature two):
This feature allows the user to change information for a
particular car in the list.
In order to complete the requirements for this feature you must have completed
feature two because the user of the program must indicate which car model that
they wish to edit. When the edit
feature is selected, the user of the program will then be able to edit all the
fields of a car one field at a time. You are not required to allow
the user edit only some of the fields (although you can do this if you wish).
Feature five (Insert car at the end of the list):
When this feature is selected by the user, he or she will prompted to enter
in information for all the fields of the new car.
Feature six (Remove car from the list - requires that you have
already completed feature number
two):
With this feature the user types in a model
name and if that model of car exists the program will remove it from the
collection. If the car doesn't exist in the collection the program should
indicate that the model could not be deleted because it isn't in the collection.
Feature seven (Clear the entire list)
This feature allows the user to remove all
elements from the list and start again from scratch.
Grading: Non-Working submissions
D- version (0.7 GPA for the assignment))
The student has invested a considerable effort in the assignment, but the
program does not compile.
D version (1.0 GPA for the assignment)
The student has invested a considerable effort in the assignment, the program
compiles but does it not fulfill any of the requirements listed in the
assignment specification.
Other submission requirements
-
Good coding style and documentation:
They will play a role in determining your final
grade for this assignment. Your grade can be reduced by a letter step
or more if your submission was implemented using bad style conventions (e.g., "A" to "A-"
for employing poor naming
conventions for identifiers, insufficient documentation, the use of global
variables or non-modular design).
-
Include a README file in your submission: For this assignment
your README file must indicate what grade level you think your assignment should
receive (e.g., A, B or C) and the features that you have implemented.
This will allow your marker to quickly determine what he or she must look for
and speed up the marking process.
-
Assignments (source code and the README file) must be electronically
submitted via submit.
In addition a paper print out of the source code and README must be handed into the
assignment drop box for the lab that you are registered in (located on the
second floor of the Math Sciences building). Electronically submitting the
assignment allows your marker to run the code in order to quickly determine what
features were implemented. Providing a paper printout makes it easier for
your marker to read and flip through your source code. You do not
need to demo this assignment.
Suggested Approaches to this Assignment:
-
Start early! As was the case with the
previous assignment, this is another
"tough" assignment. There is a fair amount of new concepts that you have
to understand and apply for this one, although you may find problem a little
bit less difficult to solve than was the case with the previous assignment.
-
Take it in small steps. Get the basic
program working before you start working on the additional features. Make
sure it really works by testing it!
-
Back up your work! Once you get your basic
program working make a backup copy (e.g., at Unix type 'cp cars.p car.June9'. As you complete additional features backup these versions
and don't touch the backup and when you start working on more features, modify
only the copy.
-
Do attempt this assignment. Although it
isn't worth a large percentage of your final grade, writing these programs
really helps you to truly understand the concepts that you were taught in
lecture.
-
Addendum to point 4 - while it is important to try this assignment both
for the learning and the marks don't fall into the other extreme and spend all
your time on these last two assignments worth 12% and no time studying for a
final exam worth 40%.