17 November 2011

Chapter 12

    • #include<cctype> is declared above.
    • function prototype: string up(string s)
    is declared
    • This function uses for loop with index < s.size() and uses
    toupper(s[i]) to convert string to upper case and returns a modified version
    of the string to be used by functions below
   
1)    match Function
    • void match(string title, vector<unsigned int>&found)
    prototype is added to BookCollection class as a member function
    • for loop with index < s.size() is used. Inside the loop
    if (up(title) == up(book.title[i])) assign i into found vector.

2)    partialMatch Function
    • void partialMatch(string title, vector<unsigned int>&found)
    prototype is added to BookCollection class as a member function.
    • Declare s1 = up(title).  Then for loop with index < s.size() is used.
    Inside the loop    declare string s2 = up(book.title[i]);
    if (s2.find(s1) != string::npos) assign i into found vector.

3)    displayBooks Function
    • void displayBooks(vector<unsigned int>&)
    prototype is added to BookCollection class as a member function.
    • for loop with index < found size is used. Each index in the found
    vector uses book[] display function.

4)    lookUpBook now calls the above functions sequentially.