The instructions and starter files for each CS 235 assignment are found in this repo.
In each homework folder are the instructions for that assignment and the files you will need.
You should use the .cpp
and .h
files that are provided. Do not change the names of any files.
The test_*.py
files run the tests for your submission. To run these locally:
- Make sure you have
byu_pytest_utils
installed:
pip install byu_pytest_utils
- In the homework folder, run:
python -m pytest -vv .
Once byu_pytest_utils
is installed, your IDE may detect the tests, and you can run them and see the test output there.
The test_files
folder contains files used for testing your submission.
The tests in Gradescope are identical to the tests provided in this repo.
Some homework assignments just have test_*.py
files. These files will show example invocations of your program with different command line arguments (if required). They compare the output of your program to the specified dialog.txt
file in test_files
.
A dialog.txt
file shows what your program should print (or write to an output file).
Strings surrounded by << >>
are inputs provided via STDIN to your program.
Some parts of the output are worth more than other parts (called "target regions"). These are identified by backticks (` `
).
The first part of the target region is the expected text; the second part is the name of the region (used in the test output); and the third part is the percentage of points assigned to that region.
Some homework assignments will also have a tests.cpp
file. This file is compiled with the files from your assignment.
Look through this file to understand what kinds of operations will be performed on your data structures.
Some homework assignments have you implement various data structures. You have 3 options to test your implementation:
-
Run the provided tests in the
test_*.py
file. This is the easiest to do, but it might make it harder to debug your code. -
Compile the provided
tests.cpp
file. This may be slightly harder to do, but doing it will allow you use the debugger to troubleshoot any errors in your data structure. Thetests.cpp
file does various operations on your data structure and just prints what it sees. Thetest_*.py
file just compares whattests.cpp
outputs to what it expectedtests.cpp
to output. Eachtests.cpp
file has several tests, each doing different operations on your data structure. To select a test(s) to run, pass in its number(s) as a command line argument. For example to compiletests.cpp
and run test 1, run the following:g++ -Wall -std=c++17 -o tests tests.cpp ./tests 1
The output from
tests.cpp
should be fairly self-describing. You can compare it with the expected output—which is found in thetest_files
folder—to see if your data structure is behaving properly. -
Write your own tests. This is hardest to do, but it will help you start thinking through how to test code and troubleshoot errors (and if you're a nerd, it might even be fun!). To do this, create your own
cpp
file,#include
your data structure, and write test code in themain
function to do operations to the data structure. For an even bigger challenge, give test-driven development a try. In a nutshell, this has you write tests before writing the code under test. Doing so helps your brain think through edge cases and places where things could break beforehand and in more depth. It also helps you feel more confident about your code as you see it (hopefully) doing what you expect it to do.
Your assignments are submitted through Canvas (which in turn uses Gradescope).
You should turn in only the .cpp
and .h
files that you modify or create.
We will be using Git to manage the homework files and instructions. To help you get started, here is a brief guide on how to use the essential Git commands for cloning, committing, and pulling the course repository.
To get started, you'll first need to clone the class git repository. This will create a local copy of the repository on your computer.
- Open your terminal or Command Prompt.
- Navigate to the folder you would like to store the local copy of the class repository.
- Run the following command (replace <repository_url> with the actual URL of the course repository):
git clone <repository_url>
This will create a new folder with the repository name containing all the starter files and instructions.
As you work on your assignments, you can save a backup of your work by committing your changes.
- Navigate to your repository folder in the terminal or Command Prompt.
- Check the status of your changes using
git status
. This will show you any new, changed, or deleted files. - Add the changed files to the staging area using
git add <file_name>
orgit add .
(to add all changes). - Commit your changes using
git commit -m "Your commit message"
(Replace "Your commit message" with a brief description of the changes you made).
Your changes are now saved in your local repository.
You can also see and commit your changes in your IDE.
To receive any updates to the instructions or starter files from the course repository, you'll need to pull the latest changes.
- Before pulling, make sure you have committed your current work following Step 2. This will help to avoid conflicts during the pull process.
- Run git pull to fetch and merge the latest changes from the remote repository.
If there are any conflicts between your local changes and the updates, Git will notify you. To resolve the conflicts, we recommend you use the resolve conflicts feature in your IDE.
After resolving conflicts, your repository will be up to date with the latest course materials.