diff --git a/53-TechTitans/.classpath b/53-TechTitans/.classpath new file mode 100644 index 0000000..cdb4ef0 --- /dev/null +++ b/53-TechTitans/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/53-TechTitans/.project b/53-TechTitans/.project new file mode 100644 index 0000000..149781b --- /dev/null +++ b/53-TechTitans/.project @@ -0,0 +1,28 @@ + + + TaskManager + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + + + 1714473260680 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/53-TechTitans/.settings/org.eclipse.core.resources.prefs b/53-TechTitans/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 0000000..4824b80 --- /dev/null +++ b/53-TechTitans/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/53-TechTitans/.settings/org.eclipse.jdt.core.prefs b/53-TechTitans/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..d6b935f --- /dev/null +++ b/53-TechTitans/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,14 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=18 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=18 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning +org.eclipse.jdt.core.compiler.release=enabled +org.eclipse.jdt.core.compiler.source=18 diff --git a/53-TechTitans/README.md b/53-TechTitans/README.md new file mode 100644 index 0000000..b49c12f --- /dev/null +++ b/53-TechTitans/README.md @@ -0,0 +1,33 @@ +Task Manager GUI +The Task Manager GUI is a Java application designed to help users manage their tasks effectively. It provides a graphical user interface (GUI) for adding, viewing, and deleting tasks, along with displaying task details such as title, description, and deadline. + +Features +Add Task: Users can add new tasks by providing a title, description, and deadline in the specified format (dd/MM/yyyy HH:mm). +View Tasks: Users can view all added tasks sorted by their deadlines.The task which is to be done first is displayed first based on the deadline. Tasks are displayed in a text area within the GUI. +Delete Task: Users can select and delete tasks from the list. Tasks are deleted based on their titles. + + +Tools andTechniques used +ArrayList: Used to store the tasks added by the user. The ArrayList allows for dynamic resizing and efficient storage and retrieval of task objects. +Date: Utilized to represent task deadlines. Dates are parsed and formatted using the SimpleDateFormat class, ensuring consistency and compatibility with user input and display. +JTextArea: Used to display tasks within the GUI. The JTextArea component provides a scrollable text area for presenting task details to the user. +JScrollPane: Incorporated to enable scrolling functionality within the JTextArea when the number of tasks exceeds the visible area, ensuring a seamless user experience. +Custom Comparator: Implemented a custom comparator (TaskComparator) to sort tasks based on their deadlines. This comparator is used in conjunction with Collections.sort() to maintain tasks in ascending order of deadlines. + + +Requirements +Java Development Kit (JDK) +Java Swing library for GUI components +Video Link +https://drive.google.com/file/d/19CG9PDrTrxDTZPwUtqw-EiJAGBzpJ2y3/view?usp=sharing + + + + + + +15 Day Report 1: +https://docs.google.com/document/d/12FsSRyhOI-NnVypT2zaPgVI-l46HSBTjMBG_fGUeczg/edit?usp=sharing + +15 Day Report 2: +https://docs.google.com/document/d/16XrLwLSu-Wkn_sPkGkDTiV9RffEM6ZMwkeWE_xL0a1Q/edit?usp=sharing diff --git a/53-TechTitans/bin/Task.class b/53-TechTitans/bin/Task.class new file mode 100644 index 0000000..248194d Binary files /dev/null and b/53-TechTitans/bin/Task.class differ diff --git a/53-TechTitans/bin/TaskComparator.class b/53-TechTitans/bin/TaskComparator.class new file mode 100644 index 0000000..fe36eec Binary files /dev/null and b/53-TechTitans/bin/TaskComparator.class differ diff --git a/53-TechTitans/bin/TaskManagerGUI$1.class b/53-TechTitans/bin/TaskManagerGUI$1.class new file mode 100644 index 0000000..c2a2a26 Binary files /dev/null and b/53-TechTitans/bin/TaskManagerGUI$1.class differ diff --git a/53-TechTitans/bin/TaskManagerGUI$2.class b/53-TechTitans/bin/TaskManagerGUI$2.class new file mode 100644 index 0000000..c1bea1b Binary files /dev/null and b/53-TechTitans/bin/TaskManagerGUI$2.class differ diff --git a/53-TechTitans/bin/TaskManagerGUI$3.class b/53-TechTitans/bin/TaskManagerGUI$3.class new file mode 100644 index 0000000..4fd3af3 Binary files /dev/null and b/53-TechTitans/bin/TaskManagerGUI$3.class differ diff --git a/53-TechTitans/bin/TaskManagerGUI$4.class b/53-TechTitans/bin/TaskManagerGUI$4.class new file mode 100644 index 0000000..ffafa56 Binary files /dev/null and b/53-TechTitans/bin/TaskManagerGUI$4.class differ diff --git a/53-TechTitans/bin/TaskManagerGUI.class b/53-TechTitans/bin/TaskManagerGUI.class new file mode 100644 index 0000000..1b72339 Binary files /dev/null and b/53-TechTitans/bin/TaskManagerGUI.class differ diff --git a/53-TechTitans/src/TaskManagerGUI.java b/53-TechTitans/src/TaskManagerGUI.java new file mode 100644 index 0000000..55eefdd --- /dev/null +++ b/53-TechTitans/src/TaskManagerGUI.java @@ -0,0 +1,164 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Date; + +public class TaskManagerGUI extends JFrame { + private ArrayList tasks; + private JTextArea taskTextArea; + + public TaskManagerGUI() { + tasks = new ArrayList<>(); + + setTitle("Task Manager"); + setSize(400, 300); + setDefaultCloseOperation(EXIT_ON_CLOSE); + + JPanel mainPanel = new JPanel(); + mainPanel.setLayout(new BorderLayout()); + + taskTextArea = new JTextArea(); + JScrollPane scrollPane = new JScrollPane(taskTextArea); + mainPanel.add(scrollPane, BorderLayout.CENTER); + + JPanel buttonPanel = new JPanel(); + buttonPanel.setLayout(new FlowLayout()); + + JButton addButton = new JButton("Add Task"); + addButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + addTask(); + } + }); + + JButton viewButton = new JButton("View Tasks"); + viewButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + viewTasks(); + } + }); + + JButton deleteButton = new JButton("Delete Task"); + deleteButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + deleteTask(); + } + }); + + buttonPanel.add(addButton); + buttonPanel.add(viewButton); + buttonPanel.add(deleteButton); + + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + + add(mainPanel); + setVisible(true); + } + + private void addTask() { + String title = JOptionPane.showInputDialog("Enter task title:"); + String description = JOptionPane.showInputDialog("Enter task description:"); + String deadlineStr = JOptionPane.showInputDialog("Enter task deadline (format: dd/MM/yyyy HH:mm):"); + + SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm"); + Date deadline; + try { + deadline = dateFormat.parse(deadlineStr); + } catch (ParseException e) { + JOptionPane.showMessageDialog(this, "Invalid date format! Please enter in the format: dd/MM/yyyy HH:mm"); + return; + } + + Task newTask = new Task(title, description, deadline); + tasks.add(newTask); + Collections.sort(tasks, new TaskComparator()); // Sort tasks based on priority + taskTextArea.append("Task added successfully!\n"); + } + + private void viewTasks() { + if (tasks.isEmpty()) { + taskTextArea.setText("No tasks to display."); + } else { + taskTextArea.setText(""); + for (Task task : tasks) { + taskTextArea.append(task.toString() + "\n"); + } + } + } + + private void deleteTask() { + if (tasks.isEmpty()) { + JOptionPane.showMessageDialog(this, "No tasks to delete."); + } else { + String[] taskTitles = new String[tasks.size()]; + for (int i = 0; i < tasks.size(); i++) { + taskTitles[i] = tasks.get(i).getTitle(); + } + String selectedTitle = (String) JOptionPane.showInputDialog(this, "Select task to delete:", + "Delete Task", JOptionPane.PLAIN_MESSAGE, null, taskTitles, taskTitles[0]); + if (selectedTitle != null) { + for (Task task : tasks) { + if (task.getTitle().equals(selectedTitle)) { + tasks.remove(task); + taskTextArea.append("Task '" + selectedTitle + "' deleted successfully!\n"); + return; + } + } + } + } + } + + public static void main(String[] args) { + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + new TaskManagerGUI(); + } + }); + } +} + +class Task { + private String title; + private String description; + private Date deadline; + + public Task(String title, String description, Date deadline) { + this.title = title; + this.description = description; + this.deadline = deadline; + } + + public String getTitle() { + return title; + } + + public String getDescription() { + return description; + } + + public Date getDeadline() { + return deadline; + } + + @Override + public String toString() { + return "Title: " + title + ", Description: " + description + ", Deadline: " + deadline; + } +} + +class TaskComparator implements Comparator { + @Override + public int compare(Task t1, Task t2) { + return t1.getDeadline().compareTo(t2.getDeadline()); + } +}