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

[Cui Minjing] iP #13

Open
wants to merge 59 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
4caa62c
level-0
Cuiminjing Aug 25, 2021
22361f2
Update Duke.java
Cuiminjing Aug 25, 2021
d9444d5
Merge remote-tracking branch 'origin/master'
Cuiminjing Aug 25, 2021
5a95fff
Level-1
Cuiminjing Aug 25, 2021
9082346
Level-1
Cuiminjing Aug 25, 2021
f9d3e52
Level-2
Cuiminjing Aug 25, 2021
035821c
Level-3
Cuiminjing Aug 25, 2021
44ec76d
Level-4
Cuiminjing Aug 31, 2021
b1b1d94
Level-4
Cuiminjing Aug 31, 2021
24b02c7
Level-4
Cuiminjing Aug 31, 2021
e497d25
Level-4 final with ui
Cuiminjing Sep 1, 2021
2222f06
level-4 after peer review
Cuiminjing Sep 5, 2021
633befa
Level-5
Cuiminjing Sep 5, 2021
e7c8ad4
exception
Cuiminjing Sep 5, 2021
c2637d1
package
Cuiminjing Sep 5, 2021
7caaf87
commit
Cuiminjing Sep 6, 2021
5052722
for branch level 5
Cuiminjing Sep 6, 2021
fe3aae2
for master
Cuiminjing Sep 6, 2021
78c0a19
for master
Cuiminjing Sep 6, 2021
8f91ee9
practice
Cuiminjing Sep 6, 2021
c6ae5c3
..
Cuiminjing Sep 6, 2021
2a818e7
level-6
Cuiminjing Sep 12, 2021
548867c
for master
Cuiminjing Sep 12, 2021
dc40ec5
level-7
Cuiminjing Sep 12, 2021
aa415ce
level-9
Cuiminjing Sep 26, 2021
7970bad
Level-9 final
Cuiminjing Sep 26, 2021
b07d5d1
JavaDoc
Cuiminjing Sep 26, 2021
fcf82ba
Update README.md
Cuiminjing Sep 26, 2021
09b6898
Update README.md
Cuiminjing Sep 26, 2021
bf3ba61
Update README.md
Cuiminjing Sep 26, 2021
eb1a1b4
Update README.md
Cuiminjing Sep 26, 2021
912736e
Update README.md
Cuiminjing Sep 26, 2021
b84167c
Update README.md
Cuiminjing Sep 26, 2021
c90176d
no message
Cuiminjing Sep 26, 2021
a06dec1
Merge remote-tracking branch 'origin/master'
Cuiminjing Sep 26, 2021
c039eb1
images
Cuiminjing Sep 26, 2021
1cde7f8
Update README.md
Cuiminjing Sep 26, 2021
3798107
Update README.md
Cuiminjing Sep 26, 2021
1d7f2da
Update README.md
Cuiminjing Sep 26, 2021
2e7fc7d
Update README.md
Cuiminjing Sep 26, 2021
ac11498
Update README.md
Cuiminjing Sep 26, 2021
46bfe80
Update README.md
Cuiminjing Sep 26, 2021
bf17d78
Update README.md
Cuiminjing Sep 26, 2021
4c56f42
Update README.md
Cuiminjing Sep 26, 2021
d0fbb00
Update README.md
Cuiminjing Sep 26, 2021
05d765d
Update README.md
Cuiminjing Sep 26, 2021
338ef72
final
Cuiminjing Sep 30, 2021
59ebc42
add error detecting
Cuiminjing Sep 30, 2021
c521047
Update README.md
Cuiminjing Sep 30, 2021
b5314f1
Update README.md
Cuiminjing Sep 30, 2021
5c06be4
Update README.md
Cuiminjing Sep 30, 2021
7f3abf0
Update README.md
Cuiminjing Sep 30, 2021
82aaf0f
Update README.md
Cuiminjing Sep 30, 2021
10f2a4a
test
Cuiminjing Sep 30, 2021
9080cae
Merge pull request #1 from Cuiminjing/branch-A-JavaDoc
Cuiminjing Sep 30, 2021
12ecb0d
final version of ip
Cuiminjing Sep 30, 2021
4b632a0
Merge branch 'branch-A-JavaDoc'
Cuiminjing Sep 30, 2021
93acc4c
Merge remote-tracking branch 'origin/master'
Cuiminjing Sep 30, 2021
8a4135c
change for ug
Cuiminjing Oct 1, 2021
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
JavaDoc
  • Loading branch information
Cuiminjing committed Sep 26, 2021
commit b07d5d18977e7bc00a78464a85abd8d049f8fbe4
48 changes: 47 additions & 1 deletion src/main/java/Duke/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,14 @@
import java.io.IOException;

public class Command {

/** The data structure to store all task information**/
private static ArrayList<Task> tasks = new ArrayList<>();
/** The integer to store the sum of tasks**/
private static int taskSum = 0;

/**
* The methods to print all tasks.
*/
public static void printList() {
Task now;
System.out.println(" Here are the tasks in your list:");
Expand All @@ -22,16 +26,28 @@ public static void printList() {
}
}

/**
* The methods to close the system.
*/
public static void bye() {
System.out.println(" Bye. Hope to see you again soon!" );
}

/**
* The methods to mark the task as done.
* @param command A String to store the information of done command.
*/
public static void done(String command){
String[] number = command.split(" ");
int taskIndex = Integer.parseInt(number[1]) - 1;
tasks.get(taskIndex).complete();
System.out.println(" Nice! I've marked this task as done:" + "\n " + tasks.get(taskIndex).toString());
}

/**
* The methods to delete a task from the list.
* @param command A String to store the information of delete command.
*/
public static void delete(String command){
String[] number = command.split(" ");
int taskIndex = Integer.parseInt(number[1]) - 1;
Expand All @@ -40,6 +56,11 @@ public static void delete(String command){
System.out.println(" Noted. I've removed this task: " + "\n " + tasks.get(taskIndex).toString() + "\n" + " Now you have " + taskSum + " tasks in the list");
tasks.remove(taskIndex);
}

/**
* The methods to add a todo tyoe into the list.
* @param command A String to store the information of todo command.
*/
public static void todo(String command){
int first = command.indexOf(" ");
String item = command.substring(first,command.length());
Expand All @@ -48,6 +69,11 @@ public static void todo(String command){
taskSum++;
System.out.println(" Got it. I've added this task: " + "\n" + " [T][ ] " + item + "\n" + " Now you have " + taskSum + " tasks in the list");
}

/**
* The methods to add a deadline tyoe into the list.
* @param command A String to store the information of deadline command.
*/
public static void deadline(String command){
int first = command.indexOf(" ");
int itemEnd = command.indexOf("/");
Expand All @@ -59,6 +85,11 @@ public static void deadline(String command){
System.out.println( " Got it. I've added this task: " + "\n" + " [D][ ] " + item + " (" + by + ")" + "\n" + " Now you have " + taskSum + " tasks in the list");

}

/**
* A String to store the information of event command.
* @param command A String to store the information of event command.
*/
public static void event(String command){
int first = command.indexOf(" ");
int itemEnd = command.indexOf("/");
Expand All @@ -69,6 +100,11 @@ public static void event(String command){
taskSum++;
System.out.println(" Got it. I've added this task: " + "\n" + " [E][ ] " + item + " (" + at + ")" + "\n" + " Now you have " + taskSum + " tasks in the list");
}

/**
* The methods to find a task by searching for a keyword.
* @param command A String to store the information of event command.
*/
public static void find(String command){
System.out.println(" Here are the matching tasks in your list:");
int first = command.indexOf(" ");
Expand All @@ -81,9 +117,19 @@ public static void find(String command){
}
}
}

/**
* The methods means that Duke cannot understand the command.
*/
public static void printerror(){
System.out.println(" ☹ OOPS!!! I'm sorry, but I don't know what that means :-(");
}

/**
* The methods to write the output into the file.
* @param filePath A string store the path of the output file.
* @throws IOException Exception strows when cannot find the path of the file.
*/
public static void writeToFile(String filePath) throws IOException {
FileWriter fw = new FileWriter(filePath);
for(int i=0; i<taskSum; i++){
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/Duke/Duke.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package Duke;

import java.util.Scanner;

public class Duke {

public static void main(String[] args) {
Ui.printLogo();
Ui.greeting();
String command;
Scanner in = new Scanner(System.in);
boolean flag = true;

do{
command = in.nextLine();
flag = Parser.parse(command);
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/Task/Deadline.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
package Task;

public class Deadline extends Task {
/** The deadline of the task**/
protected String by;

/**
* A constructor of Deadline.
* @param content the name of the task.
* @param by the deadline of the task
*/
public Deadline(String content, String by) {
super(content);
this.by = by;
}

/**
* A methods to return the whole information of the Deadline
* @return A String contains the type, name, and deadline for this task.
*/
@Override
public String toString() {
return "[D]" + super.toString() + "(" + by + ")";
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/Task/Event.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
package Task;

public class Event extends Task {
/** The deadline of the task**/
protected String at;

/**
* A constructor of Event.
* @param content the name of the task.
* @param at the deadline of the task.
*/
public Event(String content, String at) {
super(content);
this.at = at;
}

/**
* A methods to return the whole information of the Event
* @return A String contains the type, name, and deadline for this task.
*/
@Override
public String toString() {
return "[E]" + super.toString() + "(a" + at + ")";
Expand Down
18 changes: 16 additions & 2 deletions src/main/java/Task/Task.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
package Task;

public class Task {
/** The name of the task**/
protected String content;
/** The complement status of the task **/
protected boolean Done;


/**
* A public constructor to initialized the Task.
* @param content the whole information of the task
*/
public Task(String content) {
this.content = content;
this.Done = false;

}

/**
* The methods to mark the task as done.
*/
public void complete(){
this.Done = true;
}

/**
* @return The complement status of the task.
*/
public String getInformation() {
return (Done ? "X" : " ");
}

/**
* @return The whole status of teh task including name and complement.
*/
@Override
public String toString() {
return "[" + getInformation() + "]" + content;
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/Task/Todo.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,18 @@

public class Todo extends Task {

/**
* A public constructor to initialized the Todo.
*/
public Todo(String content) {
super(content);

}

/**
* A methods to return the whole information of the Todo.
* @return A String contains the type, and name this task.
*/
@Override
public String toString() {
return "[T]" + super.toString();
Expand Down