0% found this document useful (0 votes)
2 views7 pages

CS262_P3

The document outlines the requirements for a programming project at George Mason University, where students must create a prototype for an Online Campus Tour app using a singly linked list in C. The program must allow users to add, delete, and manage tour stops, ensuring no duplicates and providing options for ordering stops. Additionally, it includes specifications for user interaction, file handling, and memory management testing using Valgrind.

Uploaded by

hashlab88
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

CS262_P3

The document outlines the requirements for a programming project at George Mason University, where students must create a prototype for an Online Campus Tour app using a singly linked list in C. The program must allow users to add, delete, and manage tour stops, ensuring no duplicates and providing options for ordering stops. Additionally, it includes specifications for user interaction, file handling, and memory management testing using Valgrind.

Uploaded by

hashlab88
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

CS262 - Spring 2025

Programming Project #3 -- Linked List Campus Tour

Premise:
The George Mason University Office of Transportation and Tourism (GMUTT)
has decided to create an Online Campus Tour. (A bright young CS student working
parttime in the GMUTT office has proposed that such a tour may be converted into a
downloadable app and used to fund full tuition scholarships to all future CS majors.)
In order to ensure the success of this app, GMUTT has asked several CS
professors (including your CS262 instructors) to select students to write alpha
prototypes of the tour. Seeing an opportunity to improve her students’ programming
ability, your professor has tasked you to create a prototype of a tour program that
could perhaps be integrated into the final app.

You are to create a program to assist GMUTT using the following specifications:
1. Your program will be written in C.
2. Your program will use a singly linked list to represent the tour.
3. Each node of the linked list will correspond to one stop on the tour.
4. One full tour is represented by visiting every node in the linked list once.
5. Each run of the program will allow the user to designate a new set of Tour
stops.
6. Prior to adding the Tour stops, the program should inquire whether the user
wishes to designate the order in which the Tour will visit each Tour stop. If the
user does not wish to designate the order, the program should store the Tour
stops in alphabetical order, so that the user may easily review the current
stops on the Tour.
7. No duplicate Tour stops should appear in the Tour.
8. The user may delete a Tour stop at any time.
9. A tour stop should be implemented as a struct contains (at minimum) the
following information:
a. Name of the Stop (Maximum of 25 characters, including the NULL
terminator)
b. A Brief Description of the Stop (Maximum of 100 characters, including
the NULL terminator)
c. The number of minutes expected to stay at the tour stop (using an
integer data type)
10. The program should allow the tour (in its current state) to be printed to the
screen
11. The program should be menu driven using a switch statement with the
following choices:
a. Print the current tour (stating whether the order was user-designated or
defaulted to alphabetical order)
b. Add a stop to the tour
c. Delete a stop from the tour
d. Restore a saved tour from a file. Prompt the user for the name of the file
from which to read a previously saved tour.
e. Save the current tour to a file. Prompt the user for the name of the file to
which the current tour is saved.
f. Exit the program
Programming Requirements:
Your program should define a tour node structure which contains variables to
hold the information required (Name of stop, description, time to spend, etc). The tour
structure will be part of a separate Linked List structure. In other words, you will have
two structs - one for the tour information, and the other for the linked list. The linked
list structure's data will contain a tour node struct as well as a self-referential “Next”
pointer. You should access the list through local pointers. (I.e., there should be no
global struct variables in your program.)

Your program must contain, at a minimum, the following functions:

1. Two Node insertion functions: (1) using alphabetical order, based on the name
of the Tour stop; and (2) using the Order designated by the user. Both insertion
functions must be able to handle insertion into an empty list (thus creating a
list with one node), insertion at the beginning of the list, insertion at the end of
the list and insertion within the list.
2. A function to delete a Node from the linked list. This function must be able to
handle a specified Node from the beginning, end or middle of the list.
3. A function to traverse the list, printing all the tour stops and their descriptions
in order.
4. A function to save the current tour to a binary format file
5. A function to load the current tour from a binary format file
6. A function to delete the entire tour (used on program exit).

When the user wishes to add a tour stop to the list, you will first ask for the name
of the stop and then a brief description of that stop. If the list is empty, you will add the
node for that tour stop to the list immediately. If there are already stops on the tour,
the node will be inserted either in alphabetical order, or in an order specified by the
user. You may use your own creativity as to how to program and/or prompt for this
order. One possible method is to ask the user which tour stop, if any, the new stop will
follow. You may ask the user to enter the Tours in the order they should be visited, but
remember that you must allow the user the opportunity to insert a stop in the middle if
s/he forgets one along the way.) If at any time the user enters the name of a stop
already contained in the list, you should notify the user of this fact, discard the new
node (so that no duplicates will appear in the Tour), and return to the menu.

When the user wishes to delete a tour stop from the list and the list is not empty,
you will ask the user for the name of the stop to remove. You will then search for that
tour stop and remove it from the tour. If the stop is not found, or if the list is empty, you
will notify the user of these facts and leave the current tour unchanged. You should
not ask the user for a tour stop name if the list is empty.
To save a tour, you will traverse the tour list in its current order and save each tour
stop in binary format (i.e. use fwrite()). To load a tour, you will read each tour stop
individually (using fread()), create a LinkedList node using the tour stop as its data and
insert each stop at the end of current list. When loading a tour, you must first delete
the current tour (if any) to avoid any memory leaks.

Feel free to set up your menu and user interaction as you wish, but be sure to
provide sufficient information to the user.

Testing using Valgrind:

It is time to get into the practice of testing your programs on zeus using valgrind.
Valgrind is a suite of programs that you can use to improve your programs. For this
assignment, you will be using a tool called Memcheck. Read a quick-start tutorial at
this link: http://valgrind.org/docs/manual/quick-start.html
Also read the Overview (section 4.1) for Memcheck at this
link: http://valgrind.org/docs/manual/mc-manual.html and skim sections 4.2 and 4.3.

Once you have your program working, use valgrind with the
--leak-check=yes
option to check for and correct any issues that are flagged. Don't forget to use the -g
and -O0 (that's oh-zero) options. Your Makefile should contain these options so that it
will compile with them automatically

Make sure that the Heap, Leak and Error Summaries using valgrind show that there
are no errors or issues. Then, to show what might happen if you make an error (such
as creating a memory leak), comment out the "free(p);" statement in one or more of
your source files and recompile. Then run valgrind again. Once you understand how
valgrind catches errors and makes you aware of them, uncomment the lines of code,
recompile and check again so that there are no errors.
Submission:
On zeus, create a directory named p3_<username>_<labsection>
Create a typescript with the following content: Show that you are on zeus
Show a listing of your directory
Show your source code
Remove any executable version using the Makefile
Compile the code using the Makefile
Run your code using the sample run
End the typescript
Be sure your directory ONLY contains the source code, typescript and Makefile
Create a tarfile of your project directory.
Name this tarfile p3_<username>_<labsection>.tar

Submit this tarfile to Blackboard no later than the due date.


Sample Run:
An example run of your program might be something like the following (Your output
doesn't need to look like this):

Welcome to the GMUTT Campus Tour!

Choose 1 to create the tour in alphabetical order


Choose 2 to customize the order of your Tour stops
Choice -> 2
New tour stops will be inserted into the list in an order chosen by the user.

Please choose from the following options:


1) Print the Current Campus Tour
2) Add a tour stop to the tour
3) Delete a tour stop from the tour
4) Save the current tour to a file
5) Load a tour from a file
6) Exit the program
Choice -> 1

Sorry, there are no stops on the tour yet.

Please choose from the following options:


1) Print the Current Campus Tour
2) Add a tour stop to the tour
3) Delete a tour stop from the tour
4) Save the current tour to a file
5) Load a tour from a file
6) Exit the program
Choice -> 2

Enter the name of the tour stop: Engineering Building

Enter an interesting fact about this stop: CS Department offices are on the 4th
floor.
Your tour stop has been entered into the tour.

Please choose from the following options:


1) Print the Current Campus Tour
2) Add a tour stop to the tour
3) Delete a tour stop from the tour
4) Save the current tour to a file
5) Load a tour from a file
6) Exit the program
Choice -> 2

Enter the name of the tour stop: Johnson Center


Enter an interesting fact about this stop: This is a great place for lunch!
Enter Tour Stop before which this new stop should be placed (Enter End to place at
the end of the tour): Engineering Building

Your tour stop has been entered into the tour.

Please choose from the following options:


1) Print the Current Campus Tour
2) Add a tour stop to the tour
3) Delete a tour stop from the tour
4) Save the current tour to a file
5) Load a tour from a file
6) Exit the program
Choice -> 1

Tour Stop 1: Johnson Center – This is a great place for lunch!


Tour Stop 2: Engineering Building - CS Department offices are on the 4th floor.
End of Tour

Please choose from the following options:


1) Print the Current Campus Tour
2) Add a tour stop to the tour
3) Delete a tour stop from the tour
4) Save the current tour to a file
5) Load a tour from a file
6) Exit the program
Choice -> 2

Enter the name of the tour stop: Fenwick Library


Enter an interesting fact about this stop: A good opportunity to catch up on some
sleep ...

Enter Tour Stop before which this new stop should be placed (Enter End to place at
the end of the tour): End

Your tour stop has been entered into the tour.


...

[More stops added]

...

Please choose from the following options:


1) Print the Current Campus Tour
2) Add a tour stop to the tour
3) Delete a tour stop from the tour
4) Save the current tour to a file
5) Load a tour from a file
6) Exit the program
Choice -> 3

Enter the name of the tour stop to delete: Engineering Building


The Engineering Building Tour Stop has been deleted.

Please choose from the following options:


1) Print the Current Campus Tour
2) Add a tour stop to the tour
3) Delete a tour stop from the tour
4) Save the current tour to a file
5) Load a tour from a file
6) Exit the program
Choice -> 1

Tour Stop 1: Johnson Center – This is a great place for lunch!


Tour Stop 2: Patriot Center – Catch a concert or a basketball game
Tour Stop 3: Taco Bamba – Not on campus, but a good place to eat and watch GMU
basketball
Tour Stop 4: Fenwick Library – A good opportunity to catch up on some sleep ...
End of Tour

Please choose from the following options:


1) Print the Current Campus Tour
2) Add a tour stop to the tour
3) Delete a tour stop from the tour
4) Save the current tour to a file
5) Load a tour from a file
6) Exit the program
Choice -> 4
Enter the name of the file -> tour

The tour has been saved!

Please choose from the following options:


1) Print the Current Campus Tour
2) Add a tour stop to the tour
3) Delete a tour stop from the tour
4) Save the current tour to a file
5) Load a tour from a file
6) Exit the program
Choice -> 6

Thank you for visiting GMU!

You might also like