Exam
====


10.00h -- 11.45h


Create a calendar similar to the one in the last lecture.
Now the key of the calendar is not only the date but also the hour.

Insert and replace function now should return a bool value:
true on success, false on failure.

You can use the "date" class we implemented in lecture6.



This is the test program:



/*
 * calendar: list of dates, hours and associated events
 *
 */

#include <iostream>
#include <string>
#include "date.h"
#include "calendar.h"

int main()
{
    int your_mark = 1;
/*
    // default constructor: creates an empty list of events
    calendar my_calendar;  

    // inserting elements done ordered by date. insert returns bool
    my_calendar.insert(2015,5,18, 12, "Lunch");  
    my_calendar.insert(2015,5,18, 10, "C++ exam");  
    my_calendar.insert(2015,5,11,  8, "Practicing for C++ exam");

    if ( 3 == my_calendar.size() )
        ++your_mark;

    my_calendar.insert(2015,5,17,  8, "Reading C++ material");  // ok
    my_calendar.insert(2015,5,19, 20, "Party");      // ok, after exam
  
    // duplicated date+hour insert must return false
    if ( false == my_calendar.insert(2015,5,18, 10, "Other exam") // exists
          && 5 == my_calendar.size() )
        ++your_mark;

    // replace existing entries only. replace returns bool
    if ( true == my_calendar.replace(2015,5,19, 20, "More practicing")// exists
          && false == my_calendar.replace(2015,5,19, 22, "Party") // not exists
          && 5 == my_calendar.size()  )  
        ++your_mark;      

    // returns existing elements with their enty, otherwise return emty string
    if ( my_calendar.get(2015,5,18, 10) == "C++ exam"  // exists
          && my_calendar.get(2015,5,19, 22) == "" )    // not exists
        ++your_mark;

    std::cout << "my_calendar:" << std::endl;
    my_calendar.print();
    std::cout << std::endl;
*/
    std::cout << "Your mark is " << your_mark << std::endl;
    return 0;
}