You'll notice straight away that the starter code for this assignment will not compile straight out of the box. We're letting you take ownership of a bit more of the assignment setup this time around.
In order for a project to compile, all the functions that our code is calling need to be defined in the appropriate places. Typically in our assignment starter code, our provided test cases call all the functions you need to write for an assignment, and so to ensure that the project will compile when you download it, we create a function stub for each function that you'll have to write. A function stub is a kind of function skeleton that really doesn't do everything it needs to do, and instead just returns a dummy value (that is, a placeholder value that has no real meaning and doesn't solve whatever problem that function aims to solve).
For example, in Assignment 2, one of the functions you had to write in search.cpp was called gatherTokens(). Because we had test cases in search.cpp that were calling gatherTokens(), the project wouldn't have compiled unless that function were already defined in the starter code we gave you. We wanted the project to compile straight out of the box for you, but we didn't want to rob you of the fun of implementing that function, so we simply placed the following function stub in search.cpp:
// TODO: Add a function header comment here to explain the
// behavior of the function and how you implemented this behavior
Set<string> gatherTokens(string text) {
Set<string> tokens;
return tokens;
}
Notice that the function's return type is Set<string>. In order for the code to compile, that function had to be set up to return a Set<string>. So, we created the simplest possibly Set<string> we could think of β an empty set β and returned that as a "dummy value."
To create a function stub for a function that is supposed to return a string, we might simply return an empty string. For a boolean function, we could set up a function stub to return either true or false. For a void function, a function stub would not need to return anything at all; we could just create a function with an empty body. See search.cpp from Assignment 2 for additional examples of function stubs.
Note that for functions that return pointers, nullptr is always a good choice for a placeholder return value. You'll want to use that for a good number of the function stubs you set up for this assignment.
Your Task
To get the current project compiling, you will need to do the following:
-
Open the project in Qt Creator, go to
listystrings.cpp, and add function stubs for all of the functions listed in the comment toward the top of the file. To find their exact function signatures, check out the Listy Strings page of this assignment (linked from the assignment index page). -
Next, do the same for
garlands.cpp. You can find the required function signatures on the Garlands page of this assignment.
When adding function stubs to those files, we recommend copying and pasting the function signature for each required function directly from the assignment write-up, and having the body of each of those functions return a dummy value. Your function signatures will need to be exact matches for the ones listed in this assignment writeup in order for your code to compile and pass test cases. For guidance on this, you might want to refer to the starter code from previous assignments (such as search.cpp from Assignment 2), where we have several function stubs.
Once you have added all the function stubs correctly, your project will compile and run. If you get an error complaining that a required function is not defined, go back to the file where that function is supposed to be written and double check that the function signature is an exact match for the one listed in the assignment writeup, and that it has a body that returns an appropriate dummy value (or returns nothing at all in the case of void functions).
Once you have the project compiling, you're ready to push through the warmup exercises and start implementing the actual bodies of the required functions!
Example Function Stub
Here's an example to help get you started:
In listystrings.cpp, you'll see that one of the required functions is listToString. If you go to the Listy Strings page of this assignment, you can find that the full function signature for this particular function is string listToString(ListyNode *head). Since the return type for that function is string, you need your function stub to return some sort of string, such as an empty string. Putting all that information together gives rise to the following function stub, which you should add to listystrings.cpp, along with stubs for all the other functions listed there:
string listToString(ListyNode *head) {
// TODO: Implement this function later.
return "";
}