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

[Ong Jun Lin Jeremiah] iP #212

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
62 changes: 38 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,38 @@
# Duke project template

This is a project template for a greenfield Java project. It's named after the Java mascot _Duke_. Given below are instructions on how to use it.

## Setting up in Intellij

Prerequisites: JDK 11, update Intellij to the most recent version.

1. Open Intellij (if you are not in the welcome screen, click `File` > `Close Project` to close the existing project first)
1. Open the project into Intellij as follows:
1. Click `Open`.
1. Select the project directory, and click `OK`.
1. If there are any further prompts, accept the defaults.
1. Configure the project to use **JDK 11** (not other versions) as explained in [here](https://www.jetbrains.com/help/idea/sdk.html#set-up-jdk).<br>
In the same dialog, set the **Project language level** field to the `SDK default` option.
3. After that, locate the `src/main/java/Duke.java` file, right-click it, and choose `Run Duke.main()` (if the code editor is showing compile errors, try restarting the IDE). If the setup is correct, you should see something like the below as the output:
```
Hello from
____ _
| _ \ _ _| | _____
| | | | | | | |/ / _ \
| |_| | |_| | < __/
|____/ \__,_|_|\_\___|
```
# Duke
Welcome to Duke! This is a user guide for the task tracker Duke.

## Installation
Requires: JDK 11
1. Download the jar file for Duke under "Releases"
2. Extract it to an empty folder
3. Run the jar file
4. Enjoy!

### Commands
Below are the list of commands that can be used with Duke
Please remember to follow the input format strictly!

1. list || (to see the current tasks saved)
2. `todo <task>` || Adds a task with no particular time to take note of
3. `event <task> /from <start time of event> /to <end time of event>` || Adds an event with a start and end time
4. `deadline <task> /by <deadline of task>` || Adds a task with a deadline
5. `mark <task number>` || To mark a task as done
6. `unmark <task number>` || To mark a task as not done
7. `delete <task number>` || To remove a task from the list
8. `bye` || To terminate the programme

## Usage

Example of usage:

`event study /from 2pm /tp 4pm`

Expected outcome:
```
Got it. I've added this task:
[E][ ] study (From: 2pm to To: 4pm)
Now you have 1 tasks in the list.
____________________________________________________________

What would you like to do?
```
49 changes: 29 additions & 20 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
# User Guide

## Features

### Feature-ABC

Description of the feature.

### Feature-XYZ

Description of the feature.
# Duke
Welcome to Duke! This is a user guide for the task tracker Duke.

## Installation
Requires: JDK 11
1. Download the jar file for Duke under "Releases"
2. Extract it to an empty folder
3. Run the jar file
4. Enjoy!

### Commands
Below are the list of commands that can be used with Duke
Please remember to follow the input format strictly!

1. list || (to see the current tasks saved)
2. `todo <task>` || Adds a task with no particular time to take note of
3. `event <task> /from <start time of event> /to <end time of event>` || Adds an event with a start and end time
4. `deadline <task> /by <deadline of task>` || Adds a task with a deadline
5. `mark <task number>` || To mark a task as done
6. `unmark <task number>` || To mark a task as not done
7. `delete <task number>` || To remove a task from the list
8. `bye` || To terminate the programme

## Usage

### `Keyword` - Describe action

Describe the action and its outcome.

Example of usage:

`keyword (optional arguments)`
`event study /from 2pm /tp 4pm`

Expected outcome:

Description of the outcome.

```
expected output
Got it. I've added this task:
[E][ ] study (From: 2pm to To: 4pm)
Now you have 1 tasks in the list.
____________________________________________________________

What would you like to do?
```
Empty file added duke.txt
Empty file.
36 changes: 28 additions & 8 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
import User.Parser;
import User.Storage;
import User.TaskList;
import User.UI;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;

public class Duke {
public static void main(String[] args) {
String logo = " ____ _ \n"
+ "| _ \\ _ _| | _____ \n"
+ "| | | | | | | |/ / _ \\\n"
+ "| |_| | |_| | < __/\n"
+ "|____/ \\__,_|_|\\_\\___|\n";
System.out.println("Hello from\n" + logo);

public static void main(String[] args) throws IOException {
try{
TaskList.taskList = Storage.readFile("duke.txt");
} catch (FileNotFoundException e) {
System.out.println("File not found, a new one will be created shortly!");
}
UI.printLogo();
Scanner myObj = new Scanner(System.in);
String userInput;
userInput = myObj.nextLine();
while (!userInput.equals("bye")) {
Parser.parsing(userInput);
System.out.println("What would you like to do?");
userInput = myObj.nextLine();
}
Storage.clearFile();
Storage.updateFile(TaskList.taskList);
UI.printBye();
}
}
}
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: Duke

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

import Tasks.Task;

public class Deadline extends Task {

protected String by;
protected String symbol = "[D]";

public String getDescription() {
return super.getDescription();
}

public String getSymbol() {
return symbol;
}

/**
* Constructs a deadline-type task
* @param description the activity that needs be done by the user
* @param by the deadline by which the user needs to finish said activity
*/
public Deadline(String description, String by) {
super(description);
this.by = by;
this.description = description + "(By:" + by + ")";
}

/**
* Returns a string representation of the deadline-type task to be printed for the user
* @return the formatted string output
*/
@Override
public String toString() {
return "[D]" + super.getStatusIcon() + " " + super.getDescription() ;
}

/**
* Returns a string representation of the deadline-type task to be stored in the text file
* @return the formatted string output
*/
@Override
public String toFile() {
return this.getStatusIcon() + " : " +"D"+ " : " + this.description;
}
}
37 changes: 37 additions & 0 deletions src/main/java/Tasks/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package Tasks;

public class Event extends Task {
protected String from;
protected String to;
protected String symbol = "[E]";

public Event(String description, String from, String to) {
super(description);
this.from = from;
this.to = to;
this.description = description + "(From:" + this.from + "To:" + this.to + ")";
}

@Override
public String getSymbol() {
return symbol;
}

/**
* Returns the string in a format to be presented to the user
* @return the formatted string output
*/
@Override
public String toString(){
return "[E]" + super.getStatusIcon() + " " + super.getDescription();
}

/**
* Returns the string in a format to be stored in the text file
* @return the formatted string to be stored in the text file
*/
@Override
public String toFile() {
return this.getStatusIcon() + " : " + "E" + " : " + this.description;
}
}
73 changes: 73 additions & 0 deletions src/main/java/Tasks/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package Tasks;

public class Task {
protected String description;
protected boolean isDone;
protected String symbol = "[T]";

public String getDescription() {
return description;
}

public Task(String description) {
this.description = description;
this.isDone = false;
}

/**
* Returns the symbol of the task
* @return
*/
public String getSymbol() {
return symbol;
}

/**
* marks the task as done
*/
public void markAsDone() {
this.isDone = true;
}

/**
* Returns the boolean value of whether a task has been marked as done or not
* @return true if the task has been marked as done, false otherwise
*/
public boolean isDone() {
return isDone;
}

/**
* marks the task as not done
*/
public void markAsUnDone() {
this.isDone = false;
}

/**
* Checks if the task has been marked as done and returns the appropriate symbol
* @return returns "[X]" if done, and "[ ]" if not done
*/
public String getStatusIcon() {
return (isDone ? "[X]" : "[ ]"); // mark done task with X
}

/**
* Returns a string representation of the task to be presented to the user
* @return the formatted string output
*/
@Override
public String toString(){
return "[T]" + this.getStatusIcon() + " " + getDescription();
}

/**
* Returns a string representation of the task to be stored in the text file
* @return the formatted string output
*/
public String toFile() {
return this.getStatusIcon() + " : " +"T"+ " : " + this.description;
}
}


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

public class Parser {
/**
* Takes in the users command and carries out the corresponding action
* @param userInput the command that the user inputs
*/
public static void parsing(String userInput){
String[] inputParts;
inputParts = userInput.split(" ",2);
String command = inputParts[0];
switch(command){
case("list"):
TaskList.printList();
break;
case("delete"):
TaskList.deleteItem(userInput);
break;
case("mark"):
TaskList.markItem(userInput);
break;
case("unmark"):
TaskList.unMarkItem(userInput);
break;
case("event"):
TaskList.createEvent(userInput);
break;
case("todo"):
TaskList.createToDo(userInput);
break;
case("deadline"):
TaskList.createDeadline(userInput);
break;
case("help"):
UI.printHelp();
break;
case("find"):
if(!TaskList.taskList.isEmpty()) {
TaskList.find(userInput);
} else {
UI.listIsEmpty();
}
break;
default:
UI.invalidCommand();
break;
}
}
}
Loading