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

[Gibson0918] IP #375

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
556af3f
Add Gradle support
May 24, 2020
d2246c4
Add Level 1. Greet, Echo, Exit feature
Gibson0918 Jan 31, 2023
28b9930
Level 2 Completed
Gibson0918 Jan 31, 2023
75b6c9e
Level 3 done
Gibson0918 Jan 31, 2023
27b9c65
level 4 completed
Gibson0918 Feb 1, 2023
a008a30
Update Duke.java
Gibson0918 Feb 1, 2023
7f54de7
Completed Duke's Automated Text UI testing
Gibson0918 Feb 1, 2023
f43cdd7
Level 5 Completed.
Gibson0918 Feb 1, 2023
7e981d9
Level 6 Completed
Gibson0918 Feb 1, 2023
ee4a824
Added Enumerations
Gibson0918 Feb 1, 2023
44bf9f2
Update Duke.java
Gibson0918 Feb 1, 2023
038d559
Delete unnecessary files
Gibson0918 Feb 1, 2023
cdbfde3
Level 7 Completed
Gibson0918 Feb 1, 2023
9e0df04
Level 8 Completed
Gibson0918 Feb 1, 2023
33c6108
Merge branch 'branch-Level-8'
Gibson0918 Feb 1, 2023
6b26a8e
Refactor Duke to use more OOP
Gibson0918 Feb 2, 2023
3893500
Merge remote-tracking branch 'upstream/add-gradle-support'
Gibson0918 Feb 2, 2023
a8d7d89
Merge remote-tracking branch 'origin/add-gradle-support'
Gibson0918 Feb 3, 2023
26a98f0
Fixed bugs related to datetime and organize duke into packages
Gibson0918 Feb 4, 2023
c722460
add Gradle to Duke
Gibson0918 Feb 4, 2023
dcb5baf
Added JUnit tests for Duke
Gibson0918 Feb 5, 2023
4dc52da
Merge branch 'master' of https://github.com/Gibson0918/ip
Gibson0918 Feb 6, 2023
1756cea
Release duke to the wild
Gibson0918 Feb 6, 2023
391e222
Added Java Docs to Duke
Gibson0918 Feb 7, 2023
ca66669
Added StringBuilder class to Duke
Gibson0918 Feb 7, 2023
fc417a2
Completed Level 9
Gibson0918 Feb 7, 2023
818d54e
Tweak Duke's code
Gibson0918 Feb 7, 2023
451fc56
Level 10 Completed
Gibson0918 Feb 8, 2023
6a11a02
Remove commented lines
Gibson0918 Feb 8, 2023
9b4f6d8
Added more Java Docs
Gibson0918 Feb 9, 2023
cbb24a9
Improve Duke's code quality
Gibson0918 Feb 10, 2023
cad9985
Update README.md
Gibson0918 Feb 13, 2023
486c91d
Add Update feature to Duke
Gibson0918 Feb 14, 2023
77e726e
Updated GUI and added set method to tasklist
Gibson0918 Feb 14, 2023
f94e91b
Added Assertions to Duke
Gibson0918 Feb 14, 2023
7d857d1
Merge pull request #2 from Gibson0918/branch-A-Assertions
Gibson0918 Feb 14, 2023
18c5321
Update README.md
Gibson0918 Feb 15, 2023
e2a6d89
Fixed some bugs relating to DateTime format and Duke exit command
Gibson0918 Feb 15, 2023
14367ac
Merge branch 'master' of https://github.com/Gibson0918/ip
Gibson0918 Feb 15, 2023
5954700
Added Ui image for docs
Gibson0918 Feb 15, 2023
b272b25
Clean up code for checkstyle
Gibson0918 Feb 17, 2023
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
201 changes: 0 additions & 201 deletions src/main/java/Duke.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package duke;

public class Deadline extends Task {

protected String by;
Expand Down
55 changes: 55 additions & 0 deletions src/main/java/duke/Duke.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package duke;

import duke.exception.DukeException;
import duke.ui.Ui;
import duke.command.Command;
import duke.parser.Parser;
import duke.storage.Storage;

import java.util.Scanner;
import java.io.FileNotFoundException;

public class Duke {

enum Type {
TODO, DEADLINE, EVENT
}

private static TaskList tasks;
private static Ui ui;
private static final String FILEPATH = "duke.txt";
private static Storage storage;
public static void main(String[] args) {
initDuke();
}

public static void initDuke() {
ui.displayLogo();
ui = new Ui();
storage = new Storage(FILEPATH);
try {
tasks = new TaskList(storage.loadFile());

} catch (FileNotFoundException e) {
tasks = new TaskList();
}
System.out.println(tasks);
boolean startDuke = true;
Scanner sc = new Scanner(System.in);
while (startDuke) {
try {
String command = sc.nextLine();
ui.displayLine();
Command c = Parser.parse(command);
c.initCommand(tasks, ui, storage);
startDuke = c.isTerminated();
}
catch (DukeException e) {
System.out.println(e);
}
finally {
ui.displayLine();
}
}
}
}
2 changes: 2 additions & 0 deletions src/main/java/Event.java → src/main/java/duke/Event.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package duke;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

Expand Down
10 changes: 1 addition & 9 deletions src/main/java/Task.java → src/main/java/duke/Task.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
package duke;
public abstract class Task {
protected String description;
protected boolean isDone;
protected static int taskCount = 0;

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

public static void incrementTaskCount() {
taskCount++;
}

public static void decrementTaskCount() {
taskCount--;
}

public String getStatusIcon() {
return (isDone ? "X" : " ");
}
Expand Down
52 changes: 52 additions & 0 deletions src/main/java/duke/TaskList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package duke;

import java.util.ArrayList;
import java.util.List;


public class TaskList extends ArrayList<Task> {
private List<Task> taskList;

public TaskList() {
taskList = new ArrayList<>();
}

public TaskList(List<Task> taskList) {
this.taskList = taskList;
}

public Task geTask(int taskID) {
return taskList.get(--taskID);
}

public void addTask(Task task) {
taskList.add(task);
}

public Task deleteTask(int taskID) {
Task task = taskList.remove(--taskID);
return task;
}




public boolean isEmpty() {
return taskList.isEmpty();
}

@Override
public String toString() {
String output = "";
if (!taskList.isEmpty()) {
output = "Here are the tasks in your list: \n";
int count = 1;
for (Task t : taskList) {
output += count + "." + t.toString() + "\n";
}
} else {
output = "You have no tasks";
}
return output;
}
}
2 changes: 2 additions & 0 deletions src/main/java/Todo.java → src/main/java/duke/Todo.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package duke;

public class Todo extends Task {
public Todo(String description) {
super(description);
Expand Down
2 changes: 2 additions & 0 deletions Type.java → src/main/java/duke/Type.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package duke;

public enum Type {
TODO, DEADLINE, EVENT
}
23 changes: 23 additions & 0 deletions src/main/java/duke/command/AddCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package duke.command;

import duke.TaskList;
import duke.ui.Ui;
import duke.Task;
import duke.storage.Storage;


public class AddCommand extends Command {
private Task task;

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

@Override
public void initCommand(TaskList tasks, Ui ui, Storage storage) {
tasks.addTask(task);
storage.saveData(tasks);
ui.displayAddTaskMessage(task, tasks);
}

}
Loading