Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
68c58c1
Add Gradle support
May 24, 2020
03523ec
Bump gradle and lib version
Eclipse-Dominator Aug 5, 2023
81a9c53
build.gradle: Prevent generating a second JAR file
aureliony Jul 16, 2024
f8bb5fb
Level-0
mikolajed Aug 21, 2024
4b6a8b1
Add Level-1: echoing
mikolajed Aug 25, 2024
66187d7
Add Level-2: adding, listing
mikolajed Aug 26, 2024
e62452e
Add Level-3: marking
mikolajed Aug 26, 2024
934dabd
Add minor code quality changes
mikolajed Sep 4, 2024
5089664
Add new Task derived class
mikolajed Sep 4, 2024
266dda4
Add Level-4: ToDos, Events, Deadlines
mikolajed Sep 8, 2024
37e3f9b
Improve code quality
mikolajed Sep 8, 2024
97047ec
Add automated testing
mikolajed Sep 8, 2024
f4594ed
Minor UI change
mikolajed Sep 8, 2024
c7d735b
Add Level-5: error handling
mikolajed Sep 8, 2024
7aead71
Merge branch 'branch-Level-5'
mikolajed Sep 8, 2024
5682555
Add A-Packages
mikolajed Sep 8, 2024
73d4c22
Add Level-6: deleting
mikolajed Sep 18, 2024
e117036
Add Level-7: saving
mikolajed Sep 18, 2024
a76c9ad
Merge branch 'branch-Level-6'
mikolajed Sep 19, 2024
f1a9136
Merge branch 'branch-Level-7'
mikolajed Sep 19, 2024
bb903a4
A-MoreOOP: Add TaskList class
mikolajed Sep 28, 2024
7119092
A-MoreOOP: Add Storage
mikolajed Sep 29, 2024
bcd72f0
Update pythia.txt
mikolajed Sep 29, 2024
7cb4643
A-MoreOOP: Update Ui
mikolajed Sep 29, 2024
a144c7c
A-MoreOOP: Refactor Parser
mikolajed Sep 29, 2024
a58e2d5
Add Level-9: finding tasks
mikolajed Oct 3, 2024
6702bb4
Add Level-8
mikolajed Oct 3, 2024
4f34a67
Merge pull request #1 from mikolajed/branch-Level-8
mikolajed Oct 3, 2024
acf8c93
Merge pull request #2 from mikolajed/branch-Level-9
mikolajed Oct 3, 2024
44da9b8
Add JavaDoc comments
mikolajed Oct 7, 2024
2c38341
Update README.md
mikolajed Oct 8, 2024
ed28a9d
Update README.md
mikolajed Oct 8, 2024
3b5a414
Update README.md
mikolajed Oct 8, 2024
1031f84
Minor bug fix
mikolajed Oct 8, 2024
ede59cb
Update README.md
mikolajed Oct 8, 2024
cbc2fdc
Update README.md
mikolajed Oct 8, 2024
2f33e97
Update README.md
mikolajed Oct 8, 2024
cb9105a
Update README.md
mikolajed Oct 8, 2024
7762786
Update README.md
mikolajed Oct 8, 2024
5e18e76
Bug fix
mikolajed Oct 8, 2024
e561e10
Bug fix
mikolajed Oct 8, 2024
a754e2e
Merge branch 'add-gradle-support'
mikolajed Oct 8, 2024
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
5 changes: 1 addition & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# Duke User Guide

// Update the title above to match the actual product name

# Pythia User Guide
// Product screenshot goes here

// Product intro goes here
Expand Down
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.

38 changes: 38 additions & 0 deletions src/main/java/IO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import java.util.ArrayList;
import java.util.Scanner;

public class IO {
private static Scanner scanner;;

public static void init() {
scanner = new Scanner(System.in);
}

public static void printResponse(String text) {
String lineSeparator = "-------------------------------";
text = lineSeparator + "\n" + text + "\n" + lineSeparator + "\n";
String formattedText = text.replaceAll("(?m)^", "\t");
System.out.print(formattedText);
}

public static String getRequest() {
return scanner.nextLine();
}

public static void printAddedTask(String text) {
printResponse(text.toLowerCase());
}

public static void printTaskList(ArrayList<Task> taskList) {
StringBuilder taskListString = new StringBuilder();
for (int i = 0; i < taskList.size(); i++) {
taskListString.append(i + 1);
taskListString.append(". ");
taskListString.append(taskList.get(i).toString());
if (i < taskList.size() - 1) {
taskListString.append("\n");
}
}
printResponse(taskListString.toString());
}
}
77 changes: 77 additions & 0 deletions src/main/java/Pythia.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import java.util.ArrayList;

public class Pythia {
private static String botName = "Pythia";
private static String logo =
"____ _ _ _ \n" +
"| _ \\ _ _| |_| |__ (_) __ _ \n" +
"| |_) | | | | __| '_ \\| |/ _` |\n" +
"| __/| |_| | |_| | | | | (_| |\n" +
"|_| \\__, |\\__|_| |_|_|\\__,_|\n" +
" |___/ ";

private static boolean byeSaid = false;
private static ArrayList<Task> taskList = new ArrayList<Task>();

public static void greet() {
String helloMsg = "Welcome, seeker. I am " + botName + ".\n" +
"What brings you here?";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think the original looks good already.

IO.printResponse(helloMsg);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Spacing looks a little off to me.

}

public static void echo(String text) {
IO.printResponse(text);
}

public static void sayBye() {
String byeMsg = "Your path is set. Until we meet again.";
IO.printResponse(byeMsg);
byeSaid = true;
}

public static void listTasks() {
IO.printTaskList(taskList);
}

public static void chooseAction(String request) {
String key = request.split(" ")[0];
String value = "";

if (request.split(" ").length > 1) {
value = request.substring(key.length() + 1);
}

switch (key) {
case "bye" -> sayBye();
case "list" -> listTasks();
case "add" -> addTask(value);
case "mark" -> markTask(Integer.parseInt(value));
default -> IO.printResponse("Hmm. I am not sure what you mean.");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good that you handled edge case.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nice change to make this much more readable!

}
}

public static void addTask(String taskName) {
taskList.add(new Task(taskName));
IO.printAddedTask("added: " + taskName);
}

public static void markTask(Integer taskNumber) {
if (taskNumber <= taskList.size()) {
taskList.get(taskNumber - 1).markAsDone();
String msg = "Nice! I've marked this task as done:\n\t" + taskList.get(taskNumber - 1).toString();
IO.printResponse(msg);
} else {
IO.printResponse("There is no such task :(");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

good change to follow coding standard.

}
}

public static void main(String[] args) {
IO.init();
greet();

while (!byeSaid) {
String request = IO.getRequest();
chooseAction(request);
}
}
}
39 changes: 39 additions & 0 deletions src/main/java/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
public class Task {
private String name;
private boolean status;

public Task(String name, boolean status) {
this.name = name;
this.status = status;
}

public Task(String name) {
this.name = name;
this.status = false;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

public void markAsDone() {
this.status = true;
}

public void markAsNotDone() {
this.status = false;
}

public String getName() {
return name;
}

public boolean getStatus() {
return status;
}

@Override
public String toString() {
if (status == false) {
return "[ ] " + name;
} else {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good changes to maintain code quality standard.

return "[X] " + name;
}
}
}