Last active
November 5, 2021 02:29
-
-
Save ameryisafreeelf/b30386e64f0b5cee715c6ecd67a55ea8 to your computer and use it in GitHub Desktop.
First round of feature requests in To Do List exercise (week 2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
#include <vector> | |
#include <ctime> | |
static int taskNumberCounter = 0; // Static variable to assign a taskNumber to task | |
enum Status {done, notDone}; | |
enum Priority {none, low, medium, high}; | |
class Task { | |
private: | |
int taskNumber; | |
std::string name; | |
Status currStatus = notDone; | |
Priority currPriority = none; | |
time_t dueDate; | |
public: | |
Task(std::string name, Status s); // Assigns a taskNumber and increments taskNumberCounter | |
void setName(std::string newName); | |
void setStatus(Status newStatus); | |
void setPriority(Priority newPriority); | |
void setDueDate(timt_t newDueDate); | |
}; | |
class List { | |
private: | |
std::vector<Task> taskList; | |
public: | |
List(Task &t); // Creates a List, note that instantiation of a List requires a Task | |
// Accessors | |
Task getTask(int taskNumber); | |
// Mutators for taskList | |
void addTaskToList(Task &t); // Creates a task object and adds it to taskList | |
void deleteTaskFromList(Task &t); // If this causes taskList.empty(), delete List | |
std::vector<Task> viewTaskList(); // Returns a copy of taskList | |
std::vector<Task> viewTaskListDateSort(bool asc); // Returns list of tasks sorted by Date, ascending or descending | |
std::vector<Task> viewTaskListByStatus(Status s); // Returns list of tasks filtered by status | |
std::vector<Task> viewTaskListByPriority(Priority p); // Returns list of tasks filtered by priority | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(Second and fourth options)
I implemented a notion of priority and date. This felt relatively straightforward as I simply added a those properties to the
Task
class with getters and setters. Then, I added some methods inList
that allow for sorting by date and filtering by both status and priority.