Skip to content
Open
Show file tree
Hide file tree
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 Aug 19, 2024
85bd6a5
Commit change Logo
Bev-low Aug 19, 2024
afcf4e7
Commit change text
Bev-low Aug 19, 2024
5c3cc13
Commit Final Version
Bev-low Aug 19, 2024
9e97cef
Commit Final Version
Bev-low Aug 19, 2024
eb4b65e
added an echo function
Bev-low Aug 29, 2024
9fbf0c6
Commit Echo Function and Gitignore Class
Bev-low Aug 29, 2024
89920cc
Commit update Echo
Bev-low Aug 29, 2024
b31dc7b
Commit update Echo
Bev-low Aug 29, 2024
dced9db
Added A tasklist maker
Bev-low Aug 29, 2024
7014334
Mark as Done Algo added. Created a Task Class and the List class is m…
Bev-low Aug 29, 2024
2076ea4
Mark as Done Algo added. Created a Task Class and the List class is m…
Bev-low Aug 29, 2024
258892c
Add coding standards
Bev-low Aug 30, 2024
50d89a6
Add coding standards
Bev-low Aug 30, 2024
f67a83f
Add Level-4
Bev-low Sep 4, 2024
1e1bb0c
Add Level-4-bugfixes
Bev-low Sep 4, 2024
0085d8f
Add Level-4-bugfixes
Bev-low Sep 4, 2024
01ea11f
Add A-TextIuTesting
Bev-low Sep 5, 2024
9893111
Add A-CodeQuality
Bev-low Sep 5, 2024
0573acf
Add A-CodeQuality
Bev-low Sep 5, 2024
2361592
Add Level-5
Bev-low Sep 10, 2024
f5fcf14
Add Level-5-MasterBranch
Bev-low Sep 10, 2024
1996a83
Add Level-5-MasterBranch
Bev-low Sep 10, 2024
166d83b
Add Level-5-MasterBranch
Bev-low Sep 10, 2024
9f1bc2c
Add Level-5-MasterBranch
Bev-low Sep 10, 2024
0e6bae6
Merge branch 'master' into branch-level-5
Bev-low Sep 10, 2024
56d0e22
Add A-Packages
Bev-low Sep 12, 2024
3b75765
Add Level-5-bug fixes
Bev-low Sep 18, 2024
b63bd20
Add Level-6+A-Collections
Bev-low Sep 20, 2024
79a8871
Add Level-6+A-Collections
Bev-low Sep 20, 2024
3d1361d
Add Level-7
Bev-low Sep 22, 2024
1527ab8
Merge branch 'branch-level-6'
Bev-low Sep 22, 2024
d8923aa
Add Level-7-conflicts
Bev-low Sep 22, 2024
91f00e2
Add Level-7-bug-fixes
Bev-low Sep 22, 2024
e7f6588
Add A-collections
Bev-low Sep 22, 2024
2a63fdc
Add A-Exceptions
Bev-low Sep 22, 2024
6c8dfc5
Add A-Exceptions
Bev-low Sep 22, 2024
3be8c65
Add A-MoreOOP
Bev-low Sep 26, 2024
adabff1
Add Level-8
Bev-low Oct 1, 2024
7ce6169
Add Level-9
Bev-low Oct 1, 2024
562d87d
Add A-JavaDoc
Bev-low Oct 1, 2024
1289341
Merge pull request #1 from Bev-low/branch-level-8
Bev-low Oct 1, 2024
cdf3bfb
Merge branch 'master' into branch-level-9
Bev-low Oct 1, 2024
3a40699
Merge pull request #2 from Bev-low/branch-level-9
Bev-low Oct 1, 2024
74dd30e
Merge branch 'master' into A-JavaDoc
Bev-low Oct 1, 2024
5de4602
Merge pull request #3 from Bev-low/A-JavaDoc
Bev-low Oct 1, 2024
9d6381c
Add A-JavaDoc-fixes
Bev-low Oct 2, 2024
769a80b
Add A-UserGuide
Bev-low Oct 4, 2024
86639ed
Resolved outstanding merge conflicts, keeping master version
Bev-low Oct 5, 2024
95f37b6
Add A-UserGuide-fixes
Bev-low Oct 5, 2024
c383183
Merge branch-level-6 into master, keeping master version
Bev-low Oct 5, 2024
e2cc91e
Add A-Jar2.0
Bev-low Oct 9, 2024
8dc1a20
Add A-Formatting-Fixes
Bev-low Oct 9, 2024
2fa2497
Add A-added Gradle Checks
Bev-low Oct 9, 2024
b32e1fe
Add Bug-Fixes
Bev-low Oct 9, 2024
4b1bc2e
Add Bug-Fixes
Bev-low Oct 9, 2024
c9478f8
Add Fix User-Guide
Bev-low Oct 9, 2024
0f6e5f1
Add Fix user-guide
Bev-low Oct 9, 2024
56dd508
Add Fix user-guide
Bev-low Oct 9, 2024
2b98a0b
Add Updating ReadMe.md
Bev-low Oct 9, 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ src/main/resources/docs/
*.iml
bin/

# Ignore compiled .class files
*.class

/text-ui-test/ACTUAL.TXT
text-ui-test/EXPECTED-UNIX.TXT
20 changes: 20 additions & 0 deletions src/main/java/ChattyCharlie/CharlieExceptions.java
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!");
}
}
156 changes: 156 additions & 0 deletions src/main/java/ChattyCharlie/ChattyCharlie.java
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

Copy link
Copy Markdown

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

public static void ScheduleMaker() throws CharlieExceptions { //Echo as a function

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 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));
//print
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));
//print
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);
//print
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);
//print
System.out.println(StringDesign.LINE);
break;
case BYE:
return; //just exit
case LIST:
list.printList();
//print
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);

}
}
11 changes: 11 additions & 0 deletions src/main/java/ChattyCharlie/CommandType.java
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
}
102 changes: 102 additions & 0 deletions src/main/java/ChattyCharlie/List.java
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;
}
}
25 changes: 25 additions & 0 deletions src/main/java/ChattyCharlie/StringDesign.java
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: ";
}
23 changes: 23 additions & 0 deletions src/main/java/ChattyCharlie/Task/Deadline.java
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 + ")";
}
}
37 changes: 37 additions & 0 deletions src/main/java/ChattyCharlie/Task/Event.java
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 + ")";
}
}
Loading