forked from nus-cs2103-AY2324S1/ip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6656f9e
commit f56c1a7
Showing
9 changed files
with
146 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import java.text.ParseException; | ||
import java.text.SimpleDateFormat; | ||
import java.util.Date; | ||
|
||
public class DateConverter { | ||
public static String convertDate(String inputDateStr) { | ||
try { | ||
// Define a SimpleDateFormat for parsing the input date | ||
SimpleDateFormat inputDateFormat = new SimpleDateFormat("MMM dd yyyy"); | ||
|
||
// Parse the input date string to obtain a Date object | ||
Date inputDate = inputDateFormat.parse(inputDateStr); | ||
|
||
// Convert the Date to a LocalDate if needed | ||
// For this example, we'll convert it to a string in "yyyy/MM/dd" format | ||
SimpleDateFormat outputDateFormat = new SimpleDateFormat("yyyy/MM/dd"); | ||
|
||
// Format the Date as a string in "yyyy/MM/dd" format | ||
return outputDateFormat.format(inputDate); | ||
} catch (ParseException e) { | ||
// Handle any parsing errors | ||
return "Invalid date format: " + e.getMessage(); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import java.util.ArrayList; | ||
|
||
public class TaskList { | ||
protected ArrayList<Task> tasks; | ||
|
||
public TaskList() { | ||
this.tasks = new ArrayList<>(); | ||
} | ||
|
||
public void addTask(Task task) { | ||
tasks.add(task); | ||
System.out.println("Got it. I've added this task:"); | ||
System.out.println(" " + task); | ||
System.out.println("Now you have " + tasks.size() + " tasks in the list."); | ||
} | ||
|
||
public boolean isEmpty() { | ||
return tasks.isEmpty(); | ||
} | ||
|
||
public void deleteTask(int taskNumber) { | ||
Task task = tasks.get(taskNumber); | ||
tasks.remove(taskNumber); | ||
System.out.println("Noted. I've removed this task: \n" + " " + task); | ||
System.out.println("Now you have " + tasks.size() + " tasks in the list."); | ||
} | ||
|
||
public void set(int index, Task task) { | ||
tasks.set(index, task); | ||
} | ||
|
||
public int size() { | ||
return tasks.size(); | ||
} | ||
|
||
public Task get(int index) { | ||
return tasks.get(index); | ||
} | ||
|
||
public ArrayList<Task> toArrayList() { | ||
return tasks; | ||
} | ||
|
||
public void markTaskAsDone(int taskNumber) { | ||
Task task = tasks.get(taskNumber); | ||
task.setMarked(true); | ||
tasks.set(taskNumber, task); | ||
System.out.println("Nice! I've marked this task as done:\n" + " " + tasks.get(taskNumber)); | ||
} | ||
|
||
public void unmarkTask(int taskNumber) { | ||
Task task = tasks.get(taskNumber); | ||
task.setMarked(false); | ||
tasks.set(taskNumber, task); | ||
System.out.println("OK, I've marked this task as not done yet:\n" + " " + tasks.get(taskNumber)); | ||
} | ||
|
||
public void listOfTasks() { | ||
System.out.println("Here are the tasks in your list: "); | ||
if (!tasks.isEmpty()) { | ||
for (int i = 1; i <= tasks.size(); i++) { | ||
System.out.println(i + "." + tasks.get(i - 1)); | ||
} | ||
} | ||
} | ||
|
||
// Add other methods for task list operations | ||
|
||
|
||
|
||
public String toString() { | ||
return tasks.toString(); | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters