-
Notifications
You must be signed in to change notification settings - Fork 114
[Low Beverly] iP #107
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
Open
Bev-low
wants to merge
60
commits into
nus-cs2113-AY2425S1:master
Choose a base branch
from
Bev-low:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Low Beverly] iP #107
Changes from 27 commits
Commits
Show all changes
60 commits
Select commit
Hold shift + click to select a range
ab3b287
Commit change in Bot Name
Bev-low 85bd6a5
Commit change Logo
Bev-low afcf4e7
Commit change text
Bev-low 5c3cc13
Commit Final Version
Bev-low 9e97cef
Commit Final Version
Bev-low eb4b65e
added an echo function
Bev-low 9fbf0c6
Commit Echo Function and Gitignore Class
Bev-low 89920cc
Commit update Echo
Bev-low b31dc7b
Commit update Echo
Bev-low dced9db
Added A tasklist maker
Bev-low 7014334
Mark as Done Algo added. Created a Task Class and the List class is m…
Bev-low 2076ea4
Mark as Done Algo added. Created a Task Class and the List class is m…
Bev-low 258892c
Add coding standards
Bev-low 50d89a6
Add coding standards
Bev-low f67a83f
Add Level-4
Bev-low 1e1bb0c
Add Level-4-bugfixes
Bev-low 0085d8f
Add Level-4-bugfixes
Bev-low 01ea11f
Add A-TextIuTesting
Bev-low 9893111
Add A-CodeQuality
Bev-low 0573acf
Add A-CodeQuality
Bev-low 2361592
Add Level-5
Bev-low f5fcf14
Add Level-5-MasterBranch
Bev-low 1996a83
Add Level-5-MasterBranch
Bev-low 166d83b
Add Level-5-MasterBranch
Bev-low 9f1bc2c
Add Level-5-MasterBranch
Bev-low 0e6bae6
Merge branch 'master' into branch-level-5
Bev-low 56d0e22
Add A-Packages
Bev-low 3b75765
Add Level-5-bug fixes
Bev-low b63bd20
Add Level-6+A-Collections
Bev-low 79a8871
Add Level-6+A-Collections
Bev-low 3d1361d
Add Level-7
Bev-low 1527ab8
Merge branch 'branch-level-6'
Bev-low d8923aa
Add Level-7-conflicts
Bev-low 91f00e2
Add Level-7-bug-fixes
Bev-low e7f6588
Add A-collections
Bev-low 2a63fdc
Add A-Exceptions
Bev-low 6c8dfc5
Add A-Exceptions
Bev-low 3be8c65
Add A-MoreOOP
Bev-low adabff1
Add Level-8
Bev-low 7ce6169
Add Level-9
Bev-low 562d87d
Add A-JavaDoc
Bev-low 1289341
Merge pull request #1 from Bev-low/branch-level-8
Bev-low cdf3bfb
Merge branch 'master' into branch-level-9
Bev-low 3a40699
Merge pull request #2 from Bev-low/branch-level-9
Bev-low 74dd30e
Merge branch 'master' into A-JavaDoc
Bev-low 5de4602
Merge pull request #3 from Bev-low/A-JavaDoc
Bev-low 9d6381c
Add A-JavaDoc-fixes
Bev-low 769a80b
Add A-UserGuide
Bev-low 86639ed
Resolved outstanding merge conflicts, keeping master version
Bev-low 95f37b6
Add A-UserGuide-fixes
Bev-low c383183
Merge branch-level-6 into master, keeping master version
Bev-low e2cc91e
Add A-Jar2.0
Bev-low 8dc1a20
Add A-Formatting-Fixes
Bev-low 2fa2497
Add A-added Gradle Checks
Bev-low b32e1fe
Add Bug-Fixes
Bev-low 4b1bc2e
Add Bug-Fixes
Bev-low c9478f8
Add Fix User-Guide
Bev-low 0f6e5f1
Add Fix user-guide
Bev-low 56dd508
Add Fix user-guide
Bev-low 2b98a0b
Add Updating ReadMe.md
Bev-low File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,20 @@ | ||
| package ChattyCharlie; | ||
|
|
||
| public class CharlieExceptions extends Exception{ | ||
| public CharlieExceptions(String message){ | ||
| super(message); | ||
| } | ||
|
|
||
| // Static factory methods for common exceptions | ||
| public static CharlieExceptions missingDescription(CommandType command) { | ||
| return new CharlieExceptions("Oop, the task for " + command + " cannot be empty."); | ||
| } | ||
|
|
||
| public static CharlieExceptions missingDeadline() { | ||
| return new CharlieExceptions("When is this due?"); | ||
| } | ||
|
|
||
| public static CharlieExceptions missingTimes() { | ||
| return new CharlieExceptions("Your event is missing or incomplete!"); | ||
| } | ||
| } |
This file contains hidden or 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,156 @@ | ||
| package ChattyCharlie; | ||
|
|
||
| import ChattyCharlie.Task.Deadline; | ||
| import ChattyCharlie.Task.Event; | ||
| import ChattyCharlie.Task.Todo; | ||
|
|
||
| import java.util.Scanner; | ||
|
|
||
| public class ChattyCharlie { | ||
|
|
||
| //MAIN ALGO | ||
| public static void ScheduleMaker() throws CharlieExceptions { //Echo as a function | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that names for methods are supposed to be in camelCase |
||
| String line = null; | ||
| //make the scanner | ||
| Scanner in = new Scanner(System.in); | ||
|
|
||
| //create an instance of list class | ||
| List list = new List(); | ||
| CommandType command = null; | ||
| //accept an insert | ||
| while (true) { | ||
| try { | ||
| //takes in an input | ||
| System.out.print(StringDesign.YOU); | ||
| line = in.nextLine(); | ||
| System.out.println(StringDesign.LINE); | ||
|
|
||
| //get the first word to see the command type | ||
| String firstWord = line.split(" ")[0]; | ||
|
|
||
| command = CommandType.valueOf(firstWord.toUpperCase()); | ||
|
|
||
| //start the different command types | ||
| switch (command) { | ||
| case TODO: | ||
| //remove the words todo | ||
| String todoDescription = line.substring(4).trim(); | ||
|
|
||
| // Check if the description is empty | ||
| if (todoDescription.isEmpty()) { | ||
| throw CharlieExceptions.missingDescription(command); | ||
| } | ||
|
|
||
| //add the todo task | ||
| list.addTask(new Todo(todoDescription)); | ||
| System.out.println(StringDesign.SPACE + "Added todo: " + todoDescription); | ||
| System.out.println(StringDesign.LINE); | ||
| break; | ||
| case DEADLINE: | ||
| //remove the deadline word and split into description and deadline time | ||
| String[] deadlineParts = line.substring(8).trim().split(" by "); | ||
| String deadlineDescription; | ||
| String by; | ||
|
|
||
| //handle errors | ||
| if (deadlineParts[0].isEmpty()) { | ||
| throw CharlieExceptions.missingDescription(command); | ||
| } else if (deadlineParts.length < 2) { | ||
| throw CharlieExceptions.missingDeadline(); | ||
| } else { | ||
| deadlineDescription = deadlineParts[0].trim(); | ||
| } | ||
|
|
||
| by = deadlineParts[1].trim(); | ||
|
|
||
| list.addTask(new Deadline(deadlineDescription, by)); | ||
| System.out.println(StringDesign.SPACE + "Added deadline: " + deadlineDescription + " (by: " + by + ")"); | ||
| System.out.println(StringDesign.LINE); | ||
| break; | ||
| case EVENT: | ||
| //remove the event word and split into the description and event times | ||
| String[] eventParts = line.substring(5).trim().split("from"); | ||
| String description; | ||
| String startTime; | ||
| String endTime; | ||
|
|
||
| // Error handling for Events | ||
| if (eventParts[0].isEmpty()) { //no description | ||
| throw CharlieExceptions.missingDescription(command); | ||
| } else if (eventParts.length < 2) { //no from | ||
| throw CharlieExceptions.missingTimes(); | ||
| } else { | ||
| description = eventParts[0].trim(); | ||
| } | ||
|
|
||
| String[] eventTimes = eventParts[1].trim().split(" to "); | ||
|
|
||
| if (eventTimes.length < 2) { | ||
| throw CharlieExceptions.missingTimes(); //change this to no end date | ||
| } | ||
|
|
||
| if (eventTimes[0].isEmpty() || eventTimes[1].isEmpty()) { | ||
| throw CharlieExceptions.missingTimes(); | ||
| } else { | ||
| startTime = eventTimes[0].trim(); | ||
| endTime = eventTimes[1].trim(); | ||
| } | ||
|
|
||
| //add the event task | ||
| list.addTask(new Event(description, startTime, endTime)); | ||
| System.out.println(StringDesign.SPACE + "Added event: " + description | ||
| + " (from: " + startTime + ", to: " + endTime + ")"); | ||
| System.out.println(StringDesign.LINE); | ||
| break; | ||
| case MARK: | ||
| //remove the mark word | ||
| String markIndex = line.substring(4).trim(); | ||
| //convert the string number into an int | ||
| int markNo = Integer.parseInt(markIndex) -1; //convert to array | ||
| //mark it | ||
| list.mark(markNo); | ||
| System.out.println(StringDesign.LINE); | ||
| break; | ||
| case UNMARK: | ||
| //remove the unmark word | ||
| String unmarkIndex = line.substring(6).trim(); | ||
| //convert the string no into a int | ||
| int unmarkNo = Integer.parseInt(unmarkIndex) -1; | ||
| //mark it | ||
| list.unmark(unmarkNo); | ||
| System.out.println(StringDesign.LINE); | ||
| break; | ||
| case BYE: | ||
| return; //just exit | ||
| case LIST: | ||
| list.printList(); | ||
| System.out.println(StringDesign.LINE); | ||
| break; | ||
| default: | ||
| break; | ||
| } | ||
| } catch (CharlieExceptions e) { | ||
| // Handle custom exceptions and prompt for new input | ||
| System.out.println(e.getMessage()); | ||
| System.out.println(StringDesign.LINE); | ||
| continue; // Continue to ask for input after throwing exception | ||
| } catch (IllegalArgumentException e) { | ||
| System.out.println("Oop, did you make a typo?"); | ||
| System.out.println(StringDesign.LINE); | ||
| continue; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public static void main (String[]args) throws CharlieExceptions{ | ||
| System.out.println(StringDesign.LOGO + StringDesign.CHARLIE + StringDesign.GREETING); | ||
| ScheduleMaker(); | ||
| System.out.println(StringDesign.CHARLIE + StringDesign.FAREWELL); | ||
|
|
||
| } | ||
| } | ||
This file contains hidden or 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,11 @@ | ||
| package ChattyCharlie; | ||
|
|
||
| public enum CommandType { | ||
| TODO, | ||
| DEADLINE, | ||
| EVENT, | ||
| MARK, | ||
| UNMARK, | ||
| BYE, | ||
| LIST | ||
| } |
This file contains hidden or 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,102 @@ | ||
| package ChattyCharlie; | ||
|
|
||
| import ChattyCharlie.Task.Deadline; | ||
| import ChattyCharlie.Task.Event; | ||
| import ChattyCharlie.Task.Task; | ||
| import ChattyCharlie.Task.Todo; | ||
|
|
||
| //LIST CLASS | ||
| public class List { | ||
| //make a list of task | ||
| private Task[] tasks; | ||
| private int size; | ||
|
|
||
| //constructor | ||
| public List() { | ||
| tasks = new Task[100]; | ||
| size = 0; | ||
| } | ||
|
|
||
| //Method to add an item to the list | ||
| public void addTask(Task task) { | ||
| //add the text into the list | ||
| tasks[size] = task; | ||
| //account for the item | ||
| size++; | ||
| } | ||
|
|
||
| public Task[] getList() { | ||
| return this.tasks; | ||
| } | ||
|
|
||
| public int getSize() { | ||
| return size; | ||
| } | ||
|
|
||
| //To mark | ||
| public void mark(int index) { | ||
| if (index >= 0 && index < size) { | ||
| tasks[index].markTask(); | ||
| int remainingTask = countUnmarkedTasks(); | ||
| System.out.println(StringDesign.SPACE + "Well Done! 1 task down, " + remainingTask + " to go."); | ||
| System.out.println(StringDesign.SPACE+ "[" + tasks[index].getMarkedStatus() + "] " + tasks[index].getDescription()); | ||
| } else { | ||
| System.out.println(StringDesign.SPACE+ "Invalid task number."); | ||
| } | ||
| } | ||
|
|
||
| //To unmark | ||
| public void unmark(int index) { | ||
| if (index >= 0 && index < size) { | ||
| tasks[index].unmarkTask(); | ||
| int remainingTask = countUnmarkedTasks(); | ||
| System.out.println(StringDesign.SPACE + "Hmmm, not quite done yet, " + remainingTask + " to go."); | ||
| System.out.println(StringDesign.SPACE + "[" + tasks[index].getMarkedStatus() + "] " + tasks[index].getDescription()); | ||
| } else { | ||
| System.out.println(StringDesign.SPACE + "Invalid task number."); | ||
| } | ||
| } | ||
|
|
||
| //To print list | ||
| public void printList() { | ||
| //print all | ||
| int remainingTask = countUnmarkedTasks(); | ||
| System.out.println("ToDo List:"); | ||
| System.out.println("pending Task: " + remainingTask); | ||
| for (int i = 0; i < size; i++) { | ||
| int number = i+1; | ||
| Task task = tasks[i]; | ||
| //use a switch to determine | ||
| switch (task.getType()) { | ||
| case TODO: | ||
| Todo todoTask = (Todo) task; | ||
| System.out.println(StringDesign.SPACE + number + ".[T][" + todoTask.getMarkedStatus() + "] " | ||
| + todoTask.getDescription()); | ||
| break; | ||
| case DEADLINE: | ||
| Deadline deadlineTask = (Deadline) task; | ||
| System.out.println(StringDesign.SPACE + number + ".[D][" + deadlineTask.getMarkedStatus() + "] " | ||
| + deadlineTask.getDescription() + " (by: " + deadlineTask.getBy() + ")"); | ||
| break; | ||
| case EVENT: | ||
| Event eventTask = (Event) task; | ||
| System.out.println(StringDesign.SPACE + number + ".[E][" + eventTask.getMarkedStatus() + "] " | ||
| + eventTask.getDescription() + " (from: " + eventTask.getStart() + " to: " + eventTask.getEnd() + ")"); | ||
| break; | ||
| default: | ||
| break; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Method to count how many tasks are unmarked | ||
| public int countUnmarkedTasks() { | ||
| int count = 0; | ||
| for (int i = 0; i < size; i++) { | ||
| if (!tasks[i].getIsDoneStatus()) { | ||
| count++; | ||
| } | ||
| } | ||
| return count; | ||
| } | ||
| } |
This file contains hidden or 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,25 @@ | ||
| package ChattyCharlie; | ||
|
|
||
| public class StringDesign { | ||
| //this class is for all my Strings and designs | ||
| public static final String LOGO = " _____ \n" | ||
| + " / \\ \n" | ||
| + " | O O | \n" | ||
| + " | \\___/ | \n" | ||
| + " \\_____/ \n" | ||
| + " /\\_____/\\ \n" | ||
| + " | | \n" | ||
| + " | | \n" | ||
| + " |_______| \n" | ||
| + " \n"; | ||
| public static final String CHARLIE = "Charlie: "; | ||
|
|
||
| public static final String GREETING = "Hello! I'm ChattyCharlie, your consistent buddy.\n" | ||
| + " What shall we do today?\n"; | ||
|
|
||
| public static final String FAREWELL = "All the best in clearing your list!"; | ||
|
|
||
| public static final String SPACE = " "; | ||
| public static final String LINE = "------------"; | ||
| public static final String YOU = "User: "; | ||
| } |
This file contains hidden or 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,23 @@ | ||
| package ChattyCharlie.Task; | ||
|
|
||
| import ChattyCharlie.CommandType; | ||
|
|
||
| //Deadline Class | ||
| public class Deadline extends Task { | ||
| protected String by; | ||
|
|
||
| public Deadline(String description, String by) { | ||
| super(description, CommandType.DEADLINE); | ||
| this.by = by; | ||
| } | ||
| public void setBy(String by) { | ||
| this.by = by; | ||
| } | ||
| public String getBy() { | ||
| return by; | ||
| } | ||
| @Override | ||
| public String toString() { | ||
| return "[D]" + super.toString() + " (by: " + by + ")"; | ||
| } | ||
| } |
This file contains hidden or 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,37 @@ | ||
| package ChattyCharlie.Task; | ||
|
|
||
| import ChattyCharlie.CommandType; | ||
|
|
||
| //Events | ||
| public class Event extends Task { | ||
| protected String start; | ||
| protected String end; | ||
|
|
||
| public Event(String description, String start, String end) { | ||
| super(description, CommandType.EVENT); | ||
| this.start = start; | ||
| this.end = end; | ||
| } | ||
|
|
||
| public void setStart(String start) { | ||
| this.start = start; | ||
| } | ||
|
|
||
| public String getStart() { | ||
| return start; | ||
| } | ||
|
|
||
|
|
||
| public void setEnd(String end) { | ||
| this.end = end; | ||
| } | ||
|
|
||
| public String getEnd() { | ||
| return end; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "[E]" + super.toString() + " (from: " + start + " to: " + end + ")"; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can consider removing this comment