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

[nihalzp] iP #61

Open
wants to merge 65 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
da9144b
Rename bot and implement basic greet, exit
nihalzp Aug 27, 2023
75be7ce
Echo the user given command, exit when "bye"
nihalzp Sep 4, 2023
afc511c
Add indentation to responses
nihalzp Sep 4, 2023
332b3f4
Add Python ASCII art
nihalzp Sep 4, 2023
1ebb2bf
Add Python emoji before response
nihalzp Sep 4, 2023
111d8a1
Store commands and display if requested
nihalzp Sep 4, 2023
0093f07
Add task class
nihalzp Sep 4, 2023
8f17b24
Allow mark and unmark of tasks
nihalzp Sep 4, 2023
4cf5d1e
Rename taskList to tasks
nihalzp Sep 4, 2023
7e8e63a
Format and change var names to match Java standards
nihalzp Sep 4, 2023
875d4bb
Add Todo class
nihalzp Sep 6, 2023
dca8d87
Add toString method to task class
nihalzp Sep 14, 2023
bbb2a75
Implement Todo class
nihalzp Sep 14, 2023
a08b038
Implement Deadline class
nihalzp Sep 14, 2023
d0b678e
Implement Deadline class toString method
nihalzp Sep 14, 2023
ec7a82d
Implement Event class
nihalzp Sep 14, 2023
0591c0f
Integrate Todo, Deadline, Event class into chatbot
nihalzp Sep 14, 2023
846bfbf
Remove trailing spaces from Ascii art
nihalzp Sep 14, 2023
dd17203
Add input and expected behaviour of the bot
nihalzp Sep 14, 2023
16606ac
Use all capitals for constant variables
nihalzp Sep 14, 2023
2847381
Change method name to getDone
nihalzp Sep 14, 2023
2ee7cc7
Use constant variables for command names
nihalzp Sep 14, 2023
edcb499
Use newlines to keep coherent blocks together
nihalzp Sep 14, 2023
8235ebc
Add some comments
nihalzp Sep 14, 2023
16258c4
Make Task class abstract
nihalzp Sep 14, 2023
54707ec
Catch exceptions and respond for unexpected input
nihalzp Sep 14, 2023
c60023a
Fix typo in Duke
nihalzp Sep 14, 2023
652ef28
Update input.txt and EXPECTED.TXT
nihalzp Sep 14, 2023
0a328b0
Merging branch-Level-5 into master
nihalzp Sep 14, 2023
a45995b
Rename Duke to Python
nihalzp Sep 18, 2023
a35adec
Organize files into packages
nihalzp Sep 18, 2023
6ce1ada
Update the path in runtest.sh
nihalzp Sep 18, 2023
000bb2e
Merge branch-A-Packages into master
nihalzp Sep 18, 2023
96f5be8
Use String.repeat instead of Arrays.fill
nihalzp Sep 18, 2023
938cdb0
Change method name from getDone() to isDone()
nihalzp Sep 18, 2023
085f7ec
Use Em Dash for horizontal line
nihalzp Sep 18, 2023
cabb00d
Fix path in runtest.sh
nihalzp Sep 18, 2023
8dd6c03
Add support for deleting tasks
nihalzp Sep 18, 2023
0960bfb
Add tests for delete feature
nihalzp Sep 18, 2023
1d7a30b
Implement task details format method for file saving
nihalzp Sep 18, 2023
4ea6ed5
Save tasks after each change to task lists
nihalzp Sep 18, 2023
3c1dc3c
Use type icon constant variable
nihalzp Sep 18, 2023
9141ff6
Add support for loading tasks from file
nihalzp Sep 18, 2023
d6ebb8f
Merge branch-Level-6 into master
nihalzp Sep 18, 2023
efa847a
Merge branch-Level-7 into master
nihalzp Sep 18, 2023
6dbf985
Save tasks to file after delete command
nihalzp Sep 18, 2023
5d81533
Ignore data folder
nihalzp Sep 18, 2023
1e4f784
Use lower case for directory names
nihalzp Oct 5, 2023
e6fb515
Update text-ui-test input and expected text
nihalzp Oct 5, 2023
19bf31a
Add Command class
nihalzp Oct 6, 2023
d34035c
Add Message class
nihalzp Oct 6, 2023
e13479b
Add Parser class
nihalzp Oct 6, 2023
e995cc5
Add Exception class
nihalzp Oct 6, 2023
7bbab3b
Add TaskList class
nihalzp Oct 6, 2023
4a3c6b7
Add Ui class
nihalzp Oct 6, 2023
c84f7dc
Refactor Python.java for more oop
nihalzp Oct 6, 2023
dd0cf10
Update text-ui-testing
nihalzp Oct 6, 2023
ae0c242
Add support for finding tasks
nihalzp Oct 6, 2023
dd55af9
Add manifest.mf
nihalzp Oct 6, 2023
cf0307f
Merge pull request #1 from nihalzp/branch-Level-9
nihalzp Oct 6, 2023
1dab8c7
Add JavaDoc comments
nihalzp Oct 6, 2023
85589ff
Merge pull request #2 from nihalzp/branch-A-JavaDoc
nihalzp Oct 6, 2023
f61a1b9
Add user guide
nihalzp Oct 6, 2023
4d7bdfb
Reorder and fix formatting
nihalzp Oct 6, 2023
3218369
Do not print task count at start
nihalzp 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ bin/

/text-ui-test/ACTUAL.TXT
text-ui-test/EXPECTED-UNIX.TXT

# Data files
/data/
109 changes: 94 additions & 15 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,108 @@
# User Guide
# Python User Guide

**Python** task manager will be a blessing for users with fast typing speed. You can
add three types of tasks, mark tasks as completed, delete tasks, and if necessary
find tasks using a keyword!

## Features
Python comes with the following core features:
* [Add Todo](#add-todo)
* [Add Deadline](#add-deadline)
* [Add Event](#add-event)
* [Mark Task](#mark-task)
* [Unmark Task](#unmark-task)
* [Delete Task](#delete-task)
* [Find Tasks](#find-tasks)
* [List Tasks](#list-tasks)
* [Exit](#exit-program)

### Add Todo
Format:
`todo [todo description]`

Example of usage:
`todo buy groceries`

Add a simple todo!

### Add Deadline

Format:
`deadline [deadline description] /by [due date]`

Example of usage:
`deadline lab 2 /by friday night`

Add a deadline with due date!


### Add Event

Format:
`event [event description] /from [start date] /to [end date]`

Example of usage:
`event math exam /from monday 2pm /to monday 4pm`

Add an event to keep track of both start and end times of an activity!

### Mark Task

Format:
`mark [index of the task - 1 based]`

Example of usage:
`mark 1`

Mark the task at index as done!

### Unmark Task

Format:
`unmark [index of the task - 1 based]`

Example of usage:
`unmark 1`

Unmark the task at index as not done yet!

### Delete Task

Format:
`delete [index of the task - 1 based]`

Example of usage:
`delete 1`

Delete the task at the index!

### Find Tasks

### Feature-ABC
Format:
`find [keyword]`

Description of the feature.
Example of usage:
`find exam`

### Feature-XYZ
List the tasks that contains the keyword in the description!

Description of the feature.
### List Tasks

## Usage
Format:
`list`

### `Keyword` - Describe action
Example of usage:
`list`

Describe the action and its outcome.
List all the tasks along with completion status and task type!

Example of usage:
### Exit Program

`keyword (optional arguments)`
Format:
`bye`

Expected outcome:
Example of usage:
`bye`

Description of the outcome.
Greet Python 'bye' to exit the program!

```
expected output
```
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

3 changes: 3 additions & 0 deletions src/main/java/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: python.Python

21 changes: 21 additions & 0 deletions src/main/java/python/Python.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package python;

import python.exception.PythonException;
import python.ui.Ui;

public class Python {
static final private Ui ui = new Ui();

public static void main(String[] args) {
ui.welcomeUser();
do {
ui.getUserInput();
try {
ui.parseLine();
ui.executeLine();
} catch (PythonException e) {
ui.displayException(e);
}
} while (!ui.isExit());
}
}
7 changes: 7 additions & 0 deletions src/main/java/python/exception/PythonException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package python.exception;

public class PythonException extends Exception {
public PythonException(String errorMessage) {
super(errorMessage);
}
}
26 changes: 26 additions & 0 deletions src/main/java/python/parser/Command.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package python.parser;

/**
* Defines the commands expected from the user
*/
public class Command {
public static final String COMMAND_BYE = "bye";
public static final String COMMAND_LIST = "list";
public static final String COMMAND_MARK = "mark";
public static final String COMMAND_UNMARK = "unmark";
public static final String COMMAND_DELETE = "delete";
public static final String COMMAND_TODO = "todo";
public static final String COMMAND_DEADLINE = "deadline";
public static final String COMMAND_EVENT = "event";
public static final String COMMAND_FIND = "find";

/**
* Returns whether the given command is "bye" command or not
*
* @param command The command to check
* @return Returns whether the given command is "bye" command or not
*/
public static boolean isCommandBye(String command) {
return (command.equals(COMMAND_BYE));
}
}
126 changes: 126 additions & 0 deletions src/main/java/python/parser/Parser.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package python.parser;

/**
* Contains utility functions for parsing of raw input given by the user. All classes here are static
*/
public class Parser {
/**
* Returns the first word as command
*
* @param inputLine The raw user input
* @return Returns the first word as command
*/
public static String extractCommandFromInputLine(String inputLine) {
return inputLine.split("\\s+")[0];
}

/**
* Returns the rest of the sentence excluding the first word
*
* @param inputLine The raw user input
* @return Returns the rest of the sentence excluding the first word
*/
public static String extractCommandDescFromInputLine(String inputLine) {
return inputLine.split(" ", 2)[1];
}

/**
* Returns the second word as integer
*
* @param inputLine The raw user input
* @return Returns the second word as integer
*/
public static int extractTaskNoFromInputLine(String inputLine) {
return Integer.parseInt(inputLine.split(" ")[1]);
}

/**
* Returns the second word as keyword
*
* @param inputLine The raw user input
* @return Returns the second word as keyword
*/
public static String extractKeywordFromInputLine(String inputLine) {
return inputLine.split(" ")[1];
}

/**
* Returns the rest of the sentence excluding the first word
*
* @param inputLine The raw user input
* @return Returns the rest of the sentence excluding the first word
*/
public static String extractTodoDescFromInputLine(String inputLine) {
return inputLine.split(" ", 2)[1];
}

/**
* Returns the rest of the sentence excluding the first word
*
* @param inputLine The raw user input
* @return Returns the rest of the sentence excluding the first word
*/
public static String extractDeadlineDetailsFromInputLine(String inputLine) {
return inputLine.split(" ", 2)[1];
}

/**
* Returns the text after the first word
*
* @param deadlineDetails The deadline details
* @return Returns the text after the first word
*/
public static String extractDeadlineDescFromDeadlineDetails(String deadlineDetails) {
return deadlineDetails.split(" /by ")[0];
}

/**
* Returns the text after the /by command
*
* @param deadlineDetails The deadline details
* @return Returns the text after the /by command
*/
public static String extractDeadlineByFromDeadlineDetails(String deadlineDetails) {
return deadlineDetails.split(" /by ")[1];
}

/**
* Returns the rest of the sentence excluding the first word
*
* @param inputLine The raw user input
* @return Returns the rest of the sentence excluding the first word
*/
public static String extractEventDetailsFromInputLine(String inputLine) {
return inputLine.split(" ", 2)[1];
}

/**
* Returns the sentence before /from
*
* @param eventDetails The event details
* @return Returns the sentence before /from
*/
public static String extractEventDescFromEventDetails(String eventDetails) {
return eventDetails.split("\\s+/from\\s+|\\s+/to\\s+", 3)[0];
}

/**
* Returns the sentence after /from and before /to
*
* @param eventDetails The event details
* @return Returns the sentence after /from and before /to
*/
public static String extractEventFromFromEventDetails(String eventDetails) {
return eventDetails.split("\\s+/from\\s+|\\s+/to\\s+", 3)[1];
}

/**
* Returns the sentence after /to
*
* @param eventDetails The event details
* @return Returns the sentence after /to
*/
public static String extractEventToFromEventDetails(String eventDetails) {
return eventDetails.split("\\s+/from\\s+|\\s+/to\\s+", 3)[2];
}
}
49 changes: 49 additions & 0 deletions src/main/java/python/task/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package python.task;

/**
* Represents a deadline object using due date
*/
public class Deadline extends Task {
final static private String TYPE_ICON = "[D]";
private String by;

/**
* Constructs <code>Deadline</code> object
*
* @param description The description of the task
* @param by The due datetime
*/
public Deadline(String description, String by) {
super(description);
this.by = by;
}

/**
* Returns the type icon of deadline
*
* @return Returns the type icon of deadline
*/
@Override
public String getTypeIcon() {
return TYPE_ICON;
}

/**
* Returns the due datetime of deadline
*
* @return Returns the due datetime of deadline
*/
public String getBy() {
return by;
}

/**
* Returns a human-readable string format
*
* @return Returns a human-readable string format
*/
@Override
public String toString() {
return super.toString() + " (by: " + getBy() + ")";
}
}
Loading