Task
parent
81d4e75abd
commit
b48452801b
|
@ -0,0 +1,29 @@
|
|||
package TodoListApp.Domain;
|
||||
|
||||
public class AddTask {
|
||||
|
||||
public static Task addTaskZuList(String title, String beschreibung, String eingabeTaskprioritaet) {
|
||||
Task t;
|
||||
Prioritaet taskPrioritaet = null;
|
||||
switch (eingabeTaskprioritaet) {
|
||||
case "niedrig":
|
||||
taskPrioritaet = taskPrioritaet.Niedrig;
|
||||
break;
|
||||
|
||||
case "mittel":
|
||||
taskPrioritaet = taskPrioritaet.Mittel;
|
||||
break;
|
||||
|
||||
case "hoch":
|
||||
taskPrioritaet = taskPrioritaet.Hoch;
|
||||
break;
|
||||
default:
|
||||
taskPrioritaet = taskPrioritaet.Niedrig;
|
||||
}
|
||||
|
||||
return t = new Task(title,beschreibung,taskPrioritaet);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
package TodoListApp.Domain.KlassenException;
|
||||
|
||||
public class FalscheEinagebException extends Exception {
|
||||
|
||||
public FalscheEinagebException(String error){
|
||||
super(error);
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
package TodoListApp.Domain.KlassenException;
|
||||
|
||||
public class TaskNichtGefundenException extends Exception {
|
||||
|
||||
public TaskNichtGefundenException(String error){
|
||||
super(error);
|
||||
}
|
||||
}
|
|
@ -2,7 +2,6 @@ package TodoListApp.Domain;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import TodoListApp.Domain.*;
|
||||
import TodoListApp.Domain.KlassenException.*;
|
||||
|
||||
public class TaskList {
|
||||
|
||||
|
@ -14,46 +13,32 @@ public class TaskList {
|
|||
}
|
||||
|
||||
public boolean addTaskZuList(String title, String beschreibung, String eingabeTaskprioritaet) {
|
||||
Prioritaet taskPrioritaet = null;
|
||||
switch (eingabeTaskprioritaet) {
|
||||
case "niedrig":
|
||||
taskPrioritaet = taskPrioritaet.Niedrig;
|
||||
break;
|
||||
|
||||
case "mittel":
|
||||
taskPrioritaet = taskPrioritaet.Mittel;
|
||||
break;
|
||||
|
||||
case "hoch":
|
||||
taskPrioritaet = taskPrioritaet.Hoch;
|
||||
break;
|
||||
default:
|
||||
taskPrioritaet = taskPrioritaet.Niedrig;
|
||||
}
|
||||
|
||||
alleTasks.add(new Task(title, beschreibung, taskPrioritaet));
|
||||
Task t = AddTask.addTaskZuList(title, beschreibung, eingabeTaskprioritaet);
|
||||
if (t == null)
|
||||
return false;
|
||||
|
||||
alleTasks.add(t);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean removeTask(String title) {
|
||||
|
||||
for (Task t : alleTasks) {
|
||||
if (t.getTitle().equalsIgnoreCase(title)) {
|
||||
alleTasks.remove(t);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
Task t = findTask(title);
|
||||
if (t == null)
|
||||
return false;
|
||||
|
||||
alleTasks.remove(t);
|
||||
return true;
|
||||
}
|
||||
|
||||
public String findeTaskByTitle(String title) throws TaskNichtGefundenException {
|
||||
|
||||
for (Task t : alleTasks) {
|
||||
if (t.getTitle() == title)
|
||||
return t.toString();
|
||||
}
|
||||
throw new TaskNichtGefundenException("Task wurde nicht gefunden");
|
||||
public boolean markTaskAsDone(String title) {
|
||||
Task t = findTask(title);
|
||||
if (t == null)
|
||||
return false;
|
||||
t.setIstGemacht(true);
|
||||
return t.isIstGemacht();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ArrayList<String> printAlleGemachteTasks() {
|
||||
ArrayList<String> alleGemachteTasks = new ArrayList<>();
|
||||
|
@ -73,13 +58,11 @@ public class TaskList {
|
|||
return printallTasks;
|
||||
}
|
||||
|
||||
public boolean markTaskAsDone(String title) {
|
||||
for (Task t : alleTasks)
|
||||
if (t.getTitle().equalsIgnoreCase(title)) {
|
||||
t.setIstGemacht(true);
|
||||
return t.isIstGemacht();
|
||||
}
|
||||
return false;
|
||||
private Task findTask(String title) {
|
||||
for (Task t : alleTasks)
|
||||
if (t.getTitle().equalsIgnoreCase(title))
|
||||
return t;
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package TodoListApp.GUI_UserInterface;
|
||||
|
||||
import TodoListApp.Domain.ProgrammSystem;
|
||||
import TodoListApp.Domain.KlassenException.FalscheEinagebException;
|
||||
|
||||
public class Userverwalter {
|
||||
|
||||
|
@ -20,24 +19,9 @@ public class Userverwalter {
|
|||
this.markTaskFenster = new MarkTask();
|
||||
|
||||
// Buttons User:
|
||||
user.getAddTask().addActionListener(e -> {
|
||||
try {
|
||||
taskAddFenster();
|
||||
} catch (FalscheEinagebException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
taskHinziFuegenFenster.getSubmitTask().addActionListener(e -> {
|
||||
try {
|
||||
addTask();
|
||||
} catch (FalscheEinagebException e1) {
|
||||
// TODO Auto-generated catch block
|
||||
e1.printStackTrace();
|
||||
}
|
||||
});
|
||||
user.getAddTask().addActionListener(e -> taskAddFenster());
|
||||
|
||||
taskHinziFuegenFenster.getSubmitTask().addActionListener(e ->addTask());
|
||||
|
||||
markTaskFenster.getMarkTaskButton().addActionListener(e -> markTaskAsDone());
|
||||
taskLöschenFenster.getRemoveTaskButton().addActionListener(e-> removeTask());
|
||||
|
@ -49,12 +33,12 @@ public class Userverwalter {
|
|||
|
||||
}
|
||||
|
||||
public void taskAddFenster() throws FalscheEinagebException {
|
||||
public void taskAddFenster() {
|
||||
taskHinziFuegenFenster.zeigeFensterAddTask();
|
||||
|
||||
}
|
||||
|
||||
public void addTask() throws FalscheEinagebException {
|
||||
public void addTask(){
|
||||
|
||||
String title = taskHinziFuegenFenster.getTasktitle().getText();
|
||||
String beschreibung = taskHinziFuegenFenster.getTaskBeschreibung().getText();
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package TodoListApp;
|
||||
|
||||
import TodoListApp.Domain.KlassenException.FalscheEinagebException;
|
||||
import TodoListApp.GUI_UserInterface.GUI_UserInterface;
|
||||
import TodoListApp.GUI_UserInterface.Userverwalter;
|
||||
|
||||
public class Main {
|
||||
|
||||
public static void main(String[] args) throws FalscheEinagebException {
|
||||
public static void main(String[] args) {
|
||||
new Userverwalter();
|
||||
}
|
||||
|
||||
|
|
|
@ -3,16 +3,15 @@ package TodoListApp;
|
|||
import java.util.Scanner;
|
||||
|
||||
import TodoListApp.Domain.*;
|
||||
import TodoListApp.Domain.KlassenException.*;
|
||||
|
||||
public class UserInterface {
|
||||
private TaskList tasks;
|
||||
|
||||
UserInterface() throws FalscheEinagebException{
|
||||
UserInterface() {
|
||||
tasks = new TaskList();
|
||||
startProgramm();
|
||||
|
||||
}
|
||||
public void startProgramm() throws FalscheEinagebException {
|
||||
public void startProgramm(){
|
||||
Scanner eingabe = new Scanner(System.in);
|
||||
String optionAuswahl;
|
||||
String title;
|
||||
|
|
Loading…
Reference in New Issue