case 2 almost done
This commit is contained in:
@@ -1,44 +1,23 @@
|
|||||||
package com.tabrizu.ds;
|
package com.tabrizu.ds;
|
||||||
|
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
public class App {
|
public class App {
|
||||||
ISingleLinkedList<Task> m_unfinished;
|
ISingleLinkedList<Task> m_unfinished;
|
||||||
ISingleLinkedList<Task> m_finished;
|
ISingleLinkedList<Task> m_finished;
|
||||||
|
|
||||||
public void userInterface(){
|
public int mainMenu() {
|
||||||
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;
|
int command;
|
||||||
Scanner scanner = new Scanner(System.in);
|
Scanner scanner = new Scanner(System.in);
|
||||||
System.out.println(
|
System.out.println(
|
||||||
"Task Manager App:\n" +
|
"Task Manager App:\n" +
|
||||||
"\t 1. Add new normal task.\n" +
|
"\t 1. Add new normal task.\n" +
|
||||||
"\t 2. Add new important task.\n" +
|
"\t 2. Add new important task.\n" +
|
||||||
"\t 3. Get the list of available tasks.\n" +
|
"\t 3. Get the list of available tasks.\n" +
|
||||||
"\t 4. Get current task.\n" +
|
"\t 4. Get current task.\n" +
|
||||||
"\t 5. Change current task's status to DONE.\n" +
|
"\t 5. Change current task's status to DONE.\n" +
|
||||||
"\t 6. Get the list of finished tasks.\n" +
|
"\t 6. Get the list of finished tasks.\n" +
|
||||||
"\t 7. Quit"
|
"\t 7. Quit"
|
||||||
);
|
);
|
||||||
System.out.print("What is your command? [1-7]: ");
|
System.out.print("What is your command? [1-7]: ");
|
||||||
command = scanner.nextInt();
|
command = scanner.nextInt();
|
||||||
@@ -47,37 +26,72 @@ public class App {
|
|||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 2: {
|
||||||
|
System.out.println("What is the title of the task? ");
|
||||||
|
String taskTitle = sc.next();
|
||||||
|
Task task = new Task(taskTitle);
|
||||||
|
addTask(task, false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
System.out.println("DEFAULT");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public App() {
|
public App() {
|
||||||
m_unfinished = ISingleLinkedList.create();
|
m_unfinished = ISingleLinkedList.create();
|
||||||
m_finished = ISingleLinkedList.create();
|
m_finished = ISingleLinkedList.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] Args) {
|
public static void main(String[] Args) {
|
||||||
App app = new App();
|
App app = new App();
|
||||||
app.userInterface();
|
app.userInterface();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTask(Task task, boolean isNormalTask){
|
public void addTask(Task task, boolean isNormalTask) {
|
||||||
if(isNormalTask){
|
if (isNormalTask) {
|
||||||
m_unfinished.addLast(task);
|
m_unfinished.addLast(task);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
m_unfinished.addFirst(task);
|
m_unfinished.addFirst(task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task getCurrentTasks(){
|
public Task getCurrentTasks() {
|
||||||
return m_unfinished.getFirst();
|
return m_unfinished.getFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void taskDone(){
|
public void taskDone() {
|
||||||
m_finished.addFirst(m_unfinished.removeFirst());
|
m_finished.addFirst(m_unfinished.removeFirst());
|
||||||
}
|
}
|
||||||
|
|
||||||
public String showFinishedTasks(){
|
public String showFinishedTasks() {
|
||||||
return m_finished.toString();
|
return m_finished.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String showUnFinishedTasks(){
|
public String showUnFinishedTasks() {
|
||||||
return m_unfinished.toString();
|
return m_unfinished.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,7 +45,9 @@ public class SingleLinkedList<T> implements ISingleLinkedList<T> {
|
|||||||
m_tail = m_head;
|
m_tail = m_head;
|
||||||
}
|
}
|
||||||
m_size += 1;
|
m_size += 1;
|
||||||
System.out.println("First Node added with value: " + value);
|
System.out.println(
|
||||||
|
"First Node added with value: " + value
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +61,9 @@ public class SingleLinkedList<T> implements ISingleLinkedList<T> {
|
|||||||
m_tail.setNext(newNode);
|
m_tail.setNext(newNode);
|
||||||
m_tail = newNode;
|
m_tail = newNode;
|
||||||
m_size++;
|
m_size++;
|
||||||
System.out.println("Last Node added with value: " + value);
|
System.out.println(
|
||||||
|
"Last Node added with value: " + value
|
||||||
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,4 +10,9 @@ public class Task {
|
|||||||
public String getTitle(){
|
public String getTitle(){
|
||||||
return m_title;
|
return m_title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "[Task] " + m_title;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
sll/target/classes/com/tabrizu/ds/Task.class
Normal file
BIN
sll/target/classes/com/tabrizu/ds/Task.class
Normal file
Binary file not shown.
Reference in New Issue
Block a user