Project 0
Project 0
Fall 2022
Assignment No. 0
Reminder: The Academic Honesty Policy posted on Brightspace is applicable to all work you do this semester in
CS2201.
Assignment: This assignment deals with a program which stores a collection of tweets. The tweets will be stored in
sorted (chronological) order which is based on timestamps. The TweetMgr class is able to contain up to MAX_TWEETS
(currently defined to be 50) tweets. The TweetMgr.h file provides a detailed description of all the functions provided by
the class – you will want to read this file carefully.
You will be provided with the source code that supports the tweets and object code (pre-compiled code) that supports the
TweetMgr. Your task will be to test the provided TweetMgr class as fully as possible to ensure it works as expected. This
is known as test-driven development: we write code to test that a class works as expected, and afterward we write the
class such that it passes all tests (the only difference is that I am giving you working code so that you can see if your tests
are correct or not). Note: your task is to only test the TweetMgr class, not to implement the TweetMgr class. All the
functions that you are to test are fully described in the TweetMgr.h file.
The TweetMgr.h file contains a detailed description, known as the class declaration, of a set of functions to manipulate a
collection of Tweet objects. A predetermined maximum size of the collection is defined by the constant identifier
MAX_TWEETS. You will also be supplied a compiled object file, TweetMgr.cpp.obj or TweetMgr.cpp.o, which
implements all the functions [it was created from a properly working TweetMgr.cpp file]. You will also be provided
with an initial test program: TweetMgrTest.cpp. Your job is to add code to the TweetMgrTest.cpp file to fully
test/exercise the TweetMgr class. Note: your task is to only test the TweetMgr class, not to implement the TweetMgr
class. You are not to test the Tweet class – you can assume it works as given (if you think you have found a bug in the
Tweet class, please report them to the instructor or post them on Piazza). Please ignore any messages from CLion that the
methods are not implemented.
Here are the methods/features of the TweetMgr class that you are to test (see the TweetMgr.h file for descriptions that are
more complete):
TweetMgr class
Methods Function
TweetMgr() Default constructor – creates an empty TweetMgr
getNumTweets() Return the total number of Tweets in the TweetMgr
insert(const Tweet &t) Add/insert a tweet to the TweetMgr
retrieve(size_t index) Returns the tweet at the specified index
exists(size_t ts) Returns true if a tweet exists at the given timestamp
count(const string& sender) Returns the number of tweets from a specified sender
getTweets() Return a string of all tweets
getTweets(const string& sender) Return a string of all tweets sent by a specified sender
getTweets(size_t ts) Return a string of all tweets at a given timestamp
getTweets(size_t ts1, size_t ts2) Return a string of all tweets in a range of two given timestamps
deleteTweets() Deletes all tweets
deleteTweets(const string& sender) Delete all tweets from the specified sender
deleteTweets(size_t ts) Deletes the tweets whose timestamps are earlier than the
parameter timestamp
deleteTweets(size_t ts1, size_t ts2) Deletes all tweets between a range of two timestamps
Background: A TweetMgr simply manages a collection of tweets. A tweet is simply an object containing three items: a
sender, the text of the tweet, and a timestamp of when it was sent. Tweets are created/supported through the Tweet class.
Again, you may assume the Tweet class is bug-free. The purpose of this assignment is to only test the TweetMgr class.
The properties of the Tweet class (which is already provided to you) is given below:
Tweet class
Methods Function
Tweet() Default constructor – creates a Tweet object having an empty sender
and text, and timestamp of zero
Tweet(size_t ts, const string& Overloaded constructor that creates a Tweet object with the provided
sender, const string& msg) timestamp, sender, and message
string getUser() Return the sender of the tweet
void setUser(const string& newUser) Changes the sender of the tweet
string getText() Return the message of the tweet
void setText(const string& newText) Changes the message of the tweet
size_t getTimestamp() Return the timestamp of the tweet
void setTimestamp(size_t newTime) Changes the timestamp of the tweet
string toString() Return a formatted string version of the tweet, containing the sender,
the message, and the timestamp
bool equals(const Tweet& rhs) Compares two tweets for equality, comparing the senders, the
messages, and the timestamps
bool operator==(const Tweet& rhs) Equality and relational operators that compares two tweets by
bool operator!=(const Tweet& rhs) comparing only their timestamps. Useful for sorting tweets.
bool operator<(const Tweet& rhs)
bool operator<=(const Tweet& rhs)
bool operator>(const Tweet& rhs)
bool operator>=(const Tweet& rhs)
bool operator==(size_t ts) Overloaded equality and relational operators that compares a tweet
bool operator!=(size_t ts) against a timestamp value. The tweet must be on the left-hand side
bool operator<(size_t ts) of the operator for these to work.
bool operator<=(size_t ts)
bool operator>(size_t ts)
bool operator>=(size_t ts)
Note on using defined operators: In the above class description you see that several operators have been defined for the
class; for example “operator==” has been defined. You can use these like any other method of the class; for example if
t1 & t2 were two Tweet objects, you could type: t1.operator==(t2) to test if the two tweets had the same
timestamp. However, it is much easier to simply use them as the operators you know and love; for example: t1==t2.
Typing t1==t2 calls the operator== method.
Many of the methods of the Tweet class are declared to be const methods; indicating that they do not modify the object on
which they are called (the const declaration is not shown above to save space). The Tweet class has overloaded the
insertion operator so that tweet objects can easily be displayed with the << insertion operator.
You are NOT allowed to make any changes to the Tweet class.
Submission for grading: When you have completed your work on this assignment, please submit your
TweetMgrTest.cpp file for grading, as that is the only file you should have changed while working on this assignment.
Submit ONLY the single source file – please do not submit a zip file containing your entire project, and do not submit the
other TweetMgr/Tweet files. You can submit the files by visiting the assignment page in Brightspace (click on the
assignment name), scroll down to the “Submit Files” section, and add the file by clicking on the “Add a file” button and
finding the file to attach.
After submitting your homework, it is good practice to verify your submission. Revisit the assignment page in
Brightspace and make sure that your file was successfully submitted. Then click on the file to open it up so that you can
verify that you submitted the correct file, as opposed to some older version of the file. It is your responsibility to ensure
the correctness of your submission – this is true for all assignments.
Grading: This project is worth 25 points (half of a normal assignment). Your grade on this project will be based on the
thoroughness of your testing of the TweetMgr class performed by your TweetMgrTest.cpp file. Please make sure that your
code compiles without errors or warnings, and it runs to completion without prematurely terminating (say, due to an
uncaught exception).
You should also review the syllabus regarding the penalties for late programming assignments.
Note that we never grade test code for good programming style. However, it is to your benefit to use good style. We will
be using this test program for several assignments, and you will need to update it to test new/different behaviors. Such
updates are much easier when the test program is written with good style, using separate functions to test different
methods of the class. Past students have complained that updating the program was very hard for them since their code
was such a mess (which they thought did not matter since the code was not graded on style).
1. Unzip the provided zip file; use the one appropriate for your platform. This will create a folder named
project0-Windows or project0-MacOS-Intel or project0-MacOS-M1 that contains a set of
files.
2. Start up CLion. If it brings up an existing project, close that project down by selecting “Close Project” from
the File drop-down menu. This will return you to the CLion welcome screen: