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

A-FinalFixed #307

Open
wants to merge 13 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
1 change: 1 addition & 0 deletions data/duke.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1. [E][✗] event AS (at: 16)
146 changes: 139 additions & 7 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,151 @@

## Features

### Feature 1
Description of feature.
### 1. Add Todo
Add a todo task to your task list.

### 2. Add Deadline
Add a deadline to your task list.

### 3. Add Event
Add an event to your task list.

### 4. Mark task as Done
Mark a task in your task list as done.

### 5. List all tasks
List all tasks in your task list.

### 6. Delete task
Delete a task from your task list.

### 7. Find task
Find tasks containing a keyword.

### 8. Save task list
Save your task list to a .txt file.

## Usage

### `Keyword` - Describe action
### `todo <task description>` - Add a Todo task

Describe action and its outcome.
Add a Todo task to your task list.

Example of usage:
Example of usage:

`keyword (optional arguments)`
`todo read book`

Expected outcome:

`outcome`
`____________________________________________________________
Got it. I've added this task: `
`[T][✗] read book`
`Now you have 1 tasks in the list.`
`____________________________________________________________`

### `deadline <task description> /by <date>` - Add a Deadline

Add a Deadline task to your task list.

Example of usage:

`deadline return book /by Monday`

Expected outcome:

`____________________________________________________________
Got it. I've added this task: `
`[D][✗] return book (by: Monday)`
`Now you have 2 tasks in the list.`
`____________________________________________________________`

### `event <task description> /at <date>` - Add an Event

Add an Event task to your task list.

Example of usage:

`event book fair /at 5pm Tuesday`

Expected outcome:

`____________________________________________________________
Got it. I've added this task: `
`[E][✘] book fair (at: 5pm Tuesday)`
`Now you have 3 tasks in the list.`
`____________________________________________________________`

### `done <task index>` - Mark task as done

Mark a task in your task list as done.

Example of usage:

`done 1`

Expected outcome:

`____________________________________________________________
Nice! I've marked this task as done: `
`[[T][✓] read book`
`____________________________________________________________`

### `list` - List all tasks

List all tasks in your task list.

Example of usage:

`list`

Expected outcome:

`____________________________________________________________
Here are the tasks in your list: `
`1. [T][✓] read book`
`2. [D][✘] return book (by: Monday)`
`3. [E][✘] book fair (at: 5pm Tuesday)`
`____________________________________________________________`

### `delete <task index>` - Delete a task

Delete a task from your task list.

Example of usage:

`delete 1`

Expected outcome:

`____________________________________________________________`
`Removed: [T][✓] read book`
`Now you have 2 task(s) in your list`
`____________________________________________________________`

### `find <keyword>` - Find tasks

Find tasks with matching keyword.

Example of usage:

`find book`

Expected outcome:


`Here are the matching tasks in your list: `
`1. [D][✘] return book (by: Monday)`
`2. [E][✘] book fair (at: 5pm Tuesday)`

### `save` - Save task list

Save task list to .txt file.

Example of usage:

`save`

Expected outcome:

`Successfully saved to file!`

115 changes: 115 additions & 0 deletions src/main/duke/Duke.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
package main.duke;
import java.util.Scanner;


public class Duke {
public static void main(String[] args) {
//Generates a greeting
greeting();
request();
}

public static void request(){
Scanner in = new Scanner(System.in);
Task[] list = new Task[100];
String line;
int i=0,j;
int task_count = 0;
while(true) {
String status ="[✗] ";
line = in.nextLine();

if (line.equals("bye")){
System.out.println("____________________________________________________________\n"
+"Bye. Hope to see you again soon!\n"
+"____________________________________________________________\n");
break;
}else if(line.equals("list")){
for(j=0;j<i;j++){
if(list[j].isDone){
System.out.println((j+1)+ ". " + "[✓]" + list[j].description);
}//not done
else {
System.out.println((j + 1) + ". " + "[✗] " + list[j].description);
}
}
}else if(line.contains("done")){
int num = Integer.parseInt(line.substring(5));
System.out.println(num);
list[num-1].isDone = true;
System.out.println("____________________________________________________________\n"+
"Nice! I've marked this task as done:");
System.out.println("[✓] "+ list[num-1].description + "\n____________________________________________________________\n");
}else if(line.contains("todo")) {
try{
String desc[] = line.split(" ");
list[i] = new Deadline(desc[0], desc[1]);
System.out.println("____________________________________________________________\n" +
"Got it. I've added this task: ");
task_count++;
System.out.println("[T][✗] " + list[i].description);
System.out.println("Now you have " + task_count + " tasks in the list.");
System.out.println("____________________________________________________________\n");
i++;
}catch(ArrayIndexOutOfBoundsException e){
System.out.println("____________________________________________________________\n" +
"☹ OOPS!!! The description of a todo cannot be empty.");
System.out.println("____________________________________________________________\n");
}

}else if(line.contains("deadline")){
try {
String desc[] = line.split("/by");
list[i] = new Deadline(desc[0], desc[1]);
System.out.println("____________________________________________________________\n" +
"Got it. I've added this task: ");
task_count++;
System.out.println("[D][✗] " + list[i].description + "(by:" + desc[1] + ")");
System.out.println("Now you have " + task_count + " tasks in the list.");
System.out.println("____________________________________________________________\n");
i++;
}catch(ArrayIndexOutOfBoundsException e){
System.out.println("____________________________________________________________\n" +
"☹ OOPS!!! The description of a deadline cannot be empty.");
System.out.println("____________________________________________________________\n");
}
}else if(line.contains("event")){
try {
String desc[] = line.split("/at");
list[i] = new Deadline(desc[0], desc[1]);

System.out.println("____________________________________________________________\n" +
"Got it. I've added this task: ");
task_count++;
System.out.println("[E][✗] " + list[i].description + "(at:" + desc[1] + ")");
System.out.println("Now you have " + task_count + " tasks in the list.");
System.out.println("____________________________________________________________\n");
i++;
}catch(ArrayIndexOutOfBoundsException e){
System.out.println("____________________________________________________________\n" +
"☹ OOPS!!! The description of an event cannot be empty.");
System.out.println("____________________________________________________________\n");
}
}else if(line.contains("task")){
list[i] = new Task(line);
System.out.println("____________________________________________________________");
System.out.println("added: "+ line);
System.out.println("_____________________________________________________________");
i++;
}else{
System.out.println("____________________________________________________________");
System.out.println(" ☹ OOPS!!! I'm sorry, but I don't know what that means :-( ");
System.out.println("_____________________________________________________________");
}
}
}

public static void greeting(){
System.out.println("____________________________________________________________");
System.out.println("Hello! I'm Duke");
System.out.println("What can I do for you?");
System.out.println("____________________________________________________________");
}

}

15 changes: 15 additions & 0 deletions src/main/duke/task/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package main.duke.task;
public class Deadline extends Todo {
protected String by;

public Deadline(String description, String by) {
super(description);
this.by = by;
}
public String getBy(){
return by;
}
public void setBy(String by){
this.by = by;
}
}
15 changes: 15 additions & 0 deletions src/main/duke/task/Event.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package main.duke.task;
public class Event extends Task {
protected String when;
public Event(String description, String when) {
super(description);
this.when = when;
}

public String getWhen(){
return when;
}
public void setWhen(String when){
this.when = when;
}
}
19 changes: 19 additions & 0 deletions src/main/duke/task/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main.duke.task;
public class Task {
protected String description;
protected boolean isDone;
protected int listCount;


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

public int length() {
return listCount; //return tick or X symbols
}


}
17 changes: 17 additions & 0 deletions src/main/duke/task/Todo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package main.duke.task;
public class Todo extends Task {
protected boolean isDone;

public Todo(String description) {
super(description);
isDone = false;
}

public boolean isDone(){
return isDone;
}

public void setDone(boolean Done){
this.isDone = Done;
}
}
Binary file added src/main/java/Deadline.class
Binary file not shown.
15 changes: 15 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

public class Deadline extends Todo {
protected String by;

public Deadline(String description, String by) {
super(description);
this.by = by;
}
public String getBy(){
return by;
}
public void setBy(String by){
this.by = by;
}
}
Binary file added src/main/java/Duke.class
Binary file not shown.
Loading