LAB4 (20pts) - The BlogEntry ADT

Purpose: The purpose of this lab is to explore the implementation and applications of a BlogEntryADT, which is built on the Date class and the Text ADT class of Lab3.

This lab is found at pg. 16 in your lab manual, which can be accessed through our Libraries --> Databases --> Safari Tech Books Online -->C++ Data Structures A Laboratory Course


Pre-lab: Implement methods for Date ADT.

  1. Carefully read pg. 16-23 in your lab manual.  `
  2. Download the starting packet, Lab4.zip, for this lab, and use it to create a BlogEntry CLion project. This folder contains

Note1: before you implement any method, make sure your project compiles. This might require adding method stubs in the Date.cpp. For example, if in Date.h you have a method "int getAverage();", in Date.cpp you may add something like
int Date::getAverage()
{

return 999;

}

Note2: Document with pre and post conditions all methods you are implementing. As usual, write this documentation first in .cpp, BEFORE you implement the methods, then optionally you may copy the documentation in the .h file. The method descriptions from the lab manual will help you a lot with the documentation.

3. Implement and test the Date ADT, following the steps in the Implementation Notes and Testing sections. Before lab, get through at least Test Plan 3.

Notes:

#include <ctime>
using namespace std;

...

time_t now = time(NULL);
struct tm *current = localtime(&now);

day = current->tm_mday;
month = current->tm_mon + 1;
year = current->tm_year + 1900;

// In Text.h, after the other function declarations...
// (See Date.h for an example of where this declaration goes.)

friend ostream & operator<< (ostream& output, const Text& outputText);

// In Text.cpp...

/* Requirements: The specified output stream must not be in an error 
 *    state (not checked).
 * Results: Inserts (outputs) outputText in the specified output stream
 *    and returns the resulting output stream.
 */
ostream & operator << ( ostream &output, const Text &outputText )
{
   output << outputText.buffer;
   return output;
}

Make sure it compiles. Notice that you can use the argument output just like you’d use cout. Use this code as an example when implementing operator<< for the Date class.

Note: Possible outputs of tests 2-1 up to 2-7 can be found here: t1, t2, t3, t4, t5, t6, t7.


In-lab: Complete your Date class and Test Plans 2-1 through 2-7, and do Analysis Exercise 2.

1. Complete your Date class and Test Plans 2-1 through 2-5. You should do this within the first 1.5 hours of lab. If any test cases for your Date class are not working, ask the instructor for help.

2. Implement the BlogEntry ADT and complete the rest of the test plan up to 2-7. (If helpful to you, check my possible outputs for these tests - they are posted above.)

Notes:

Text BlogEntry::getAuthor() const {
    return author;
}

Text BlogEntry::getContents() const {
    return contents;
}

Date BlogEntry::getCreateDate() const {
    return created;
}

Date BlogEntry::getModifyDate() const {
    return modified;
}

3. Do Analysis Exercise 2. (Your Blog ADT doesn’t need to be fancy: 2-3 private members and 3-4 public methods are enough. Just provide the basic functionality that anyone using the Blog ADT would require. The Bag.h at pg. 100 from your textbook might help you.)

4. You are recommended to start the post-lab.


Post-lab: Programming Exercise 1

  1. Do Programming Exercise 1.
  2. A possible output for this activity is at t8.

On Friday hand your Text Worksheet.pdf to the instructor.

By Wednesday midnight submit your project in the following way:

Grading:

  1. Text Worksheet.pdf: 5pts (2 pts the tests and 3 pts the Analysis Exercise 2)
  2. Date.cpp: 5pts (correctnes of methods; have pre and post; throw execptions when needed)
  3. BlogEntry.cpp: 5pts (correctnes of methods; have pre and post)
  4. Programming Exercise 1: 5pts
ts the Analysis Exercise 2)
  • Date.cpp: 5pts (correctnes of methods; have pre and post; throw execptions when needed)
  • BlogEntry.cpp: 5pts (correctnes of methods; have pre and post)
  • Programming Exercise 1: 5pts