CS 14 - Lab
CS 14
Homepage
Pre-lab
Read these forms:
academic integrity guidelines for this class and the
adademic integrity
guidelines of the University. To verify that you have
read and understand these guidelines, you will be signing a copy of
these guidelines in lab. The TA will provide you with the packet.
Please fill out the packet in blue or black ink only.
Simple Linked Lists
This lab is designed to give you a refresher on pointers and
experience with a very simplified linked list of integers.
Most importantly, this lab is designed to teach you how to
conform with a given specification for a design. In this
lab, I am giving you a skeleton of the code and the function
prototypes. I am also giving you a main function that will
test the functionality of you code. It is very important that
the code that you write works with the main function that I
provide you with. The majority of future lab assignments
and home programming assignments will follow the same format.
This does not mean that you should not write your own main
function and test cases to test your code. You should try
to test your code on your own and then make sure that it
works with the main function provided.
The Assignment
You will implement a simple linked list of integers and four
operations on the list: size, push_front, push_back, and print.
You will begin with the skeleton code provided. DO NOT
make any changes to the code given to you. You will only add
code to the skeleton code.
-
node.h - Class declaration for you
node class. Notice that all members are private meaning that
outside classes do not have unrestricted access to the member
variables and functions. However, we are making the List class
a friend of the node class. You don't need to completely
understand friends at this point, just know that a friend class
is allowed to access all private member variables and functions
as if they were public.
-
list.h - Class declaration for your
list class.
-
list.cc - This file will contain all
of the functions for the list class.
-
main.cc - This file contains the
main function for you program with your list class declaration.
This file is used to test your program and your code must
work correctly with this main function to receive credit
for the assigment.
-
output.txt - This file contains the sample
output that you must achieve with your code. It is very, very important
that your output looks EXACTLY like my output including all white
space and blank lines.
List Functions
You will implement the following list functions. The specifications
for each list function is listed below. Please
use the function declarations exactly as they are listed because
if you change them, your code will not interface correctly with the
main test function.
-
int size ( ) - Returns the size of the list
-
void push_front ( int value ) - This function will insert the integer
at the head of the list.
-
void push_back ( int value ) - This function will insert the integer
at the tail of the list.
-
void print ( ) - Prints the list. You will iterate through the list
and print each integer separated by a single space followed by an return
at the end of the line. You MUST follow these guidelines.
Ensuring that you get the correct output
For all assignments and lab practicals, we will be grading your code with
an automatic grading tool. To grade you code, we will be comparing your
output with output that we are expecting you to have. This means that you
will need to carefully read all guidelines and strictly following all
specifications to ensure that you receive points. Points will be broken
down for each test case and you will receive points based on the number
of test cases you pass. You must pass and entire test case to receive points
for that test case. To receive points for a test case, your output for
your test case must EXACTLY match my output down to the whitespace and
blank lines. To make sure you are following the specs, you can test your
output while you are coding your labs/assigments.
Your output MUST match mine EXACTLY.
This is my output. You need to determine
if yours is exactly like mine by using the diff command. Do a man on diff
for more information (type "man diff" at the command prompt). Basically,
you need to run the following command in Linux:
"diff youroutput.out myoutput.txt"
and if the files are the same, nothing
will be printed to the screen (That is your goal). However, you don't have
to get all test cases working, you can get extra credit. Make sure that the
output matches exactly for the test cases that you are able to get working.
To capture your output to a file, you
can use the output redirection available in the Linux shell. You can
redirect your output using > . To capture your output for this project,
your command would look similar to this: "yourexe >
youroutput.out" where yourexe might be the name of your executable and
youroutput.out is what normally would have been printed to the screen.
You will receive points for every test case that you get working.
VERY, VERY IMPORTANT - you will NOT receive points for a particular
test if the diff command fails for that test.
To gets points for tests, you must be able to pass previous tests before
subsequent tests can be run. If for any reason you can not get a test
case working but you are able to get subsequent tests working, you
must ensure that your code doesn't seg fault! That way, you can receive
points for subsequent test cases.
Procedure
1. Sign up for the class mailing list
here.
You may have already been signed up automatically so you might want to check
first.
2. Complete the academic integrity packet provided in lab. Please
completely fill out the cover page and the information at the bottom of each section in
the packet in blue or black ink (there are two locations to fill out) and return
the packet to your TA. You should have already read these before
coming to lab.
3. Download the code provided above.
4. Compile the code using "g++ -Wall -W -Werror -pedantic main.cc list.cc"
5. Insert the code for the functions that you will need to implement. Test
your program. Make sure your output matches mine
6. When your program is working correctly with the main.cc file provided,
raise your hand to be checked out. If it is getting towards the end of the lab
period, make sure you get checked out for what you currently have working.
Partial credit is much better than no credit at all.
7. To check out, you must demonstrate that you know how to capture your
output to a file and that output must match mine. When the TA comes by,
you must download a fresh copy of main.cc and output.txt (the TA must see
you do everything). You might want to know about the wget command. Do a man
on wget but basically it allows you to download a file on the web
from the Linux prompt. Compile your code. Run your executable and
redirect the output to a file. Run the diff command on my output and your
output to show the TA that you match my output completely. The TA will
also look at your code and inspect your output to make sure that you
implemented the lab correctly and did not hardcode any functionality
or output.
8. You MUST turn in your code electronically to receive credit
for the lab. Make sure your name and partners name is on the code and
turn it in. Please only have one turnin
for each group (only turn the code in from one account). The code is due
1 hour after the end of the lab period (as it will be every week).
Make sure to turn it in to the correct
section because you will lose points if you don't.
Point Breakdown
-
2 points - Attendance - Lab attendance will be 20% of the grade for each
lab. You will receive 1 point when the lab begins and 1 point when the lab
ends. Attendance will be taken during the first and last 5 minutes of the
lab period
-
8 points - Functionality
- 2 point - Correct destructor
-
2 points - Test 1
-
2 points - Test 2
-
2 points - Test 3
-
.5 points extra credit for push_back() - Test case 4
-
Deductions -
- -1 point - If both partners turn in the code. There should
only one turnin per group
- -1 point - Program seg faults at any time
- -1 point - Doesn't compile with complete flags: -Wall -W -Werror
-pedantic
- -5 points - Turned into the wrong lab section.
- -1 point - No name on turned in work
- -5 points - Code not turned in at all. This deduction also applies to
turnins that do not contain a the partners name (only the name that is not
on the turnin will have 5 points deducted. The person that actually turned
the code in will only have 1 point deducted if their name is not on the
turnin).
© 2003 UC Riverside Department of Computer Science &
Engineering. All rights reserved.