added class ToDo
added menu in Main class
This commit is contained in:
6
plan.txt
Normal file
6
plan.txt
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
Funktionen:
|
||||||
|
-ToDo hinzufügen#
|
||||||
|
-ToDo abhaken
|
||||||
|
-ToDo löschen
|
||||||
|
-ToDo auflisten#
|
||||||
|
-ToDo-Liste abspeichern
|
||||||
@@ -1,28 +1,58 @@
|
|||||||
package de.dejan.todolist;
|
package de.dejan.todolist;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public class Main{
|
public class Main{
|
||||||
|
|
||||||
|
static int taskID=0;
|
||||||
|
static ArrayList<ToDo> tasks=new ArrayList<ToDo>();
|
||||||
|
|
||||||
public static void main( String[] args ){
|
public static void main( String[] args ){
|
||||||
String[] tasks=new String[10];
|
|
||||||
|
while (true) {
|
||||||
System.out.println("ToDo-Liste:");
|
menu();
|
||||||
|
|
||||||
System.out.println("\n10 Aufgaben hinzufügen:");
|
|
||||||
|
|
||||||
for(int i=0; i<10; i++){
|
|
||||||
|
|
||||||
tasks[i]=System.console().readLine();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("\nListe:");
|
|
||||||
|
|
||||||
for(int i=0; i<10; i++){
|
|
||||||
|
|
||||||
System.out.println(tasks[i]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void menu(){
|
||||||
|
|
||||||
|
System.out.println("\n[1]Neues ToDo hinzufügen");
|
||||||
|
System.out.println("[2]ToDos auflisten");
|
||||||
|
System.out.println("[3]Beenden");
|
||||||
|
|
||||||
|
int in=Integer.parseInt(System.console().readLine());
|
||||||
|
|
||||||
|
switch (in) {
|
||||||
|
case 1: newTask(); break;
|
||||||
|
case 2: listToDo(); break;
|
||||||
|
case 3: System.exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void newTask(){
|
||||||
|
|
||||||
|
System.out.println("\nAufgabe hinzufügen:");
|
||||||
|
|
||||||
|
String in=System.console().readLine();
|
||||||
|
|
||||||
|
ToDo task=new ToDo(taskID, in);
|
||||||
|
tasks.add(task);
|
||||||
|
taskID++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void listToDo(){
|
||||||
|
System.out.println("\n\nToDo:");
|
||||||
|
System.out.println("=====");
|
||||||
|
for (int i = 0; i < tasks.size(); i++) {
|
||||||
|
System.out.println("["+tasks.get(i).theId+"] "+tasks.get(i).theContent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
15
todolist_editor/src/main/java/de/dejan/todolist/ToDo.java
Normal file
15
todolist_editor/src/main/java/de/dejan/todolist/ToDo.java
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
package de.dejan.todolist;
|
||||||
|
|
||||||
|
public class ToDo {
|
||||||
|
|
||||||
|
int theId;
|
||||||
|
String theContent;
|
||||||
|
|
||||||
|
public ToDo(int id, String content){
|
||||||
|
theId=id;
|
||||||
|
theContent=content;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user