Skip to content
Open
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
85 changes: 85 additions & 0 deletions src/main/java/com/booleanuk/core/TodoList.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,90 @@
package com.booleanuk.core;

import java.util.List;

import com.booleanuk.core.pojo.Task;

import java.util.ArrayList;
import java.util.Comparator;

public class TodoList {

private List<Task> tdList;

public TodoList(){
this.tdList = new ArrayList<Task>();
}

public void add(Task task){
this.tdList.add(task);
}

public List<Task> retList(){
return this.tdList;
}

public void changeStatus(String task, boolean status){
for(Task t : this.tdList){
if(task == t.getTask())
t.setComplet(status);
}
Comment on lines +26 to +30
}

public List<Task> getComp(){
List<Task> tmp = new ArrayList<Task>();
for(Task t: this.tdList){
if(t.getComplet() == true)
tmp.add(t);
}
return tmp;
}

public List<Task> getInComp(){
List<Task> tmp = new ArrayList<Task>();
for(Task t: this.tdList){
if(t.getComplet() == false)
tmp.add(t);
}
return tmp;
}

public String search(String task){
for(Task t: this.tdList){
if(t.getTask().contains(task))
return "Found/Exists!";
}
return "Does not exist!";
}

public void delete(String task){
int i = 0;
for(Task t: this.tdList){
if(t.getTask() == task){
this.tdList.remove(i);
break;
}
i++;
}
}

public String orderAscend(){
String tmpStr = "";
List<Task> tmpList = this.tdList;
tmpList.sort(Comparator.comparing(Task::getTask, String.CASE_INSENSITIVE_ORDER));
for (Task t : tmpList){
tmpStr += t.getTask() + "\n";
}
return tmpStr.trim();
}
Comment on lines +70 to +78

public String orderDescend(){
String tmpStr = "";
List<Task> tmpList = this.tdList;
tmpList.sort(Comparator.comparing(Task::getTask, String.CASE_INSENSITIVE_ORDER).reversed());
for (Task t : tmpList){
tmpStr += t.getTask() + "\n";
}
return tmpStr.trim();
}

}
30 changes: 30 additions & 0 deletions src/main/java/com/booleanuk/core/pojo/Task.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.booleanuk.core.pojo;

public class Task {
private String task;
private boolean complet;

Comment on lines +4 to +6
public Task(String task){
this.task = task;
this.complet = false;

}

public Task(String task, boolean complet){
this.task = task;
this.complet = complet;

}

public void setComplet(boolean complet){
this.complet = complet;
}

public boolean getComplet(){
return this.complet;
}

public String getTask(){
return this.task;
}
}
48 changes: 48 additions & 0 deletions src/main/java/com/booleanuk/extension/ExTask.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package com.booleanuk.extension;

import java.time.LocalDateTime;

public class ExTask {
private String task;
private boolean complet;
protected int id;
Comment on lines +6 to +8
private LocalDateTime date;

public ExTask(String task){
this.task = task;
this.complet = false;
this.date = LocalDateTime.now();

}

public ExTask(String task, boolean complet){
this.task = task;
this.complet = complet;
this.date = LocalDateTime.now();

}

public void setComplet(boolean complet){
this.complet = complet;
}

public void setTask(String task){
this.task = task;
}

public boolean getComplet(){
return this.complet;
}

public String getTask(){
return this.task;
}

public int getID(){
return this.id;
}

public LocalDateTime getDate(){
return this.date;
}
}
125 changes: 125 additions & 0 deletions src/main/java/com/booleanuk/extension/ExTodoList.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
package com.booleanuk.extension;

import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;

import java.time.format.DateTimeFormatter;

public class ExTodoList {

private List<ExTask> tdList;
private int incrementID;

public ExTodoList(){
this.tdList = new ArrayList<ExTask>();
this.incrementID = 1;
}

public void add(ExTask task){
task.id = incrementID;
this.tdList.add(task);
}
Comment on lines +19 to +22

public List<ExTask> retList(){
return this.tdList;
}

public void changeStatus(String task, boolean status){
for(ExTask t : this.tdList){
if(task == t.getTask())
t.setComplet(status);
}
}

public List<ExTask> getComp(){
List<ExTask> tmp = new ArrayList<ExTask>();
for(ExTask t: this.tdList){
if(t.getComplet() == true)
tmp.add(t);
}
return tmp;
}

public List<ExTask> getInComp(){
List<ExTask> tmp = new ArrayList<ExTask>();
for(ExTask t: this.tdList){
if(t.getComplet() == false)
tmp.add(t);
}
return tmp;
}

public String search(String task){
for(ExTask t: this.tdList){
if(t.getTask().contains(task))
return "Found/Exists!";
}
return "Does not exist!";
}

public void delete(String task){
int i = 0;
for(ExTask t: this.tdList){
if(t.getTask() == task){
this.tdList.remove(i);
break;
}
i++;
}
}

public String orderAscend(){
String tmpStr = "";
List<ExTask> tmpList = this.tdList;
tmpList.sort(Comparator.comparing(ExTask::getTask, String.CASE_INSENSITIVE_ORDER));
for (ExTask t : tmpList){
tmpStr += t.getTask() + "\n";
}
return tmpStr.trim();
}

public String orderDescend(){
String tmpStr = "";
List<ExTask> tmpList = this.tdList;
tmpList.sort(Comparator.comparing(ExTask::getTask, String.CASE_INSENSITIVE_ORDER).reversed());
for (ExTask t : tmpList){
tmpStr += t.getTask() + "\n";
}
return tmpStr.trim();

}

public String getExTaskByID(int id){
for (ExTask t : tdList){
if(t.id == id)
return t.getTask();
}
return "";
}

public void updateNameExTask(int id, String newTask){
for (ExTask t : tdList){
if(t.id == id)
t.setTask(newTask);
}
}

public void changeStatus(int id, boolean status){
for (ExTask t : tdList){
if(t.id == id)
t.setComplet(status);
}
}

public String dateTime(){
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
String tmp = "";
for(ExTask t : tdList){
String tmpStr = t.getDate().format(formatter);
tmp += t.getTask() + " " + tmpStr + "\n";
}
return tmp.trim();
}
Comment on lines +115 to +123

}
Loading
Loading