Skip to content
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

Add A-Assertions #2

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/main/java/awex/Storage.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public File load() throws IOException {
public void store(TaskList t) throws IOException {
FileWriter fw = new FileWriter(this.filepath);
int len = t.size();
assert len >= 0;
String str = "";
for (int i = 0; i < len; i++) {
str += t.get(i).toString() + "\n";
Expand Down
1 change: 1 addition & 0 deletions src/main/java/awex/TaskList.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public void add(Task t) {
public LinkedList<Task> find(String str) {
LinkedList<Task> list = new LinkedList<>();
int len = this.tasks.size();
assert len >= 0;
for (int i = 0; i < len; i++) {
Task t = this.tasks.get(i);
if (t.isPartOfDesc(str)) {
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/awex/Ui.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public String emptyListMessage() {
public String showListMessage(TaskList list) {
String str = "Here are the tasks in your list:\n";
int len = list.size();
assert len >= 0;
for (int i = 1; i <= len; i++) {
str += i + "." + list.get(i - 1).showAll() + "\n";
}
Expand All @@ -70,6 +71,7 @@ public String showFindMessage(TaskList tasks, String str) {
String stri = "Here are the matching tasks in your list:\n";
LinkedList<Task> list = tasks.find(str);
int len = list.size();
assert len >= 0;
for (int i = 1; i <= len; i++) {
stri += i + "." + list.get(i - 1).showAll() + "\n";
}
Expand All @@ -87,6 +89,7 @@ public String wrongMarkDeleteFormatMessage(String str) {
* Prints explainer message when user provides inaccessible list index.
*/
public String wrongIndexMessage(int i, int len) {
assert len >= 0;
if (i == 0) {
return "Pick a value between 1 and " + len + ".";
} else {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/tasks/Task.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public class Task {
public Task(String what, String status, String type) {
this.what = what;
this.type = type;
assert status.equals("t") || status.equals("f");
if (status.equals("t")) {
this.status = "[X]";
} else {
Expand All @@ -38,9 +39,10 @@ public String showAll() {
* @param status completion status of task
*/
public void changeStatus(String status) {
assert status.equals("mark") || status.equals("unmark");
if (status.equals("mark")) {
this.status = "[X]";
} else if (status.equals("unmark")) {
} else {
this.status = "[ ]";
}
}
Expand Down