add set & get methods

This commit is contained in:
Dejan
2021-08-22 18:57:47 +02:00
parent 2124333d6f
commit 2695c15dc6
2 changed files with 31 additions and 6 deletions

View File

@@ -20,7 +20,7 @@ public class Main{
System.out.println("\n[1]Neues ToDo hinzufügen"); System.out.println("\n[1]Neues ToDo hinzufügen");
System.out.println("[2]ToDos auflisten"); System.out.println("[2]ToDos auflisten");
System.out.println("[3]ToDo abhaken"); System.out.println("[3]ToDo abhaken/als nicht erledigt markieren");
System.out.println("[4]ToDo löschen"); System.out.println("[4]ToDo löschen");
System.out.println("[5]Beenden"); System.out.println("[5]Beenden");
System.out.print(">>>"); System.out.print(">>>");
@@ -58,14 +58,21 @@ public class Main{
}else{ }else{
done_='N'; done_='N';
} }
System.out.println("["+tasks.get(i).theId+"] "+tasks.get(i).theContent+" ["+done_+"]"); System.out.println("["+tasks.get(i).getID()+"] "+tasks.get(i).getContent()+" ["+done_+"]");
} }
} }
public static void done(){ public static void done(){
listToDo(); listToDo();
System.out.print("ToDo-Nr. eingeben zum Abhaken:"); System.out.print("ToDo-Nr. eingeben zum Abhaken:");
tasks.get(Integer.parseInt(System.console().readLine())).setDone(true);; int d=Integer.parseInt(System.console().readLine());
if (tasks.get(d).getDone()) {
tasks.get(d).setDone(false);
} else {
tasks.get(d).setDone(true);
}
} }
public static void delTask(){ public static void delTask(){

View File

@@ -2,17 +2,35 @@ package de.dejan.todolist;
public class ToDo { public class ToDo {
int theId; private int theID;
String theContent; private String theContent;
private boolean theDone; private boolean theDone;
String theDeadline; String theDeadline;
public ToDo(int id, String content, boolean done){ public ToDo(int id, String content, boolean done){
theId=id; theID=id;
theContent=content; theContent=content;
theDone=done; theDone=done;
} }
//get-& set-methods
public void setID(int id){
theID=id;
}
public int getID(){
return theID;
}
public void setContent(String content){
theContent=content;
}
public String getContent(){
return theContent;
}
public void setDone(boolean done){ public void setDone(boolean done){
theDone=done; theDone=done;
} }