Skip to content

Instantly share code, notes, and snippets.

@ameryisafreeelf
Last active November 5, 2021 02:29
Show Gist options
  • Save ameryisafreeelf/9a0b847ca292906b1d21898b102e4b4b to your computer and use it in GitHub Desktop.
Save ameryisafreeelf/9a0b847ca292906b1d21898b102e4b4b to your computer and use it in GitHub Desktop.
Third round of feature requests in To Do List exercise (week 2)
#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};
enum Visibility {Visible, NotVisible}; // Public means that friends can view the task
class User {
private:
std::string name;
std::vector<User> listOfFriends;
List l;
public:
std::vector<User> getListOfFriends();
// We can have some UI element call returnNumOfPublicTasks when this method is called, so that when a user views a friend's list,
// the number of tasks in that friend's list will be available.
List viewFriendsListOfTasks(User &u); // This will call the input user's list via viewTaskListByVisibility()
// This will call viewTaskListByVisiblity(public) for all users and return the number of tasks with the same name
int getNumUsersWithSameTaskName(std::string taskName);
};
class Task {
private:
int taskNumber;
std::string name;
Status currStatus = notDone;
Priority currPriority = none;
time_t dueDate;
Visibility currVisibility = NotVisible;
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);
void setVisibility(Visibility newVisibility);
};
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
int getNumOfTasks(); // Returns number of tasks in taskList
int getNumOfVisibleTasks(); // Returns number of tasks in taskList
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
std::vector<Task> viewTaskListByVisiblity(Visiblity v); // Returns list of tasks filtered by visilbity, empty list if none visible
};
@ameryisafreeelf
Copy link
Author

I definitely feel that I've fallen into a bit of a trap here. The idea of having to search every User's List(s) to find matching Task name does not seem like a bug to me, but it does seem at least very slow. Further, since this feature request asks to display the total number of items in the List currently being viewed, I don't feel that my current design strongly captures the notion of whether or not a List is currently being viewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment