I having a problem with the status function..plz help
and here is the output result should be..
I having trouble with the status as notdone and done..
when you insert a thing that u need to do, it need to included the status of thing done or not done. and this is the problem I have to create a status function...thx
List[0]=Buy Groceries notDone
List[1]=Call friend notDone
List[2]=Study notDone
#include <iostream>
#include <string>
#include "ToDolist.h"
using namespace std;
TodoList::TodoList()
// Constructor
// Postcondition:
// length == 0
{
length = 0;
}
int TodoList::Length() const
{
return length;
}
void TodoList::Insert( /* in */ ItemType item )
// Inserts item
{
int index; // Index and loop control variable
index = length - 1;
while ((index >= 0) && (item < (data[index])))
{
data[index+1] = data[index];
data[index+1] = data[index];
index--;
}
data[index+1] = item;
TodoList::status(); // Insert item
length++;
}
void TodoList::BinSearch(
/* in */ ItemType item, // Item to be found
/* out */ bool& found, // True if item is found
/* out */ int& position ) const // Location if found
// Searches list for item, returning the indexof item if item was found.
{
int first = 0; // Lower bound on list
int last = length - 1; // Upper bound on list
int middle; // Middle index
found = false;
while (last >= first && !found)
{
middle = (first + last) / 2;
if (item < (data[middle]))
// Assert: item is not in data[middle..last]
last = middle - 1;
else if (data[middle] < (item))
// Assert: item is not in data[first..middle]
first = middle + 1;
else
// Assert: item == data[middle]
found = true;
}
if (found)
position = middle;
}
void TodoList::Delete( /* in */ ItemType item )
// Deletes item from the list, if it is there
{
bool found; // True if item is found
int position; // Position of item, if found
int index; // Index and loop control variable
BinSearch(item, found, position);
if (found)
{
// Shift data[position..length-1] up one position
for (index = position; index < length - 1; index++)
data[index] = data[index+1];
length--;
}
}
void TodoList::todotype()
{
cout<<"What would you like to do?"<<endl<<endl;
cout<<"Type 1 to add an item"<<endl;
cout<<"Type 2 to delete item"<<endl;
cout<<"Type 3 to mark item as done"<<endl;
cout<<"Type 4 to print to list of uncompleted items"<<endl;
cout<<"Type 5 to print the list of all items"<<endl<<endl;
}
void TodoList::status()
{
const int Num_row =2;
const string done="done";
const string Notdone="Notdone";
string donefunction[Num_row]={done,Notdone};
}
int TodoList::Typelist(int type)
{
string item;
if(type==1)
{
cout<<"ADD an item,please type your item"<<endl;
cin>>item;
TodoList::Insert(item);
}
if(type==2)
{
cout<<"DELETE an item, please type your item"<<endl;
cin>>item;
TodoList::Delete(item);
}
if(type==3)
{
cout<<"MARK ITEM DONE an item, please type your item"<<endl;
}
if(type==4)
{
cout<<"PRINT LIST OF UNCOMPLETED ITEMS"<<endl;
}
if(type==5)
{
cout<<"PRINT LIST OF ALL ITEMS"<<endl;
TodoList::Print();
}
return type;
}
void TodoList::Print()const
{
for (int i = 0; i < length; i++)
{
cout << data[i]<<endl;
}
}

