Skip to content
Open
Show file tree
Hide file tree
Changes from 14 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
189 changes: 189 additions & 0 deletions src/main/java/ChattyCharlie.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
import java.util.Scanner;

public class ChattyCharlie {

//TASK CLASS
public static class Task{
protected String description;
protected boolean isDone;

//constructor
public Task(String description) {
this.description = description;
this.isDone = false;
}

//check if its marked as done
public String getMarkedStatus() {
return (isDone ? "X" : " ");
}

//to toggle the task
public void markTask() {
this.isDone = true; //change the variable
}

public void unmarkTask() {
this.isDone = false; //change the variable
}
}


//LIST CLASS
public static class List {
//make a list of task
private Task[] list;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Could name the array something in plural, like tasks

private int size;

//constructor
public List() {
list = new Task[100];
size = 0;
}

//Method to add an item to the list
public void addTask(String text) {
//create an instance for Task
Task newTask = new Task(text);
//add the text into the list
list[size] = newTask;
//account for the item
size++;
}

//To mark
public void mark(int index) {
if (index >= 0 && index < size) {
list[index].markTask();
int remainingTask = countUnmarkedTasks();
System.out.println(" Well Done! 1 task down, " + remainingTask + " to go.");

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Perhaps the space identation could be made into a constant variable given its usage throughout the code.

System.out.println(" [" + list[index].getMarkedStatus() + "] " + list[index].description);
} else {
System.out.println(" Invalid task number.");
}
}

//To unmark
public void unmark(int index) {
if (index >= 0 && index < size) {
list[index].unmarkTask();
int remainingTask = countUnmarkedTasks();
System.out.println(" Hmmm, not quite done yet, " + remainingTask + " to go.");
System.out.println(" [" + list[index].getMarkedStatus() + "] " + list[index].description);
} else {
System.out.println(" Invalid task number.");
}
}

//To print list
public void toPrintList() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe the function name could be clearer without using "to"?

//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;
System.out.println(" " + number + ".[" +list[i].getMarkedStatus() + "] " + list[i].description);
}
}

// Method to count how many tasks are unmarked
public int countUnmarkedTasks() {
int count = 0;
for (int i = 0; i < size; i++) {
if (!list[i].isDone) {
count++;
}
}
return count;
}
}

//MAIN ALGO
public static void toDoMaker() { //Echo as a function
String line;
String you = "User: ";

//make the scanner
Scanner in = new Scanner(System.in);

//create an instance of list class
List toDo = new List();

//accept an insert
while (true) {
System.out.print(you);
line = in.nextLine();

//if the line contains bye, it signals the end
if (line.contains("Bye") || line.contains("bye")) {
break;
}
//add or print
if (line.equals("list")) {
toDo.toPrintList();
} else if (line.startsWith("mark ")) {
//trim to get the task name
String taskDescription = line.substring(5).trim();
boolean found = 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.

Perhaps the boolean variable could be named "isFound" for greater clarity?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Boolean is not in form of a question


//loop to find
for(int index = 0; index < toDo.size; index++)
{

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Not following loop layout coding standard

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Sorry I dont understand what you mean, is this not the standard?

There are curly brackets, can I clarfiy what fo you mean

if(toDo.list[index].description.equals(taskDescription)) {
toDo.mark(index);
found = true;
break;
}
}
if(!found) {
System.out.println(" Invalid task description");
}
} else if (line.startsWith("unmark ")) {
String taskDescription = line.substring(7).trim();
boolean found = false;

//loop to find
for(int index = 0; index < toDo.size; index++)
{

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Again, not following the loop layout coding standard

if(toDo.list[index].description.equals(taskDescription)) {
toDo.unmark(index);
found = true;
break;
}
}
if(!found) {
System.out.println(" Invalid task description.");
}
} else {
//add the item
toDo.addTask(line);
System.out.println(" Added: " + line);
}
}
}

public static void main(String[] args) {
String logo = " _____ \n"
+ " / \\ \n"
+ " | O O | \n"
+ " | \\___/ | \n"
+ " \\_____/ \n"
+ " /\\_____/\\ \n"
+ " | | \n"
+ " | | \n"
+ " |_______| \n"
+ " \n";
String charlie = "Charlie: ";

String greeting = "Hello! I'm ChattyCharlie, your consistent buddy.\n"
+ " What shall we do today?\n" ;

String farewell = "All the best in clearing your list!";

System.out.println(logo + charlie+ greeting);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Shouldn't the spacing be consistent?

toDoMaker();
System.out.println(charlie + farewell);

}
}
10 changes: 0 additions & 10 deletions src/main/java/Duke.java

This file was deleted.