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