Skip to content

Commit

Permalink
Bugs fixed in using empty find command and mulfunctions of validating…
Browse files Browse the repository at this point in the history
… time
  • Loading branch information
J-Y-Yan committed Oct 21, 2023
1 parent da1aa7c commit 20bc921
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 13 deletions.
5 changes: 3 additions & 2 deletions data/backup_taskList.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
1. [T][ ] ok
2. [T][ ] this is 2
1. [T][X] read book
2. [D][X] read book (by: 10月 22 2023 12:00 下午)
3. [E][ ] read book (from: 10月 20 2023 12:00 下午 to: 10月 27 2023 11:59 下午)
5 changes: 3 additions & 2 deletions data/taskList.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
1. [T][ ] ok
2. [T][ ] this is 2
1. [T][X] read book
2. [D][X] read book (by: 10月 22 2023 12:00 下午)
3. [E][ ] read book (from: 10月 20 2023 12:00 下午 to: 10月 27 2023 11:59 下午)
2 changes: 1 addition & 1 deletion src/main/java/Oriento/Oriento.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Oriento {
public static int taskCount = 0;
public static Task[] list = new Task[100];

public static void main(String[] args) throws IOException, OrientoException {
public static void main(String[] args) throws IOException {
Text.printWelcomeMessage();
Scanner keyboard = new Scanner(System.in);
FileIO.outputFileInitialization();
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/command/DeadlineCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void executeCommand(){
} catch (IOException io){
System.out.println("OMG! Something went wrong! Please check if the source files are available.");
} catch (InvalidTimeException ite){
System.out.println("Please check your schedule.");
System.out.println("Deadline is over already!");
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/command/EventCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void executeCommand(){
} catch (IOException io){
System.out.println("OMG! Something went wrong! Please check if the source files are available.");
} catch (InvalidTimeException d){
System.out.println("Please check your period again.");
System.out.println(d.getMessage());
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/command/UnmarkCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
import static fileIO.FileIO.overwriteToFile;

public class UnmarkCommand extends Command{

private String index;

/**
* similar to mark
*/
private String index;

public UnmarkCommand(String index) {
super(false);
this.index = index;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/commandFormat/CommandFormat.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public static int getTaskNo(String taskNum) {
public static boolean missingOrExtraTaskDescription(String[] cmd){
if (cmd.length == 1){
if(cmd[0].equals("todo") || cmd[0].equals("event") || cmd[0].equals("deadline")
|| cmd[0].equals("mark") || cmd[0].equals("unmark") || cmd[0].equals("delete")){
|| cmd[0].equals("mark") || cmd[0].equals("unmark") || cmd[0].equals("delete")
|| cmd[0].equals("find")){
System.out.println("Please describe your target.");
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/commandFormat/TimeParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class TimeParser {
* @return LocalDataTIme object
*/
public static LocalDateTime parseDateTime(String input) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("M/d/yyyy Hmm");
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd/MM/yyyy HHmm");
return LocalDateTime.parse(input, formatter);
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/exception/InvalidTimeException.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ public class InvalidTimeException extends Exception {
public InvalidTimeException(String message) {
super(message);
}

}
4 changes: 2 additions & 2 deletions src/main/java/task/Event.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public Event(String description, String start, String end) {
* if failed to parse input, assume the user is true
* @InvalidTimeException caught in EventCommand class
*/
public static Event newEventTask(String userCommand) throws OrientoException, InvalidTimeException {
public static Event newEventTask(String userCommand) throws OrientoException,InvalidTimeException {
//command format: event project meeting /from Mon 2pm /to 4pm
if (!(userCommand.contains("/from")) || !(userCommand.contains("/to"))){
throw new OrientoException("Oh, no! There is no '/from' or '/to' ");
Expand Down Expand Up @@ -52,10 +52,10 @@ public static Event newEventTask(String userCommand) throws OrientoException, In
* 2. end time is over already
*/
private static void testTimeInput(String startTime, String endTime) throws InvalidTimeException {
LocalDateTime now = LocalDateTime.now();
try{
LocalDateTime start = TimeParser.parseDateTime(startTime);
LocalDateTime end = TimeParser.parseDateTime(endTime);
LocalDateTime now = LocalDateTime.now();
if(end.isBefore(now)){
throw new InvalidTimeException("The event is ended. Please check the end time again.");
}
Expand Down

0 comments on commit 20bc921

Please sign in to comment.