ECS34 WQ25
January 21, 2025
Due January 31, 2025 at 11:59 PM
You will be working alone for this project. This specification is subject to change at any time for additional clarification.
Desired Outcomes
¡ñ Exposure to using C++ std::string
¡ñ Exposure to GoogleTest
¡ñ Use of git repository
¡ñ An understanding of how to develop Makefiles that build and execute unit tests
¡ñ An understanding of how to calculate edit distance
Project Description
You will be implementing a set of C++ string manipulation utilities that are like those available in python. To guide your development and to provide exposure to Test Driven Development, you will be developing GoogleTest tests to test your functions. You will also be developing a Makefile to compile and run your tests. You must use good coding practice by developing this project in a git repository. The string utility functions that you will have to develop are as follows:
// Returns a substring of the string str, allows for negative values as in // python end == 0 means to include end of string
std::string Slice(const std::string &str, ssize_t start, ssize_t end=0);
// Returns the capitalized string as in python std::string Capitalize(const std::string &str);
// Returns the upper- or lower-case strings as in python std::string Upper(const std::string &str);
std::string Lower(const std::string &str);
// Returns the left/right/both stripped strings (white space characters are // removed from left, right or both)
std::string LStrip(const std::string &str);
std::string RStrip(const std::string &str);
std::string Strip(const std::string &str);
// Returns the center/left/right justified strings
std::string Center(const std::string &str, int width, char fill = ‘ ‘); std::string LJust(const std::string &str, int width, char fill = ‘ ‘); std::string RJust(const std::string &str, int width, char fill = ‘ ‘);
// Returns the string str with all instances of old replaced with rep std::string Replace(const std::string &str, const std::string &old, const std::string &rep);
Project 1 1 of 3
Computer Science Tutoring
ECS34 WQ25 January 21, 2025
// Splits the string up into a vector of strings based on splt parameter, if // splt parameter is empty string, then split on white space
std::vector< std::string > Split(const std::string &str, const std::string &splt = “”);
// Joins a vector of strings into a single string
std::string Join(const std::string &str, const std::vector< std::string > &vect);
// Replaces tabs with spaces aligning at the tabstops std::string ExpandTabs(const std::string &str, int tabsize = 4);
// Calculates the Levenshtein distance (edit distance) between the two // strings. See https://en.wikipedia.org/wiki/Levenshtein_distance for // more information.
int EditDistance(const std::string &left, const std::string &right, bool ignorecase=false);
The Makefile you develop needs to implement the following:
¡ñ Must create obj directory for object files (if doesn¡¯t exist)
¡ñ Must create bin directory for binary files (if doesn¡¯t exist)
¡ñ Must compile string utils file and string utils tests using C++17
¡ñ Must link string utils and string utils tests object files to make teststrutils
executable
¡ñ Must execute the teststrutils executable
¡ñ Must provide a clean that will remove the obj and bin directories
You can unzip the given zip file with utilities on your local machine, or if you upload the file to the CSIF, you can unzip it with the command:
unzip proj1.zip
You must submit the source file(s), your Makefile, README.md file, and.git directory in a zip archive. Do a make clean prior to zipping up your files so the size will be smaller. You
can zip a directory with the command:
zip -r archive-name.zip directory-name
You should avoid using existing source code as a primer that is currently available on the Internet. You MUST specify in your README.md file any sources of code that you have viewed to help you complete this project. You MUST properly document ALL uses of Generative AI following the guidelines outlined in the Generative AI Restrictions. All class projects will be submitted to MOSS to determine if students have excessively collaborated. Excessive collaboration, or failure to list external code sources will result in the matter being referred to Student Judicial Affairs.
Recommended Approach
The recommended approach is as follows:
Project 1 2 of 3
程序代写 CS代考 加微信: cstutorcs
ECS34 WQ25 January 21, 2025
1. Create a git repository and add the provided files.
2. Create a Makefile to meet the specified requirements. Since no tests have been written,
all tests should pass.
3. Write tests for each of the functions. Each test you write should fail initially. Make sure to
have sufficient coverage of the possible input parameters.
4. Once tests have been written that fail with the initial skeleton functions, begin writing
your functions. You may find that you can write some of your functions based upon others you have already developed.
Your submission will be autograded. Make sure your code compiles on Gradescope, and passes all the test cases.
Helpful Hints
¡ñ Read through the guides that are provided on Canvas
¡ñ See http://www.cplusplus.com/reference/, it is a good reference for C++ built in functions
and classes
¡ñ Use lenth(), substr(), etc. from the string class whenever possible.
¡ñ If the build fails, there will likely be errors, scroll back up to the first error and start from
¡ñ You may find the following line helpful for debugging your code:
std::cout<<__FILE__<<" @ line: "<<__LINE__<