Start writing UI
This commit is contained in:
@@ -1,27 +1,83 @@
|
||||
package com.tabrizu.ds;
|
||||
import java.util.Scanner;
|
||||
public class App {
|
||||
ISingleLinkedList<Task> m_unfinished;
|
||||
ISingleLinkedList<Task> m_finished;
|
||||
|
||||
/**
|
||||
* Hello world!
|
||||
*/
|
||||
public final class App {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello World!");
|
||||
SingleLinkedList<Integer> list = new SingleLinkedList<Integer>();
|
||||
System.out.println("Step 0: " + list);
|
||||
list.addLast(55);
|
||||
list.addLast(76);
|
||||
list.addLast(35);
|
||||
list.addFirst(22);
|
||||
System.out.println("Step 1: " + list);
|
||||
System.out.println("[Remove]: " + list.removeLast());
|
||||
System.out.println("Step 2: " + list);
|
||||
list.addFirst(78);
|
||||
list.addLast(88);
|
||||
System.out.println("Step 3: " + list);
|
||||
System.out.println("[Remove]: " + list.removeFirst());
|
||||
System.out.println("Step 4: " + list);
|
||||
System.out.println("First: " + list.getFirst());
|
||||
System.out.println("Last: " + list.getLast());
|
||||
public void userInterface(){
|
||||
Scanner sc = new Scanner(System.in);
|
||||
while (true){
|
||||
int menuOption;
|
||||
menuOption = mainMenu();
|
||||
if(menuOption == 7){
|
||||
break;
|
||||
}
|
||||
switch (menuOption) {
|
||||
case 1:
|
||||
System.out.println("What is the title of the task? ");
|
||||
String taskTitle = sc.next();
|
||||
Task task = new Task(taskTitle);
|
||||
addTask(task, true);
|
||||
break;
|
||||
default:
|
||||
System.out.println("DEFAULT");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public int mainMenu(){
|
||||
int command;
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
System.out.println(
|
||||
"Task Manager App:\n" +
|
||||
"\t 1. Add new normal task.\n" +
|
||||
"\t 2. Add new important task.\n" +
|
||||
"\t 3. Get the list of available tasks.\n" +
|
||||
"\t 4. Get current task.\n" +
|
||||
"\t 5. Change current task's status to DONE.\n" +
|
||||
"\t 6. Get the list of finished tasks.\n" +
|
||||
"\t 7. Quit"
|
||||
);
|
||||
System.out.print("What is your command? [1-7]: ");
|
||||
command = scanner.nextInt();
|
||||
// command++;
|
||||
System.out.println(command);
|
||||
return command;
|
||||
}
|
||||
|
||||
public App() {
|
||||
m_unfinished = ISingleLinkedList.create();
|
||||
m_finished = ISingleLinkedList.create();
|
||||
}
|
||||
public static void main(String[] Args) {
|
||||
App app = new App();
|
||||
app.userInterface();
|
||||
}
|
||||
|
||||
public void addTask(Task task, boolean isNormalTask){
|
||||
if(isNormalTask){
|
||||
m_unfinished.addLast(task);
|
||||
}
|
||||
else{
|
||||
m_unfinished.addFirst(task);
|
||||
}
|
||||
}
|
||||
|
||||
public Task getCurrentTasks(){
|
||||
return m_unfinished.getFirst();
|
||||
}
|
||||
|
||||
public void taskDone(){
|
||||
m_finished.addFirst(m_unfinished.removeFirst());
|
||||
}
|
||||
|
||||
public String showFinishedTasks(){
|
||||
return m_finished.toString();
|
||||
}
|
||||
|
||||
public String showUnFinishedTasks(){
|
||||
return m_unfinished.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,7 @@ public interface ISingleLinkedList<T> {
|
||||
public T removeLast();
|
||||
public T getFirst();
|
||||
public T getLast();
|
||||
public static <T> ISingleLinkedList<T> create(){
|
||||
return new SingleLinkedList<T>();
|
||||
}
|
||||
}
|
||||
|
||||
13
sll/src/main/java/com/tabrizu/ds/Task.java
Normal file
13
sll/src/main/java/com/tabrizu/ds/Task.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.tabrizu.ds;
|
||||
|
||||
public class Task {
|
||||
String m_title;
|
||||
|
||||
public Task(String title){
|
||||
m_title = title;
|
||||
}
|
||||
|
||||
public String getTitle(){
|
||||
return m_title;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user