UWA Logo Computer Science & Software Engineering
C Programming (CITS1210) - 1st project 2008
   Faculty Home  |  CSSE Home  |  csentry  |  CITS1210  |  help1210

Submission deadline: 12noon, Friday 12th September 2008

See also clarifications of the project description and requirements.
Please post requests for clarification about any aspect of the project to help1210 so that all students may remain equally informed.

The valet parking problem:

Some fancy restaurants (i.e. ones without a drive-through window) offer a valet parking service with which one of the restaurant's employees will park your car for you as you arrive at the restaurant, and then retrieve your car when you're ready to leave (expecting a generous tip at both ends of the evening!)

A frequently seen problem is that restaurants have insufficient onsite parking for all of the cars requiring the valet service, and so cars are tightly packed into the available bays, and even the "roads" connecting the bays. Invariably, my little yellow car is always parked at the rear of the car park, and often blocked by many other cars. Fortunately my car is always parked east-west and opposite the exit, which is always on the east or west side of the carpark. Of course the restaurant employees have the keys to all cars, and so they can shuffle them around to get my car to the exit.

The goal of this project is to help the employees bring my yellow car to the exit by accepting and verifying a sequence of commands, and then moving the cars until the yellow car is brought to the exit.

valetpark

The initial configuration of the carpark is read from a simple text file, the carpark file, such as:

    EXIT: 1 9
    ...b...c..
    ##.b...c..
    ..aaa.d...
    geee..d.ff
    g.....d...

where the lowercase letters denote the location (and length) of each car, a fullstop denotes an empty square, and the '#' character denotes my poor blocked car. The first line of the file provides the location of the carpark's exit, which will always be on the east or west edge of the carpark. The parking bay in the top-lefthand corner (the northwest corner) has the location (0,0). Having read and verified the details from the carpark file, the program reads a sequence of commands from its standard input. Commands are of the form:

    c S 3
    # E 1
    e E 2
where each line requests a single move. Each line provides (in order) the car to move, the compass direction in which to move it (N, S, E, or W), and the number of squares (parking bays) to attempt to move it.

Comments in the provided source code files define how the program should perform if the carpark file or any of the movement requests are invalid. The program terminates when any part of my yellow car is brought to the exit.


Getting started:

To commence the project, download the two C99 files valetpark.h and valetpark.c, and the plain-text files (CARPARK-a and MOVES-a) and (CARPARK-b and MOVES-b).

To undertake the standard project you will only need to edit and submit the single file valetpark.c. You will not need to edit or submit any other files. In particular, the provided C99 header file will be used when marking your project, so there is no point in you changing it.

In CSSE Lab 2.01 you may run a sample solution with the command

    /cslinux/examples/CITS1210/WWW/project1/valetpark-sample  CARPARK-a

Compiling your project:

If working in CSSE Lab 2.01 you may like to use the simple graphical output. Compile your project with:

    gcc -std=c99 -Wall -pedantic -Werror -o valetpark valetpark.c /cslinux/examples/CITS1210/WWW/project1/tcltkstuff-ppc.o -ltcl -ltk

If not wanting the GUI, or if developing on other systems, you should use a command similar to:

    gcc -std=c99 -Wall -pedantic -Werror -o valetpark valetpark.c

Your project will be marked on CSSE's Apple Macs in Lab 2.01. Ensure that your project is compiling and executing correctly on these machines before you submit your project. No allowance will be made for projects that "work at home" but do not work on CSSE's Apple Macs in Lab 2.01.


Project requirements:

To successfully meet the project's requirements, you are to complete the implementation of these functions:

readCarparkFile(), trimLine(), isValidLocation(), isValidCarparkEntry(),
processMoves(), findCar(), moveCar(), moveCarOneBay(), getValue(), setValue(), isEmpty(), hasExited(),
and printCarpark()

whose descriptions and prototypes are provided in the file valetpark.c   The same file also provides a number of other fully-written functions, including main(). There is no need to modify nor extend these functions to complete the project.

As provided, the files compile successfully and valetpark appears to work. However, none of the important functionality of playing the game is provided, and this is why the functions need completing.


Advanced task:

If you would like a much greater challenge, you may like to implement the advanced task. Even if attempting the advanced task, you must also complete and submit the standard tasks.

Develop your advanced task in a new program, in its own separate file, and compile the program with:

    gcc -std=c99 -Wall -pedantic -Werror -o valetpark valetpark-advanced.c

Those who undertake and complete significant parts of the advanced task will have the opportunity to "recover" any marks lost (deducted) in the first part of the project.


Assessment:

This project is worth 15% of your final mark for CITS1210: C Programming. It will be marked out of 30. You do not need to complete the advanced task to receive full marks (100%) for the project.

As always, you are expected to show professionalism in your approach by making appropriate use of the features of the C99 language, following the principles of good program design, and adhering to the programming conventions outlined in this unit.

Those who undertake and complete significant parts of the advanced task will have the opportunity to "recover" any marks lost (deducted) in the first part of the project. As a rough estimate, completing the advanced task of the project may allow a student to recover up to 5 (out of 30) lost marks. Note that a score of >100% is not possible.

During the marking, attention will obviously be given to the correctness and readability of your solution.

A correct and efficient solution should not be considered as the perfect nor only desirable form of solution. Preference will be given to well presented, well documented work. Do not expect to receive full marks for your program simply because it works correctly.

Marks will be allocated to each function according to:

  1. correctness: a function must implement the specification exactly and completely,
  2. clarity: a function must be easy to understand, and
  3. appropriate use of the features of the C99 language.

As a rough estimate, marks will be awarded as follows: 20 (out of 30) marks to program correctness (i.e., how well your functions match the specification of the questions asked), and 10 (out of 30) marks to coding style (i.e. how well you have written the functions in terms of clarity and use of the features of the C99 language).

Part marks to questions may be awarded, so if you are not able to get a function working correctly, you should still submit what you have done. However, you will be significantly penalised if your submitted program does not compile successfully (e.g. if it contains any compilation errors).

Your project will be marked on CSSE's Apple Macs in Lab 2.01. Ensure that your project is compiling and working correctly on these machines before you submit your project. No allowance will be made for projects that "work at home" but do not work on CSSE's Apple Macs in Lab 2.01.


On plagiarism:

You are expected to have read and understood the CSSE Policy on Plagiarism. In accordance with this policy, you may discuss with other students the general principles required to understand this project, but the work you submit must be the sole result of your your efforts.

All projects will be compared using software that detects significant similarities between source code files. Students suspected of plagiarism will be interviewed and will be required to demonstrate their full understanding of their project submission.


Submission:

You must submit your program using cssubmit. No other method of submission will be accepted. cssubmit will give you a receipt of your submission. You should print and retain this receipt in case of any dispute.

Please be fully aware of CSSE's Penalties for late submission. Submitting the wrong file(s) may result in a mark of zero for your project. Note also that the cssubmit facility does not archive submissions and will simply overwrite any previous submission with your latest submission.

  • If you are attempting the project's standard requirements, submit a single file named valetpark.c.
  • If you are attempting the project's advanced requirements, submit two files named valetpark.c and valetpark-advanced.c

Your C file(s) must begin with the following lines:

/*
   CITS1210 1st Project 2008
   Name:               <family name, first name>
   Student number:     <your student number>
 */

Good luck!

Submission deadline: 12noon, Friday 12th September 2008

Top of Page
CRICOS Provider Code: 00126G