Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Barbaracwx] iP #67

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
999081b
Change name of bot
Barbaracwx Aug 31, 2023
c129070
commit echo
Barbaracwx Sep 4, 2023
23d1e0e
commit level 2: add, list
Barbaracwx Sep 4, 2023
182f0f5
commit level 3: mark as done
Barbaracwx Sep 4, 2023
69a4ae4
commit coding standard
Barbaracwx Sep 4, 2023
8842184
commint Level 4. ToDos, Events, Deadlines
Barbaracwx Sep 6, 2023
f824dfe
commit: improve code quality
Barbaracwx Sep 8, 2023
70ba578
add increment as a branch, level 5
Barbaracwx Sep 15, 2023
0894d39
Merge branch 'branch-Level-5'
Barbaracwx Sep 15, 2023
a0f798a
Organize classes into the 'duke' package
Barbaracwx Sep 15, 2023
2987979
Merge branch 'branch-A-Packages'
Barbaracwx Sep 15, 2023
9beff6f
Implement Level-6
Barbaracwx Sep 20, 2023
786c27b
Implement Level-7
Barbaracwx Sep 22, 2023
327d3d4
Merge branch 'branch-Level-6'
Barbaracwx Sep 22, 2023
5fe3f31
Implement Level-7
Barbaracwx Sep 22, 2023
9e14e1d
Added A-jar level
Barbaracwx Sep 22, 2023
d2ed96a
commit updated changes
Barbaracwx Sep 28, 2023
6425ae4
Implement A-Exceptions Tag
Barbaracwx Sep 28, 2023
2423d8a
level 5
Barbaracwx Sep 28, 2023
ef461a8
implemented A-Collections Tag
Barbaracwx Sep 28, 2023
36a4072
Merge branch 'branch-Level-7'
Barbaracwx Sep 28, 2023
36a6f2b
commit added parser,command, tasklist and ui class
Barbaracwx Oct 2, 2023
98a143a
Implement find
Barbaracwx Oct 2, 2023
87b9da0
Merge pull request #1 from Barbaracwx/branch-Level-9
Barbaracwx Oct 2, 2023
4df8bd3
Added JavaDoc comments
Barbaracwx Oct 3, 2023
6d2c93b
Merge pull request #2 from Barbaracwx/branch-A-JavaDoc
Barbaracwx Oct 3, 2023
139e288
Organised code
Barbaracwx Oct 3, 2023
dd53bc2
change name of file
Barbaracwx Oct 3, 2023
b073a6f
organised files
Barbaracwx Oct 3, 2023
b913271
Update README.md
Barbaracwx Oct 3, 2023
a58e292
Update README.md
Barbaracwx Oct 3, 2023
c03627a
Update README.md
Barbaracwx Oct 3, 2023
8b10039
Update README.md
Barbaracwx Oct 3, 2023
fc929e4
Update README.md
Barbaracwx Oct 3, 2023
2976ed5
Update README.md
Barbaracwx Oct 3, 2023
2bc67ee
Update README.md
Barbaracwx Oct 3, 2023
3f173b3
Update README.md
Barbaracwx Oct 3, 2023
7437537
Update README.md
Barbaracwx Oct 3, 2023
64ef5a1
Update README.md
Barbaracwx Oct 3, 2023
a1a8f04
Update README.md
Barbaracwx Oct 3, 2023
3f61c50
Update README.md
Barbaracwx Oct 3, 2023
f7d6c25
Added user guide
Barbaracwx Oct 5, 2023
b2c8537
Merge branch 'master' of https://github.com/Barbaracwx/ip
Barbaracwx Oct 5, 2023
a480276
Edited code
Barbaracwx Oct 6, 2023
db152b1
Updated code
Barbaracwx Oct 6, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added JavaDoc comments
Barbaracwx committed Oct 3, 2023
commit 4df8bd354d61308e9ae8f5bdebf276a5d1601a5a
9 changes: 6 additions & 3 deletions dukeData.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
T | false | borrow book
D | true | buy book /by 8 november | 8 november
E | false | meet caleb /from fgbd /to 7iksudf | fgbd | 7iksudf
T | false | mark 1
T | false | buy book
E | false | meet caleb /from 4 to /9 | No Start Date | No End Date
E | false | meet caleb /from 8 nov /to 9 | 8 nov | 9
D | false | ksfgb /by kjsdbf | kjsdbf
E | false | skjfbg /from kfjgb /to | kfjgb |
27 changes: 22 additions & 5 deletions src/main/java/duke/AddCommand.java
Original file line number Diff line number Diff line change
@@ -2,24 +2,41 @@

import java.util.ArrayList;

/**
* Represents a command to add a task to the task list.
*/
public class AddCommand implements Command {
private final String input;

/**
* Constructs an AddCommand with the given input.
*
* @param input The input string representing the task to be added.
*/
public AddCommand(String input) {
this.input = input;
}

/**
* Executes the AddCommand by adding the task to the task list.
*
* @param tasks The list of tasks.
* @param ui The user interface.
* @param storage The storage manager.
* @throws DukeException If an error occurs during task addition.
*/
@Override
public void execute(ArrayList<Task> tasks, Ui ui, Storage storage) throws DukeException {
TaskList.addTaskToList(input, tasks);
}

/**
* Indicates whether this command triggers program exit.
*
* @return False because this command does not indicate program exit.
*/
@Override
public boolean isExit() {
return false; // This command does not indicate program exit
return false;
}

}



19 changes: 19 additions & 0 deletions src/main/java/duke/Command.java
Original file line number Diff line number Diff line change
@@ -2,7 +2,26 @@

import java.util.ArrayList;

/**
* The Command interface represents an action that can be executed by Duke.
* Implementing classes should define the behavior of the execute method.
*/
public interface Command {

/**
* Executes the command with the given parameters.
*
* @param tasks The list of tasks.
* @param ui The user interface.
* @param storage The storage manager.
* @throws DukeException If an error occurs during command execution.
*/
void execute(ArrayList<Task> tasks, Ui ui, Storage storage) throws DukeException;

/**
* Checks if this command indicates program exit.
*
* @return True if the command indicates program exit, false otherwise.
*/
boolean isExit();
}
Binary file removed src/main/java/duke/DeadlineTask.class
Binary file not shown.
38 changes: 30 additions & 8 deletions src/main/java/duke/DeadlineTask.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,48 @@
package duke;

/**
* Represents a task with a deadline, which is a subclass of Task.
*/
public class DeadlineTask extends Task {
private final String by;

/**
* Constructs a DeadlineTask with the given description.
*
* @param description The description of the task, including the deadline (if provided).
*/
public DeadlineTask(String description) {
super(description);
this.by = this.extractDeadline(description);
}


private String extractDeadline(String var1) {
int var2 = var1.indexOf("/by");
return var2 != -1 ? var1.substring(var2 + 3).trim() : "No Deadline";
/**
* Extracts the deadline from the task description.
*
* @param description The description of the task.
* @return The extracted deadline or "No Deadline" if not found.
*/
private String extractDeadline(String description) {
int index = description.indexOf("/by");
return index != -1 ? description.substring(index + 3).trim() : "No Deadline";
}

/**
* Gets the deadline associated with this task.
*
* @return The deadline string.
*/
public String getBy() {
return by;
}

/**
* Returns a string representation of the DeadlineTask.
*
* @return A string representation in the format: "[D][TaskDescription] (by: [Deadline])".
*/
public String toString() {
String var1 = super.toString();
return "[D]" + var1 + " (by: " + this.by + ")";
String superString = super.toString();
return "[D]" + superString + " (by: " + this.by + ")";
}

}
}
28 changes: 23 additions & 5 deletions src/main/java/duke/DeleteCommand.java
Original file line number Diff line number Diff line change
@@ -2,23 +2,41 @@

import java.util.ArrayList;

/**
* Represents a command to delete a task from the task list.
*/
public class DeleteCommand implements Command {
private final String input;

/**
* Constructs a DeleteCommand with the given input.
*
* @param input The input string representing the task to be deleted.
*/
public DeleteCommand(String input) {
this.input = input;
}

/**
* Executes the DeleteCommand by deleting the task from the task list.
*
* @param tasks The list of tasks.
* @param ui The user interface.
* @param storage The storage manager.
* @throws DukeException If an error occurs during task deletion.
*/
@Override
public void execute(ArrayList<Task> tasks, Ui ui, Storage storage) throws DukeException {
TaskList.deleteTask(input, tasks); // Call the modified deleteTask method with the task index
TaskList.deleteTask(input, tasks);
}

/**
* Indicates whether this command triggers program exit.
*
* @return False because this command does not indicate program exit.
*/
@Override
public boolean isExit() {
return false; // This command does not indicate program exit
return false;
}

}


Binary file removed src/main/java/duke/Duke.class
Binary file not shown.
39 changes: 22 additions & 17 deletions src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
package duke;

import java.util.ArrayList;
import java.util.Scanner;
import java.io.IOException;
import java.util.ArrayList;


import duke.DeadlineTask;
import duke.EventTask;
import duke.DukeException;
import duke.TasksHandler;
import duke.TodoTask;
import duke.Ui;
import duke.TaskList;
import duke.Storage;
//import the rest

/**
* Duke is a task management program that allows users to manage their tasks.
* It provides functionality for adding, deleting, and listing tasks.
*/
public class Duke {
private Ui ui;
private TaskList tasks;
private Storage storage;


/**
* Constructs a Duke instance with the specified file path.
*
* @param filePath The path to the file used for task storage.
* @throws DukeException If there is an issue initializing Duke.
*/
public Duke(String filePath) throws DukeException {
ui = new Ui();
storage = new Storage(filePath);
@@ -32,6 +29,9 @@ public Duke(String filePath) throws DukeException {
}
}

/**
* Runs the Duke program, handling user input and executing commands.
*/
public void run() {
ui.printWelcomeMessage();
boolean isExit = false;
@@ -52,9 +52,14 @@ public void run() {
}
}

/**
* The main entry point for running the Duke program.
*
* @param args The command-line arguments (not used in this program).
* @throws IOException If an I/O error occurs.
* @throws DukeException If there is an issue with Duke initialization.
*/
public static void main(String[] args) throws IOException, DukeException {
new Duke("data/tasks.txt").run();
}


}
}
Binary file removed src/main/java/duke/DukeException.class
Binary file not shown.
10 changes: 9 additions & 1 deletion src/main/java/duke/DukeException.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@

package duke;

/**
* DukeException is a custom exception class used to represent exceptions specific to the Duke program.
*/
public class DukeException extends Exception {

/**
* Constructs a DukeException with the specified error message.
*
* @param message The error message associated with the exception.
*/
public DukeException(String message) {
super(message);
}
Binary file removed src/main/java/duke/EventTask.class
Binary file not shown.
49 changes: 40 additions & 9 deletions src/main/java/duke/EventTask.java
Original file line number Diff line number Diff line change
@@ -1,45 +1,76 @@
package duke;

/**
* Represents a task that is an event, which is a subclass of Task.
*/
public class EventTask extends Task {
private final String from;
private final String to;

/**
* Constructs an EventTask with the given description.
*
* @param description The description of the event task, including start and end dates (if provided).
*/
public EventTask(String description) {
super(description);
this.from = this.extractFromDate(description);
this.to = this.extractToDate(description);
}

// Extract the /from date
/**
* Extracts the start date from the task description.
*
* @param description The description of the event task.
* @return The extracted start date or "No Start Date" if not found.
*/
private String extractFromDate(String description) {
int fromIndex = description.indexOf("/from");
if (fromIndex != -1) {
int byIndex = description.indexOf("/to");
if (byIndex != -1 && byIndex > fromIndex) {
return description.substring(fromIndex + 5, byIndex).trim();
int toIndex = description.indexOf("/to");
if (toIndex != -1 && toIndex > fromIndex) {
return description.substring(fromIndex + 5, toIndex).trim();
}
}

return "No Start Date";
}

//Extract the /to date
/**
* Extracts the end date from the task description.
*
* @param description The description of the event task.
* @return The extracted end date or "No End Date" if not found.
*/
private String extractToDate(String description) {
int toIndex = description.indexOf("/to");
return toIndex != -1 ? description.substring(toIndex + 3).trim() : "No End Date";
}

/**
* Gets the start date of the event.
*
* @return The start date string.
*/
public String getFrom() {
return from;
}

/**
* Gets the end date of the event.
*
* @return The end date string.
*/
public String getTo() {
return to;
}

/**
* Returns a string representation of the EventTask.
*
* @return A string representation in the format: "[E][TaskDescription] (from: [Start Date] to: [End Date])".
*/
public String toString() {
String var10000 = super.toString();
return "[E]" + var10000 + " (from: " + this.from + " to: " + this.to + ")";
String superString = super.toString();
return "[E]" + superString + " (from: " + this.from + " to: " + this.to + ")";
}
}

21 changes: 18 additions & 3 deletions src/main/java/duke/ExitCommand.java
Original file line number Diff line number Diff line change
@@ -2,16 +2,31 @@

import java.util.ArrayList;

// ExitCommand class for handling the "bye" command
/**
* Represents a command to exit the Duke program.
* The "bye" command is used to terminate the program.
*/
public class ExitCommand implements Command {

/**
* Executes the ExitCommand by displaying a farewell message.
*
* @param tasks The list of tasks (not used in this command).
* @param ui The user interface.
* @param storage The storage manager (not used in this command).
*/
@Override
public void execute(ArrayList<Task> tasks, Ui ui, Storage storage) {
ui.printByeMessage();
}

/**
* Checks if this command indicates program exit.
*
* @return True because this command indicates program exit.
*/
@Override
public boolean isExit() {
return true; // This command indicates program exit
return true;
}
}

Loading