Implement an application (a system) of any abstract data type (stack, queue,
tree, graph, hashing) using Java as programming
language. Some of the examples are the following:
• Dictionary implementation using AVL Tree
• Log-book for Task Monitoring
• Queuing System for Clinics
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Queue<String> queue = new LinkedList<>();
Scanner in = new Scanner(System.in);
while (true) {
System.out.println("1. Add a patient to the queue.");
System.out.println("2. Remove a patient from the queue.");
System.out.println("0. Exit.");
switch (in.nextLine()) {
case "1":
System.out.println("Enter the patient's name: ");
queue.offer(in.nextLine());
break;
case "2":
if (queue.isEmpty()) {
System.out.println("The queue is empty.");
} else {
System.out.println("Patient: " + queue.poll());
}
break;
case "0":
System.exit(0);
}
}
}
}
Comments
Leave a comment