Question

In: Computer Science

You are asked to create to to-do list program to store and manage to-do items for...

You are asked to create to to-do list program to store and manage to-do items for user.

You need to define a class to-do item which holds the following attributes:

• Id => number, generated by the program when item is created

• Title => string • Description => string

• Type (e.g. shopping, housing, work, etc.) => Enum

• Priority => number between 1 to 5

• Status => (e.g. done, in progress, hold, etc.) => Enum

• Create date => date struct, to be set on creation

• Due date => date struct

• Last modified date => date struct, to be changed every time user makes a change

Write (3) three different constructors beside default constructor to initialize:

1. Title, Description, Type

2. Title, Type, Priority,

3. Title, Type, Priority, Due date Write set / get function of each of the attribute defined above.

You are required to define a to-do list class which holds a one dimension array of to-do objects with MAX_SIZE = 100 and the list of the following functions:

• Constructor: to initialize an empty to-do list

• Copy constructor: to initialize to-do list from another to-do list

• Add to-do item: ask the user to enter the attributes for to-do item and then insert the to-do item to the bottom of the list

• Edit to-do item: ask the user which attribute to edit and then make the change to the existing to-do item

• Delete to-do item: ask the user for the id of to-do item to be deleted

• Delete multiple to-do item by type: ask the user for the type

• Delete multiple to-do item by status: ask the user for the status

• Write list to text file o Each line in the text file represent one to-do item, all attributes are written as comma separated

. • Read list from text file

• Sort list by: o Priority o Due date o Create date o Type with inner sort by: Priority Due date

• Print list to the console with different options: o All items o Filtered by type given by the user o Filtered by priority given by the user o One item by id given by the user

• Merge another to-do list: to define a function to pass an object of to-do list, the new items will be added to the bottom of the list

• Clone to-do list to another to-do list In addition, you need to define the following global functions:

• Copy to-do list items to 2 dimensional array, each row represents item’s type.

• Copy to-do list items to 3 dimensional array,

o Second dimension represents item’s type.

o Third dimension repreents the priority

Solutions

Expert Solution

// I have defined the structure of the first few functions to give you all the idea you need. You can modify it and define the rest on your own to serve your purpose.
#include <iostream> // std input output
#include <string> // use string data type
#include <ctime> // to use date time datatype
using namespace std; // to easily ise cin and cout without writing std::
#define MAX_SIZE 100 // defining MAX_SIZE to represent 100

enum type //defining an enumeration data type by the name type which can hold the given values
{
shopping,
housing,
work
};
enum status //defining an enumeration data type by the name status which can hold the given values
{
done,
inProgress,
hold
};

// Class For To Do Item
class ToDoItem
{
private:
// below mentioned are all the attributes given in the question
int Id;
string Title;
string Description;
type Type;
int Priority;
status Status;
// time_t is a datatype for date time
time_t CreateDate = time(0); // time initialized with present time.
time_t DueDate;
time_t LastModified;

public:
// The different constructor functions
ToDoItem(){};
ToDoItem(int Id, string Title, type Type, string Description)
{
this->Id = Id;
this->Title = Title;
this->Description = Description;
this->Type = Type;
}
ToDoItem(int Id, string Title, type Type, int Priority)
{
this->Id = Id;
this->Title = Title;
this->Type = Type;
this->Priority = Priority;
}
ToDoItem(int Id, string Title, type Type, int Priority, time_t DueDate)
{
this->Id = Id;
this->Title = Title;
this->Type = Type;
this->Priority = Priority;
this->DueDate = DueDate;
}

// all the get/set methods required
int getId() { return Id; }
void setId(int Id) { this->Id = Id; }

string getTitle() { return Title; }
void setTitle(string Title) { this->Title = Title; }

string getDescription() { return Description; }
void setDescription(string Description) { this->Description = Description; }

type getType() { return Type; }
void setType(type Type) { this->Type = Type; }

int getPriority() { return Priority; }
void setPriority(int Priority) { this->Priority = Priority; }

status getStatus() { return Status; }
void sets(status Status) { this->Status = Status; }

time_t getCreateDate() { return CreateDate; }
void setCreateDate(time_t CreateDate) { this->CreateDate = CreateDate; }

time_t getDueDate() { return DueDate; }
void setDueDate(time_t DueDate) { this->DueDate = DueDate; }

time_t getLastModified() { return LastModified; }
void setLastModified(time_t LastModified) { this->LastModified = LastModified; }
};

// ToDo list class for maintaining an array of to-do items
class ToDoList
{
private:
int count; // We will be mainiaining the number of to do items in the to do list
ToDoItem TODoObjects[MAX_SIZE];

public:
// Constructor
ToDoList() { count = 0; }
// Copy Constructor
ToDoList(const ToDoList &list) { ToDoList TODoObjects = list; }
// method to add a to do item
int AddToDoItem()
{
string Title;
string Description;
cout << "Enter Title: ";
cin >> Title;
cout << "Enter Description: ";
cin >> Description;
string inp; // we will take a string input and match it with our type enumerator because directly taking an enumerator input is not possible in C++
type Type;
cout << "Enter Type: ";
cin >> inp;
if (inp == "shopping")
Type = shopping; // we change the value of our type enum as per the value of our string input
else if (inp == "housing")
Type = housing;
else
Type = work;
TODoObjects[count] = ToDoItem(count, Title, Type, Description); // we have used the counter to give the id number to our to do item, you can use any other approach too.
count++; // after inserting the to do item, we have increased the count to reflect the number of to do items
return count;
}
};

// this is the driver function to run the above class functions and achieve our task
int main()
{
ToDoList mytodo;
int i, n;
// you can provide all the menu options required. I have displayed 2 as an example.
cout << "You can perform the following operations:\n1. Add To Do Item\n2. Exit the program";
// 1 means always true, so infinite while loop is run so that we can ask the user again and again what he wants to choose, untill they opt to exit, in which case we call run
while (1)
{
cout << "Enter your choice";
cin >> i;
// Switch menu to perform different operations of your choice.
switch (i)
{
case 1: // thsi will be called when the user wants to add an item in the to do list
n = mytodo.AddToDoItem(); // we will take the count number and hence the id to display the user where the item is inserted, so that they can refer to it for future modifications/deletions
cout << "New item added to the list with Id: " << n;
break;
case 2:
return 0;
default: // the default case is triggered when none of the correct options have been selected, thus the user will be asked for a choice again
cout << "Please enter the right choice.";
}
}
return 0;
}


Related Solutions

Imagine you are writing a program to manage a shopping list. Each shopping list item is...
Imagine you are writing a program to manage a shopping list. Each shopping list item is represented by a string stored in a container. Your design requires a print function that prints out the contents of the shopping list. Using a vector to hold the shopping list items, write a print function to print out the contents of a vector of strings. Test your print function with a main program that does the following: Create an empty vector. Append the...
C or C++ program Create a list of 5 things-to-do when you are bored (in the...
C or C++ program Create a list of 5 things-to-do when you are bored (in the text file things.txt, one line each), where each thing is described as a string of characters of length in between 10 and 50. Design a C program to read these things in (from stdin or by input redirection) and store them in the least memory possible (i.e., only the last byte in the storage for each string can be the null character). After reading...
In this question you will be asked to create some classes: Store, GroceryStore, and ClothingStore.
Use Python general directions: In this question you will be asked to create some classes: Store, GroceryStore, and ClothingStore. Store has the following attributes and methods: total_profit - this is a CLASS ATTRIBUTE that keeps track of the profit made in each instance of Store. (A class attribute is an attribute shared by all the instances of the class) __init__ - this is a constructor that is used to create an instance of a Store object. This constructor will do...
You are to create a program to request user input and store the data in an...
You are to create a program to request user input and store the data in an array of structures, and then display the data as requested. The data you are collecting refers to a set of images. The images are OCT images taken of the lining of the bladder. The data you provide will help diagnose the image as cancerous or not, but your code does not need to do that at the moment. First, Define a global structure that...
C program! Create a list of 5 things-to-do when you are bored (in the text file...
C program! Create a list of 5 things-to-do when you are bored (in the text file things.txt, one line each), where each thing is described as a string of characters of length in between 10 and 50. Design a C program to read these things in (from stdin or by input redirection) and store them in the least memory possible (i.e., only the last byte in the storage for each string can be the null character). After reading things in,...
Imagine that you are asked to create a dissemination plan for a health promotion program. You...
Imagine that you are asked to create a dissemination plan for a health promotion program. You have just learned that most of the stakeholders that you planned to present to are leaving the country in two weeks and will be gone for the next six months, so you must present your findings to them before they leave. Originally, you had three months to prepare your dissemination plan. Do you think that the plan should be disseminated as it would be...
how do I create a graph class to store a adjacency list representation of a graph?...
how do I create a graph class to store a adjacency list representation of a graph? I need some help and dont conpletely understand how to start. if you could provide a code with some steps id appreciate it.
Given a list of items, write a program that generates a list of lists of the...
Given a list of items, write a program that generates a list of lists of the following form: [a,b,c,...,z]⇒[[z], [y,z], [x,y,z], ... , [a,b, ... ,y,z]] Hint: Slicing is your friend. please write a python program
Grocery List Program Write a program that keeps track of the user's grocery list items. Prompt...
Grocery List Program Write a program that keeps track of the user's grocery list items. Prompt the user if they'd like to (each action is a function): See the list Display all items (if any) in the list Add item to their list Confirm with the user before adding item (y/n or yes/no) If they enter a duplicate item, notify them the item already exists Remove items from their list Confirm with the user before removing item (y/n or yes/no)...
You have been asked to create a program that builds a tower base on the number...
You have been asked to create a program that builds a tower base on the number of items given as input. When the only 1 item is given you create no tower you just place the item on top of the stand. When 2 items are given you build the base of the tower with one foot to the right and one foot to the left. The feet will be in the ground and support the tower. For every additional...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT