CSCE 2004 - Homework 8
Due Date - 05/01/2014 at 11:59 PM

                     You can work in pairs for this homework.

1. Problem Statement:

In this assignment, you are expected to write a program that provide users with a simple blog. Basically, you will create a new class called MicroBlog on top of the Tweet class written in homework 7. The main program declares a MicroBlog object and you need to write your own code to test the MicroBlog class methods. The MicroBlog class should contain the following members:

Data: (Private)

MAX_TWEETS : Maximum number of tweets that the blog can store.

num_tweets : Number of tweets in the blog at the moment

Tweet blog[MAX_TWEETS]: An array of Tweet objects

Methods:(Pulbic)

Default constructor: initialize the blog to an empty blog

Non-default constructor: initialize the blog from a given file (you may choose to use a single constructor with non-default parameters)

Copy constructor: initialize the blog with the information of another blog

Destructor:

EraseBlog: Erase the entire blog

FillBlog: Erases the blog and then fills the blog with the contents of the file specified by a Filename parameter. Returns true if successful, false otherwise.

AppendBlog: Appends new tweets from a file specified by a Filename parameter to the blog. Returns true if successful, false otherwise.

AddNewTweet: Adds a new tweet to the blog based on parameters for date, hashtag, and contents passed in

SaveBlog: Saves the contents of the blog in a given file.  It returns true if it was successful, false otherwise

GetNumTweets: returns the number of tweets in the blog

GetNumHashtag: returns the number of tweets with the given hashtag

GetNumDate: returns the number of tweets with the given date

Print(): prints all the Tweets

PrintHashtag: prints out all Tweets with a given Hashtag

void PrintDate: prints out all Tweets with a given Date

 

The main program, declares an object of MicroBlog class. It then welcomes the user and keeps servicing to the requests of the user based on their response to a menu of options.  Based on the user selection, the appropriate MicroBlog method is called.

2. Design:

First, you should think which parameters each of the methods in microblog class needs. Then, one by one, add an entry for that method in microblog.h.   and write an empty body for that method in microblog.cpp with just a print statement, e.g., "cout << "Inside GetNumTweets\n";  

Once the cout-only version of a method works, add the formal parameters to the method (in the .h and the .cpp) and call it from the main program with the correct actual parameters.

After writing the body of each method, compile the code and run the hw8.exe file and test to see what happens if the user selects the menu option related to the method you just wrote.

DO NOT TRY TO IMPLEMENT  ALL  OF THE METHODS, AND THEN  TESTING THEM ALL. YOU SHOULD CODE AND TEST ONE METHOD AT A TIME. S TART WITH THE SIMPLE AND IMPORTANT ONES FIRST.

3. Implementation:

Make a separate directory for hw8 and copy the 5 provided files (tweet.h, tweet.cpp, hw8.cpp, MakeFile, Tweet_Data.txt, microblog.cpp, microblog.h) in your own directory by doing:

$ mkdir hw8
$ cd hw8
$ cp ~sgauch/public_html/2004/S14/hw/hw8/* .

and compile by typing "make". The files provided should compile and run properly.

Complete the Tweet class one method at a time and test it. Start with the default constructor and Print.

Bonus point (10 points):

Overloading << and >> operators in Tweet class, and using them in Microblog.cpp:

Din >> TweetObject : This should set the TweetObject from the current line in Din file variable. You will be using this instead of FillTweet method in Microblog.cpp

cout << TweetObject: Simply doing the same thing as Print method in Tweet class does.

When you are done, run the following command in the shell:

$ cat microblog.h microblog.cpp hw8.cpp > Student1ID_Student2ID_code.cpp

If you have did the bonus and changed tweet.cpp and tweet.h, run the following command instead:

$ cat tweet.h tweet.cpp microblog.h microblog.cpp hw8.cpp > Student1ID_Student2ID_code.cpp

4 . Testing:

Each option in the menu should be tested at least once, before quiting the program. The output of your program should be added to the end of your report.

5 . Documentation:

When you have completed your C++ program, write a short report (less than one page long) describing what the objectives were, what you did, and the status of the program. Does it work properly for all test cases? Did you find this project interesting? Are there any known problems? What would you add to improve the functionality of your program.

Add your testing as an appendix at the bottom of the report.

Save this report in a text or pdf file.

6. Project Submission:

In this class, we will be using electronic project submission to make sure that all students hand their programming projects on time. When you have completed the tasks above go to the Homeworks tab on the course's Blackboard web site to "upload" your report (a single pdf or txt file), and your C++ program (a single cpp or txt file). Do NOT upload an executable version of your program. To upload , simply scroll down all the way down to the end of Homework description, then click on "Browse My computer" and attach your files one at a time. Do not write any other text in "comment" section or by clicking "write submission" button. After you attached the files, click on "Submit" button. You are allowed to submit more than once; only the last sumitted homework will be graded.

Only upload one set of files for each pair of students.  Each pair (or individual if working alone) should UPLOAD two (2) files:

1) Student1ID_Student2ID_code.cpp- This is your source code (.cpp) file. Do not use any Word processor or WordPad as they automatically add extra characters to your code that causes it not to compile. You can use TextPad or NotePad in Windows; nano or any text editor on linux; TextEdit on Mac (select Plain Text under preferences, save as ASCII)

2) Student1ID_Student2ID_report.pdf (or txt file):
There is a 10% penalty for not uploading the right formats and not naming the files correctly.

The dates on your electronic submission will be used to verify that you met the due date above. All late projects will receive reduced credit:

- 10% off if less than 1 day late,

- 20% off if less than 2 days late,

- 30% off if less than 3 days late,

- no credit if more than 3 days late.

You will receive partial credit for all programs that compile even if they do not meet all program requirements, so handing projects in on time is highly recommended. Programs that do not compile on turing will receive an automatic deduction of 60%.

Academic Integrity This assignment is to be done individually. All code must be written by the student or student pair doing the submission.