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

[Cheng Tze Ning] iP #67

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
be01343
Change duke to greet
tzzzening Jan 21, 2020
fbf3a39
Add String "Duke"
tzzzening Jan 30, 2020
1c27416
Add checked items on list
tzzzening Jan 31, 2020
a33dfcd
Add Level 4 increment
tzzzening Feb 3, 2020
a542137
Touch up Level 4 increment
tzzzening Feb 6, 2020
26b35eb
Neaten "if else" conditions
tzzzening Feb 6, 2020
dad0e8a
Change conditional statements to "startsWith" string method
tzzzening Feb 9, 2020
da534c2
Throw exceptions
tzzzening Feb 11, 2020
cdaf1d1
Add idk what
tzzzening Feb 13, 2020
016a60c
Attempt to add TextUiTesting but failed
tzzzening Feb 13, 2020
8e898b3
Change "Duke" logo to "Hi"
tzzzening Feb 13, 2020
a2017c2
Add "OIOIOIO"
tzzzening Feb 13, 2020
10bc426
Merge branch 'master' into feature1
tzzzening Feb 13, 2020
2c7f344
Add list of commands to greeting
tzzzening Feb 13, 2020
447777d
Edit last statement
tzzzening Feb 13, 2020
3f2a978
Merge branch 'feature1'
tzzzening Feb 13, 2020
8607dbf
Add "Singapore"
tzzzening Feb 13, 2020
35a5861
Add "Jurong"
tzzzening Feb 13, 2020
feb2568
Delete "Jurong"
tzzzening Feb 13, 2020
6e43fcd
Merge branch 'delete-jurong'
tzzzening Feb 13, 2020
eaa4979
Chang back to Duke
tzzzening Feb 18, 2020
38b7914
Merge branch 'delete-jurong'
tzzzening Feb 18, 2020
b602d58
Attempt at adding level 6 increment (but it fails on me)
tzzzening Feb 24, 2020
2685652
Add incomplete Level 6 increment
tzzzening Feb 29, 2020
a29ddcf
Add Level 7 increment through PrintWriter
tzzzening Feb 29, 2020
6ec227d
Merge tag 'branch-Level-6'
tzzzening Feb 29, 2020
8b2763b
Merge tag 'branch-Level-7'
tzzzening Feb 29, 2020
88e44fa
Add Code Quality increment
tzzzening Mar 1, 2020
4d4a195
Add More OOP increment
tzzzening Mar 1, 2020
60122da
Add Level 9 increment with a minor bug
tzzzening Mar 2, 2020
bc2cba1
Add JavaDocs
tzzzening Mar 2, 2020
f8a42ff
Merge pull request #2 from chengTzeNing/branch-Level-9
tzzzening Mar 2, 2020
4aeaf4f
Merge branch 'master' of https://github.com/chengTzeNing/duke
tzzzening Mar 2, 2020
b25c605
Merge tag 'JavaDocs'
tzzzening Mar 2, 2020
5dcc300
Fix minor bug
tzzzening Mar 2, 2020
d656f7b
Fix spelling error and created a JAR file?
tzzzening Mar 2, 2020
f7fad9f
Fix bugs
tzzzening Mar 2, 2020
1da6df9
Add README file for User Guide correctly
tzzzening Mar 2, 2020
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
42 changes: 26 additions & 16 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,29 @@

## Features

### Feature 1
Description of feature.

## Usage

### `Keyword` - Describe action

Describe action and its outcome.

Example of usage:

`keyword (optional arguments)`

Expected outcome:

`outcome`
### Add tasks to list
#### ToDo
* Add a ToDo to your list of tasks in the following format: "todo {task to be done}"
* Example: "todo read book"
#### Deadline
* Add a task with a deadline to your list of tasks in the following format: "deadline {task to be done} /by {date and/or time}"
* Example: "deadline write essay /by today, 2pm"
#### Event
* Add an event to your list of tasks in the following format: "event {name of event} /at {date and/or time}"
* Example: "event career fair /at 2pm, 14 Feb"

### Mark a task as completed
* Mark a task as completed in the following format: "done {index number of task in the list}"
* Example: "done 3"

### See your list of tasks
* See your list of tasks in the following format: "list"
* Example: "list"

### Find a certain task using keywords
* Find a certain task using keywords in the following format: "find {keywords}"
* Example: "find book"

### Delete a task from your list
* Delete a certain task from your list in the following format: "delete {index number of the task in the list}"
* Example: "delete 4"
8 changes: 8 additions & 0 deletions src/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions src/main/java/Command.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
<<<<<<< HEAD
*
=======
* A class that is the foundation where all the Commands extends from.
>>>>>>> JavaDocs
*/

public class Command {
protected String command;
protected TextUi textUi;

public Command() {
this.command = "";
}

/**
* Constructor for Command object.
* @param command the command inputted by the user, with trailing and leading white spaces removed.
*/

public Command(String command) {
this.command = command;
textUi = new TextUi();
}
}
27 changes: 27 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Extends from Task. Stores the information needed for Deadline.
*/

public class Deadline extends Task {

/**
* The latest date the task must be completed.
*/

private String latestDate;

/**
* Constructor for Deadline.
* @param userInput the command that the user typed in.
*/

public Deadline(String userInput) {
super(userInput.substring(0, userInput.indexOf(" /")));
this.latestDate = userInput.substring(userInput.indexOf("/") + 4);
}

@Override
public String toString() {
return String.format("[D][%c] %s (by: %s)", isDone() ? '✓' : '✗', taskName, latestDate);
}
}
24 changes: 24 additions & 0 deletions src/main/java/DeadlineCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Extends from Command. Gives instructions on how to proceed when a Deadline task is added.
*/

public class DeadlineCommand extends Command {

/**
* Create a new Deadline task as requested by the user.
*/

private Deadline deadline;

/**
* Constructor for DeadlineCommand.
* @param command the command that the user typed in.
* @throws IndexOutOfBoundsException throws IndexOutOfBoundsException when there are invalid arguments.
*/
public DeadlineCommand(String command) throws IndexOutOfBoundsException {
super(command);
deadline = new Deadline(command.substring(9));
Duke.tasks.add(deadline);
textUi.printDeadlineMessage(deadline);
}
}
19 changes: 19 additions & 0 deletions src/main/java/DeleteCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Extends from Command. Gives instructions on how to proceed when a task needs to be deleted.
*/

public class DeleteCommand extends Command {

/**
* Constructor for DeleteCommand.
* @param command the command that the user typed in.
* @throws IndexOutOfBoundsException throw IndexOutOfBoundsException when there are invalid arguments.
*/
public DeleteCommand(String command) throws IndexOutOfBoundsException {
super(command);
int selectedTaskId = Integer.parseInt(command.substring(7));
Task task = Duke.tasks.get(selectedTaskId - 1);
Duke.tasks.remove(task);
textUi.printDeleteMessage(task, Duke.tasks.size());
}
}
15 changes: 15 additions & 0 deletions src/main/java/DoneCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Extends from Command. Gives instructions on how to proceed when a task is completed.
*/

public class DoneCommand extends Command {

/**
* Constructor for DoneCommand.
* @param command the command that the user typed in.
*/
public DoneCommand(String command) {
super(command);
Duke.tasks.get(Integer.parseInt(command.substring(5)) - 1).setDone();
}
}
47 changes: 41 additions & 6 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,45 @@
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.ArrayList;

/**
<<<<<<< HEAD
* Duke is a project that keeps a list of the tasks that need to be completed.
=======
* Project Duke.
* Keeps a record of the tasks that the user has, which can be saved into and loaded from a hard disk.
>>>>>>> JavaDocs
*/

public class Duke {
static ArrayList<Task> tasks = new ArrayList<>();

/**
* Stores any methods that require interaction with the user.
*/

static TextUi textUi = new TextUi();

/**
* Contains all the necessary objects to keep track of the tasks.
* @param args
*/

public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);
textUi.printWelcomeMessage();
Scanner scan = new Scanner(System.in);
String userInput = scan.nextLine();
while (!userInput.equals("bye")) {
try {
Parser.parseInput(userInput);
} catch (IndexOutOfBoundsException exception) {
textUi.printIndexOutOfBoundsExceptionMessage(exception);
} catch (IllegalArgumentException exception) {
textUi.printIllegalArgumentExceptionMessage(exception);
}
userInput = scan.nextLine();
}
textUi.printExitMessage();
}
}
26 changes: 26 additions & 0 deletions src/main/java/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* Extends from Task. Stores the information needed for Event.
*/

public class Event extends Task {

/**
* The details of the event as stated by the user.
*/

private String eventDetails;

/**
* Constructor for Event.
* @param userInput the command that the user typed in.
*/
public Event(String userInput) {
super(userInput.substring(0, userInput.indexOf(" /")));
this.eventDetails = userInput.substring(userInput.indexOf("/") + 4);
}

@Override
public String toString() {
return String.format("[E][%c] %s (at: %s)", isDone() ? '✓' : '✗', taskName, eventDetails);
}
}
24 changes: 24 additions & 0 deletions src/main/java/EventCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Extends from Command. Gives instructions on how to proceed when an Event task is added.
*/

public class EventCommand extends Command {

/**
* Creates a new Event task as requested by the user.
*/
private Event event;

/**
* Constructor for EventCommand.
* @param command the command that the user typed in.
* @throws IndexOutOfBoundsException throws IndexOutOfBoundsException when there are invalid arguments.
*/

public EventCommand(String command) throws IndexOutOfBoundsException {
super(command);
event = new Event(command.substring(6));
Duke.tasks.add(event);
textUi.printEventMessage(event);
}
}
22 changes: 22 additions & 0 deletions src/main/java/FindCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
public class FindCommand extends Command {
public FindCommand(String command) {
super(command);
execute(command);
}

public void execute(String command) {
textUi.printFindMessage(command);
String keyword = command.substring(5);
boolean isFound = false;
for (Task task : Duke.tasks) {
if (task.getTaskName().contains(keyword)) {
System.out.println(task.getTaskId() + ". " + task.toString());
isFound = true;
}
}
if (!isFound) {
System.out.println("Sorry there are no matches");
}

}
}
27 changes: 27 additions & 0 deletions src/main/java/ListCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Extends from Command. Gives instructions on how to proceed when a list of the tasks is requested.
*/

public class ListCommand extends Command {

/**
* Stores the list of tasks in a text file on the hard disk.
*/

private Storage storage;

/**
* Constructor for ListCommand.
* @param command the command that the user typed in.
*/

public ListCommand(String command) {
super(command);
storage = new Storage();
for (Task task : Duke.tasks) {
System.out.println(String.format("%d. %s", task.getTaskId(), task.toString()));
storage.addToList(String.format("%d. %s", task.getTaskId(), task.toString()));
}
storage.storeList();
}
}
37 changes: 37 additions & 0 deletions src/main/java/Messages.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* Contains all the frequently used messages displayed to the user.
*/

public class Messages {

/**
* List of commands that the user can input.
*/
public static String LIST_OF_COMMANDS = "Here is the list of commands available\n"
+ "\"bye\": to exit\n" +
"\"list\": to show the list of all your tasks\n" +
"\"todo\": add a todo\n" +
"\"deadline\": add a deadline\n" +
"\"event\": add an event\n" +
"\"done\": check off a task on your list\n";

/**
* Exit message.
*/

public static String EXIT_MESSAGE = "Bye la you";

/**
* Duke logo.
*/
public static String LOGO = " ____ _ \n" +
"| _ \\\\ _ _| | __ __ \n" +
"| | | | | | | |/ / _ \\\n" +
"| |_| | |_| | < __/\n" +
"|____/ \\\\__,_|_|\\_\\\\___\n";

/**
* Welcome message when the user first enters.
*/
public static String WELCOME_MESSAGE = "Hello there I am\n" + LOGO + LIST_OF_COMMANDS;
}
17 changes: 17 additions & 0 deletions src/main/java/NoSuchCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Extends from Command. Gives instructions on how to proceed when the command is not recognised.
*/

public class NoSuchCommand extends Command {

/**
* Constructor for NoSuchCommand.
* @param command the command that the user typed in.
* @throws IllegalArgumentException throws IllegalArgumentException within the constructor for the main method
* to catch.
*/
public NoSuchCommand(String command) throws IllegalArgumentException{
super(command);
throw new IllegalArgumentException();
}
}
Loading