case 2 almost done

This commit is contained in:
2022-10-23 16:02:52 +03:30
parent 0e90a4b4d6
commit 3a9b48a6f1
7 changed files with 64 additions and 41 deletions

View File

@@ -1,44 +1,23 @@
package com.tabrizu.ds;
import java.util.Scanner;
public class App {
ISingleLinkedList<Task> m_unfinished;
ISingleLinkedList<Task> m_finished;
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(){
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"
"\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();
@@ -47,37 +26,72 @@ public class App {
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() {
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){
public void addTask(Task task, boolean isNormalTask) {
if (isNormalTask) {
m_unfinished.addLast(task);
}
else{
} else {
m_unfinished.addFirst(task);
}
}
public Task getCurrentTasks(){
public Task getCurrentTasks() {
return m_unfinished.getFirst();
}
public void taskDone(){
public void taskDone() {
m_finished.addFirst(m_unfinished.removeFirst());
}
public String showFinishedTasks(){
public String showFinishedTasks() {
return m_finished.toString();
}
public String showUnFinishedTasks(){
public String showUnFinishedTasks() {
return m_unfinished.toString();
}
}

View File

@@ -45,7 +45,9 @@ public class SingleLinkedList<T> implements ISingleLinkedList<T> {
m_tail = m_head;
}
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 = newNode;
m_size++;
System.out.println("Last Node added with value: " + value);
System.out.println(
"Last Node added with value: " + value
);
}

View File

@@ -10,4 +10,9 @@ public class Task {
public String getTitle(){
return m_title;
}
@Override
public String toString() {
return "[Task] " + m_title;
}
}

Binary file not shown.