Question

In: Computer Science

For this assignment I need to use information from a previous assignment which I will paste...

For this assignment I need to use information from a previous assignment which I will paste here:

#ifndef TODO
#define TODO
#include <string>

using std::string;

const int MAXLIST = 10;

struct myToDo
{
    string description;
    string dueDate;
    int priority;
};

bool addToList(const MyToDo &td);
bool addToList(string description, string date, int priority);
bool getNextItem(MyToDo &td);
bool getNextItem(string &description, string &date, int &priority);
bool getByPriority(MyToDo list[], int priority int &count);
void printToDo();

#endif



#include <iostream>
#include "ToDo.h"

using namespace std;

myToDo ToDoList[MAXLIST];
int head = 0, tail = -1;

bool addToList(const myToDo &td)
{
    if(head < MAXLIST)
    {
        if(tail == -1)
            tail++;
        ToDoList[head] = td;
        head++;
        return true;
    }
    return false;
}
bool addTolist(string description, string date, int priority)
{
    MyToDo td;
    td.description = description;
    td.dueDate = date;
    td.priority = priority;
    return addToList(td);
}
bool getNextItem(MyToDo &td)
{
    if(tail >= 0)
    {
        if(tail >= MAXLIST)
            tail = 0;
        td = ToDoList[tail];
        tail++;
        return true;
    }
    return false;
}
bool getNextItem(string &description, string &date, int&priority)
{
    myToDo tmp;
    bool status = getNextItem(tmp);
    if(status == true)
    {
        description = tmp.description;
        date = tmp.dueDate;
        priority = tmp.priority;
    }

    return status;
}
bool getByPriority(MyToDo list[], int priority, int &count)
{
    if(tail < 0)
            return fals;
        count = 0;
        for(int i = 0; i < head; i++)
        {
            if(ToDoList[i].priority == priority)
            {
                list[count] = ToDoList[i];
                count++;
            }
    }
    if(count > 0)
            return true;
        return false;
}
void printToDo())
{
    for(int i = 0; i < head; i++)
    {
        cout << "Description" << ToDoList[i].description << endl;
        cout << "Due Date" << ToDoList[i].dueDate << endl;
        cout << "Priority" << ToDoList[i].priority << endl;
    }

With this info I am asked:

Creating A Classes

This assignment is geared to check your understanding of Object Oriented Programming and class creationg. The class type is called a complex type because it is a type that you create from the primitive types of the language. Even though you create it it is still a full fledged type.

This activity is designed to support the following Learning Objective:

  • Differentiate between object-oriented, structured, and functional programming methodologies.

Instructions

In Assignment 19 you created a simple ToDo list that would hold structs that contained information about each item that would be in the list.. For this assignment I want you to take lab 19 an create a class out of it.

Your class should be called ToDoList. The definition for the ToDoList should be in the header file. The variables that make up the data section should be put in the private area of the class. The prototypes for the interface functions should be in the public area of the class.

Data Section

You can easily identify the variables that make up the data section from the fact that all of the functions use these variables. You should remember from the lecture material on classes that the data section should be the private section of the class. You should also note that if a variable should not have direct access to it then it should be in the private section. What I mean here is that if a person can directly access a variable from a function outside of the class and if modifying this variable can cause unknown problems to the operation of your class then it should be in the private section of the class.

Prototype Functions

All of the function prototypes should also go in the class. If a function is an interface into the class then it should go in the public section. For this assignment all functions are interfaces so all prototypes should go in the public section of the class.

In the previous step you prototyped all of the functions and put them in the public section of the class definition. The bodies for these functions should go in ToDoList.cpp. Don't forget to use the scope resolution operator to relate the function bodies to the prototypes in the class definition.

Constructors

You should have a default and overloaded constructors. The overloaded constructor should take 2-strings and an int which represent the descrition, dueDate, and priority.

Solutions

Expert Solution

// ToDo.h

#ifndef TODO

#define TODO

#include <string>

using std::string;

const int MAXLIST = 10;

struct myToDo

{

    string description;

    string dueDate;

    int priority;

};

#endif

//end of ToDo.h

// ToDoList.h

#ifndef TODOLIST

#define TODOLIST

#include <iostream>

#include "ToDo.h"

using namespace std;

class ToDoList

{

private:

       myToDo toDoList[MAXLIST];

       int head, tail;

public:

       ToDoList();

       ToDoList(string description, string date, int priority);

       bool addToList(const myToDo &td);

       bool addToList(string description, string date, int priority);

       bool getNextItem(myToDo &td);

       bool getNextItem(string &description, string &date, int &priority);

       bool getByPriority(myToDo list[], int priority, int &count);

       void printToDo();

};

#endif

//end of ToDoList.h

// ToDoList.cpp

#include "ToDoList.h"

ToDoList::ToDoList()

{

       head = 0;

       tail = -1;

}

ToDoList::ToDoList(string description, string date, int priority)

{

       head = 0;

       tail = -1;

       myToDo td;

       td.description = description;

       td.dueDate = date;

       td.priority = priority;

       toDoList[head] = td;

       addToList(td);

}

bool ToDoList:: addToList(const myToDo &td)

{

       if(head < MAXLIST)

       {

             if(tail == -1)

                    tail++;

             toDoList[head] = td;

             head++;

             return true;

       }

       return false;

}

bool ToDoList:: addToList(string description, string date, int priority)

{

       myToDo td;

       td.description = description;

       td.dueDate = date;

       td.priority = priority;

       return addToList(td);

}

bool ToDoList:: getNextItem(myToDo &td)

{

       if(tail >= 0)

       {

             if(tail >= MAXLIST)

                    tail = 0;

             td = toDoList[tail];

             tail++;

             return true;

       }

       return false;

}

bool ToDoList:: getNextItem(string &description, string &date, int &priority)

{

       myToDo tmp;

       bool status = getNextItem(tmp);

       if(status == true)

       {

             description = tmp.description;

             date = tmp.dueDate;

             priority = tmp.priority;

       }

       return status;

}

bool ToDoList:: getByPriority(myToDo list[], int priority, int &count)

{

       if(tail < 0)

             return false;

       count = 0;

       for(int i = 0; i < head; i++)

       {

             if(toDoList[i].priority == priority)

             {

                    list[count] = toDoList[i];

                    count++;

             }

       }

       if(count > 0)

             return true;

       return false;

}

void ToDoList:: printToDo()

{

       for(int i = 0; i < head; i++)

       {

             cout << "Description" << toDoList[i].description << endl;

             cout << "Due Date" << toDoList[i].dueDate << endl;

             cout << "Priority" << toDoList[i].priority << endl;

       }

}

//end of ToDoList.cpp


Related Solutions

I need this in pseudocode: Similar to the previous assignment, you’re going to read in the...
I need this in pseudocode: Similar to the previous assignment, you’re going to read in the number of years the player played and the starting year of that player – followed by the statistics for those years. This time, however, you’re going to print out the years from worst to best in sorted order. Hint: this will require a second array to store years. If you can sort one array, can you sort both? Sample Output #1: Enter the number...
( i need Unique answer, don't copy and paste, please) (dont' use handwriting, please). (i need...
( i need Unique answer, don't copy and paste, please) (dont' use handwriting, please). (i need references URL Link) General Question ** How to perform logistic regression in SPSS?
( i need Unique answer, don't copy and paste, please) (dont' use handwriting, please) (i need...
( i need Unique answer, don't copy and paste, please) (dont' use handwriting, please) (i need your reference URL Link) 1. Discuss charismatic traits and behaviors of a leader. How a person can manage relationship in workplace? i need more explain ( i need Unique answer, please) *** Please i need Unique answer, if you don't have unique answer don't answer ***
( i need Unique answer, don't copy and paste, please) (dont' use handwriting, please) (i need...
( i need Unique answer, don't copy and paste, please) (dont' use handwriting, please) (i need your reference URL Link) 1. Discuss charismatic traits and behaviors of a leader. How a person can manage relationship in workplace? i need more explain ( i need Unique answer, please) *** Please i need Unique answer, if you don't have unique answer don't answer ***
( i need Unique answer, don't copy and paste, please) (dont' use handwriting, please) (i need...
( i need Unique answer, don't copy and paste, please) (dont' use handwriting, please) (i need your reference URL Link) 1. Discuss charismatic traits and behaviors of a leader. How a person can manage relationship in workplace? i need more explain ( i need Unique answer, please) *** Please i need Unique answer, if you don't have unique answer don't answer ***
****** please don't copy and paste and don't use handwriting ****** I need a unique answer...
****** please don't copy and paste and don't use handwriting ****** I need a unique answer Q1: Write HTML code to get the following output that include the following elements. The title is: Favorite Books Large heading with text “Your Favorite Books” Form that has 3 input values (two text boxes and one drop down list) Drop-down list contains the following options, Pearson Wiley Mc-Graw Hill Submit information to “books.php” using GET request. Q2:Display a simple message "Welcome" on your...
****** please don't copy and paste and don't use handwriting ****** I need a unique answer...
****** please don't copy and paste and don't use handwriting ****** I need a unique answer Q3: According to Ed Leonard, the CTO at DreamWorks “Shrek 3 consumed 20 million CPU render hours with 3000+ server CPUs, with 24TB file size”. Suppose the personal computer CPU advanced so much so that we accomplished that goal by fabricating 3000-core Processor Motherboard. Would this new multicore machine perform as well as the parallel processing employed by DreamWorks? Give 2 justifications to support...
Hello..I need a presentation (not copy paste from the internet, comprehensive and detailed) on the topic...
Hello..I need a presentation (not copy paste from the internet, comprehensive and detailed) on the topic of 6lowpan in networks and the topic is necessary
DO NOT COPY AND PASTE FROM THE WEBSITE!!!! I NEED YOUR OWN WORD!!! Explain the seeming...
DO NOT COPY AND PASTE FROM THE WEBSITE!!!! I NEED YOUR OWN WORD!!! Explain the seeming contradiction in the One-Way ANOVA; namely, that the null hypothesis is about comparing the means of three or more populations, whereas the actual testing of means is about using ANOVA analysis to compare variances. Why is this so?
Please, i need Unique answer, Use your own words (don't copy and paste). *Please, don't use...
Please, i need Unique answer, Use your own words (don't copy and paste). *Please, don't use handwriting. *Please, don't use handwriting.*Please, don't use handwriting.*Please, don't use handwriting.*Please, don't use handwriting.*Please, don't use handwriting.*Please, don't use handwriting.*Please, don't use handwriting.*Please, don't use handwriting.*Please, don't use handwriting.*Please, don't use handwriting.*Please, don't use handwriting.*Please, don't use handwriting.*Please, don't use handwriting. _______________ Solve the following questions Q1 Construct a cumulative frequency distribution of the 20 brain volumes(cm3) listed below. Use the classes 900-999, 1000-1099,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT