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,32 +1,11 @@
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() {
int command;
Scanner scanner = new Scanner(System.in);
@@ -47,10 +26,46 @@ 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();
@@ -59,8 +74,7 @@ public class App {
public void addTask(Task task, boolean isNormalTask) {
if (isNormalTask) {
m_unfinished.addLast(task);
}
else{
} else {
m_unfinished.addFirst(task);
}
}

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.