Advertisement
pleasedontcode

**Task Tracker** rev_01

Dec 14th, 2024
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: **Task Tracker**
  13.     - Source Code NOT compiled for: Arduino Uno
  14.     - Source Code created on: 2024-12-15 05:40:02
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Design a simple task management system that will */
  21.     /* allow the user to manage their daily tasks. The */
  22.     /* program will present the user with options to:  • */
  23.     /* Add new tasks  • Mark tasks as complete  • View */
  24.     /* their task list, with completed tasks clearly */
  25.     /* marked. */
  26. /****** END SYSTEM REQUIREMENTS *****/
  27.  
  28. /* START CODE */
  29.  
  30. /****** DEFINITION OF LIBRARIES *****/
  31. #include <Wire.h>  // Include Wire library for I2C
  32. #include <SPI.h>   // Include SPI library for SPI communication
  33. #include <Servo.h> // Include Servo library for controlling servos
  34.  
  35. /****** FUNCTION PROTOTYPES *****/
  36. void setup(void);
  37. void loop(void);
  38. void addTask(String task);
  39. void markTaskComplete(int taskIndex);
  40. void viewTasks();
  41.  
  42. /****** GLOBAL VARIABLES *****/
  43. const int MAX_TASKS = 10; // Maximum number of tasks
  44. String tasks[MAX_TASKS];   // Array to store tasks
  45. bool taskCompleted[MAX_TASKS]; // Array to track completed tasks
  46. int taskCount = 0; // Current number of tasks
  47.  
  48. void setup(void)
  49. {
  50.     // Initialize serial communication for debugging
  51.     Serial.begin(9600);
  52.     Serial.println("Task Management System Initialized");
  53. }
  54.  
  55. void loop(void)
  56. {
  57.     // Simulate adding tasks and marking them complete
  58.     addTask("Task 1");
  59.     addTask("Task 2");
  60.     markTaskComplete(0); // Mark Task 1 as complete
  61.     viewTasks(); // View the current list of tasks
  62.  
  63.     delay(5000); // Delay for demonstration purposes
  64. }
  65.  
  66. // Function to add a new task
  67. void addTask(String task) {
  68.     if (taskCount < MAX_TASKS) {
  69.         tasks[taskCount] = task;
  70.         taskCompleted[taskCount] = false; // Task is initially not completed
  71.         taskCount++;
  72.         Serial.println("Added: " + task);
  73.     } else {
  74.         Serial.println("Task list is full. Cannot add more tasks.");
  75.     }
  76. }
  77.  
  78. // Function to mark a task as complete
  79. void markTaskComplete(int taskIndex) {
  80.     if (taskIndex >= 0 && taskIndex < taskCount) {
  81.         taskCompleted[taskIndex] = true;
  82.         Serial.println("Marked task " + String(taskIndex) + " as complete.");
  83.     } else {
  84.         Serial.println("Invalid task index.");
  85.     }
  86. }
  87.  
  88. // Function to view all tasks
  89. void viewTasks() {
  90.     Serial.println("Current Tasks:");
  91.     for (int i = 0; i < taskCount; i++) {
  92.         String status = taskCompleted[i] ? " [Completed]" : " [Pending]";
  93.         Serial.println(String(i) + ": " + tasks[i] + status);
  94.     }
  95. }
  96.  
  97. /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement