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

[Karan Dev Sapra] Duke Increments #356

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
65f72a8
Add support for Gradle workflow
j-lum Aug 6, 2019
0112efe
Add sample checkstyle configuration
j-lum Aug 12, 2019
cfd6da7
Change file mode on `gradle` to be executable
j-lum Aug 18, 2019
6e6ace1
Merge pull request #12 from j-lum/gradle+x
j-lum Aug 18, 2019
a3ca5a4
Add configuration for console applications
j-lum Aug 20, 2019
7b60e81
Merge pull request #13 from j-lum/javaexec
j-lum Aug 21, 2019
6dfbb70
Level-1
Aug 26, 2019
87fb84e
Level-1
Aug 26, 2019
24796d0
Level-2
Aug 26, 2019
f302e6b
Level-2
Aug 26, 2019
e5ec66b
Level-3
Aug 26, 2019
76204fe
Level-4
Aug 27, 2019
9a81e57
Level-5
Aug 27, 2019
4ff446c
Level-6
Aug 27, 2019
a504967
Level-7
Aug 28, 2019
0ec0fe4
Level-8
Aug 28, 2019
1a541a9
Merge branch 'branch-Level-8'
Aug 28, 2019
e26dc70
Level-7 (removing a few print lines that I had put for debugging)
Aug 28, 2019
313de67
Merge branch 'master' into branch-Level-7
Aug 28, 2019
9559d8a
Level-8 (won't display error message if the date inputted by the uses…
Aug 28, 2019
35acea9
Merge branch 'branch-Level-8'
Aug 28, 2019
e8daed2
Making it more OOP
Sep 2, 2019
1c21635
Merge branch 'branch-Level-7'
Sep 2, 2019
8219d3d
A-MoreOOP
Sep 2, 2019
808d2dd
A-JUnit
Sep 2, 2019
e5b08a3
Level-9 (Now Able to Find Tasks!)
Sep 3, 2019
e56bf4d
A-JavaDoc (Added Java Doc for every class & every method)
Sep 3, 2019
dfe5277
A-CodingStandard (Changed the Access Modifier of some class variables…
Sep 3, 2019
16f1bda
Merge branch 'branch-A-CodingStandard' into master
Sep 3, 2019
5304e70
Merge branch 'branch-Level-9' into master
Sep 3, 2019
d9893cc
Merge branch 'gradle'
Sep 3, 2019
d708610
Fixed a bug (there was a merge conflict so it wasn't compiling)
Sep 3, 2019
0f9f7bd
Created my first GUI application! (a window that says Hello World)
Sep 4, 2019
2e58d6b
Created the GUI for Duke (but without any functionality)
Sep 4, 2019
59acd1a
Iteration 1 – Echoing the User
Sep 4, 2019
5131533
Iteration 2 – Adding Dialog Boxes
Sep 4, 2019
85bffc6
Duke GUI now responds to user input!
Sep 4, 2019
07298f9
Making JUnit work with Gradle (and adding more unit testing functions)
Sep 30, 2019
8f60f0f
Made the DialogBox have resizable width (through SceneBuilder) so tha…
Sep 30, 2019
acb5af9
Merge branch 'branch-Level-10'
Sep 30, 2019
8a19a8b
Added assert feature to document important assumptions that should ho…
Sep 30, 2019
e461b9a
Critically examined the code and refactored it to improve the code qu…
Sep 30, 2019
8d53e2c
Merge pull request #5 from eizon05/branch-A-CodeQuality
aang114 Sep 30, 2019
af61ae9
Merge branch 'master' into branch-A-Assertions
aang114 Sep 30, 2019
b54fc5f
Merge pull request #6 from eizon05/branch-A-Assertions
aang114 Sep 30, 2019
015f926
Add Ui.png
aang114 Sep 30, 2019
022e6c7
Update README.md
aang114 Sep 30, 2019
1360dee
Update README.md
aang114 Sep 30, 2019
540fb54
Update README.md
aang114 Sep 30, 2019
a966f0a
Update README.md
aang114 Sep 30, 2019
63aebb5
Update README.md
aang114 Sep 30, 2019
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
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ src/main/resources/docs/
.DS_Store
*.iml
bin/
src/.idea/$PRODUCT_WORKSPACE_FILE$
src/.idea/.gitignore
src/.idea/misc.xml
src/.idea/modules.xml
src/.idea/vcs.xml
src/out/production/main/Duke.class
124 changes: 124 additions & 0 deletions src/.idea/uiDesigner.xml

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

22 changes: 22 additions & 0 deletions src/main/java/AddCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import java.io.IOException;

public class AddCommand extends Command {

private Task task;

public AddCommand (Task task) {
this.task = task;
}


@Override
public void execute(TaskList taskList, Ui ui, Storage storage) throws IOException {

taskList.add(task);

ui.add(taskList.list);

storage.save(taskList.list);

}
}
10 changes: 10 additions & 0 deletions src/main/java/Command.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import java.io.IOException;

public abstract class Command {

public abstract void execute (TaskList taskList, Ui ui, Storage storage) throws IOException;

public boolean isExit() {
return false;
}
}
21 changes: 21 additions & 0 deletions src/main/java/DateClass.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateClass {

public static Date stringToDate (String string) {

SimpleDateFormat format = new SimpleDateFormat("d/MM/yyyy HHmm");

Date date = null;

try {
date = format.parse(string);
} catch (ParseException e) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to handle the exception instead of doing nothing?
Let's say you can throw ParseException to Duke class and let it handle the output/ message.


}

return date;
}
}
26 changes: 26 additions & 0 deletions src/main/java/Deadline.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import java.util.Date;

public class Deadline extends Task {

protected String by;

protected Date date;

public Deadline(String description, String by) {
super(description);
this.by = by;

this.date = DateClass.stringToDate(by);
}

@Override
public String toString() {
return "[D]" + super.toString() + " (by: " + by + ")";
}

@Override
public String saveFormat() {
return String.format("D | %d | %s | %s", this.isDone ? 1 : 0, this.description, this.by);
}

}
20 changes: 20 additions & 0 deletions src/main/java/DeleteCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import java.io.IOException;

public class DeleteCommand extends Command {

int index;

public DeleteCommand (int index) {
this.index = index;
}

@Override
public void execute(TaskList taskList, Ui ui, Storage storage) throws IOException {

Task task = taskList.delete(index);

ui.delete(taskList.list, task);

storage.save(taskList.list);
}
}
20 changes: 20 additions & 0 deletions src/main/java/DoneCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import java.io.IOException;

public class DoneCommand extends Command {

int index;

public DoneCommand (int index) {
this.index = index;
}

@Override
public void execute(TaskList taskList, Ui ui, Storage storage) throws IOException {

Task task = taskList.done(this.index);

ui.done(task);

storage.save(taskList.list);
}
}
55 changes: 48 additions & 7 deletions src/main/java/Duke.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,51 @@
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);

private Storage storage;
private TaskList tasks;
private Ui ui;

public Duke(String filePath, String folderPath) {
ui = new Ui();
storage = new Storage(filePath, folderPath);
try {
tasks = new TaskList(storage.retrieve());
} catch (FileNotFoundException e) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to inform the user about the exception?
For me particularly I would inform that "file isn't found, a new file will be created instead"

try {
storage.makeDirectory(folderPath);
tasks = new TaskList();
} catch (IOException ex) {
ui.abort();
System.exit(0);
}
}
}

public void run() {
ui.greeting();
boolean isExit = false;
while (!isExit) {
try {
String fullCommand = ui.readCommand();
// ui.showLine(); // show the divider line ("_______")
Command c = Parser.parse(fullCommand);
c.execute(tasks, ui, storage);
isExit = c.isExit();
} catch (DukeException | IOException e) {
ui.showError(e.getMessage());
} finally {
//ui.showLine();
}
}
}


public static void main(String[] args) throws DukeException, IOException {

new Duke("../data/duke.txt", "../data").run();
}
}
10 changes: 10 additions & 0 deletions src/main/java/DukeException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
public class DukeException extends Exception {

public DukeException (String message) {
super(message);
}

public static DukeException emptyDescription () {
return new DukeException("☹ OOPS!!! The description of a todo cannot be empty.");
}
}
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 @@
import java.util.Date;

public class Event extends Task {

protected String at;

protected Date date;

public Event(String description, String at) {
super(description);
this.at = at;

this.date = DateClass.stringToDate(at);
}

@Override
public String toString() {
return "[E]" + super.toString() + " (at: " + at + ")";
}

@Override
public String saveFormat() {
return String.format("E | %d | %s | %s", this.isDone ? 1 : 0, this.description, this.at);
}

}
14 changes: 14 additions & 0 deletions src/main/java/ExitCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import java.io.IOException;

public class ExitCommand extends Command {

@Override
public void execute(TaskList taskList, Ui ui, Storage storage) throws IOException {
ui.bye();
}

@Override
public boolean isExit() {
return true;
}
}
11 changes: 11 additions & 0 deletions src/main/java/ListCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import java.io.IOException;

public class ListCommand extends Command {


@Override
public void execute(TaskList taskList, Ui ui, Storage storage) throws IOException {
ui.list();
taskList.list();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you might want to make the two methods here somewhat clearer in terms of naming? Both ui.list() and taskList.list() seem to mean the same thing even though they most likely do very different things.

}
}
Loading