Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Trying to get code to work for a project. It for an ER Queue, but it gives me er

ID: 3832010 • Letter: T

Question

Trying to get code to work for a project.

It for an ER Queue, but it gives me errors in the Patient Queue. It supposes to take a text file and sort the people by is they are an employee at the hospital, have insurance, and the severity of their injuries. An example of this is Leonard Myers;true;true;0

PatientQueue JAVA

package ER;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.io.*;

public class PatientQueue
{
public static void main(String[] args) throws FileNotFoundException
{
   File Info = new File("Patient.txt");
   Scanner fileinfo = new Scanner(Info);
  
   Scanner scan;
  
   int n;
   }
  
   void insert() {
      
       Scanner scan = new Scanner(System.in);
       LList queue = new LList();
      
       System.out.println("Patient Name - Disease");
      
       System.out.println("isEmployee 'n' isInsured :");
       n = scan.nextInt();
      
       System.out.println("");
      
       for(int i=0; i<n; i++) {
          
           queue.add(scan.nextInt());
       }      
   }
  
   void delete() {
      
       System.out.println(" The Queue");
      
       while(!PatientQueue.isEmpty()) {
          
           System.out.println(PatientQueue.poll());
       }
   }
private static char[] poll() {
           // TODO Auto-generated method stub
           return null;
       }
  

  

   private static boolean isEmpty() {
           // TODO Auto-generated method stub
           return false;
       }
   public void readpatitentsandaddpatitents(){

       List<PatientQueue> list=new LList<>();

      
       try {
       System.out.print("Enter the file name with extension : ");

       Scanner input = new Scanner(System.in);

       File file = new File(input.nextLine());

       input = new Scanner(file);


       while (input.hasNextLine()) {
       String line = input.nextLine();
       //System.out.println(line);
       list.add(input);
       if(substring(0,(input).indexof(";"))){
       void passthevaluesintothequue(Queue<String> queue) {
           }

       }
      
       input.close();

}
catch (Exception ex) {
       ex.printStackTrace();
       }
      
       private static void passthevaluesintothequue() {
           }
       {
       list.add(input);
       Object queue;
           printQueue(queue);

       }
       private static void printQueue(Queue<String> queue) {
       for(String s: queue){
       System.out.print(s + " ");
       }
       System.out.println();
       }
  
  
private void printQueue(Object queue) {
               // TODO Auto-generated method stub
              
           }

   PriorityQueue<Patient> pq = new PriorityQueue<Patient>(){
   {
      
       Patient = new Patient("Patient.txt", 2);

       while (pq.size() != 0)
   {
   System.out.println(pq.remove());{
       }
  
   }
   }
}
   }

PatientComparator

package ER;
import java.util.Comparator;

public class PatientComparator implements Comparator<Patient>
{

   public int compare(Patient p1, Patient p2)
{
   if (p1.getCategory() < p2.getCategory())
       return Integer.compare(p1.getCategory(), p2.getCategory());;
  
       return -1;
}
}

Patient class

package ER;
public class Patient {
public Patient next;
  
   public Patient() {
   this.name = "Default Name";
   this.category = 5;
  

   }

   public Patient(String nameIn, int categoryIn) {
   this.name = nameIn;
   this.category = categoryIn;
  
  
   }
protected String name;
protected int category;

public String getName() {
return name;
}
public void setName(String nameIn) {
this.name = nameIn;
}
public int getCategory() {
return category;
}
public void setCategory(int categoryIn) {
this.category = categoryIn;
}
public String toString()
{
return name + category;
}

}

ER Queue

package ER;
import java.util.Random;

public class erqueue {
   boolean isEmployee;
   boolean isInsured;
   public Queue cat1, cat2, cat3, cat4;
  
   public erqueue(){
   /*
   * contains 4 basic queues
   */
   cat1 = new Queue();
   cat2 = new Queue();
   cat3 = new Queue();
   cat4 = new Queue();
   }
  
   public void addToQueue(Patient p, boolean patientEmployed, boolean patientInsured )
   {
       if (patientEmployed == true && patientInsured == true)
           cat1.enqueue(p);
       if (patientEmployed == true && patientInsured == false)
           cat2.enqueue(p);
       if (patientEmployed == false && patientInsured == true)
           cat3.enqueue(p);
       if (patientEmployed == false && patientInsured == false)
           cat4.enqueue(p);
      
   }
  
   public void dequeue()
   {
       if(cat1.isEmpty() == false)
           cat1.dequeue();
      
       else if(cat2.isEmpty() == false)
           cat2.dequeue();
      
       else if(cat3.isEmpty() == false)
           cat3.dequeue();
      
       else if(cat4.isEmpty() == false)
           cat4.dequeue();
   }
  
}

Explanation / Answer

import java.util.PriorityQueue;
import java.util.Scanner;
import java.io.*;

public class PatientQueue
{
public static void main(String[] args) throws FileNotFoundException
{
   File Info = new File("Patient.txt");
   Scanner fileinfo = new Scanner(Info);
  
   Scanner scan;
  
   int n;
   }
  
   void insert() {
      
       Scanner scan = new Scanner(System.in);
       LList queue = new LList();
      
       System.out.println("Patient Name - Disease");
      
       System.out.println("isEmployee 'n' isInsured :");
       n = scan.nextInt();
      
       System.out.println("");
      
       for(int i=0; i<n; i++) {
          
           queue.add(scan.nextInt());
       }      
   }
  
   void delete() {
      
       System.out.println(" The Queue");
      
       while(!PatientQueue.isEmpty()) {
          
           System.out.println(PatientQueue.poll());
       }
   }
private static char[] poll() {
           // TODO Auto-generated method stub
           return null;
       }
  

  

   private static boolean isEmpty() {
           // TODO Auto-generated method stub
           return false;
       }
   public void readpatitentsandaddpatitents(){

       List<PatientQueue> list=new LList<>();

      
       try {
       System.out.print("Enter the file name with extension : ");

       Scanner input = new Scanner(System.in);

       File file = new File(input.nextLine());

       input = new Scanner(file);


       while (input.hasNextLine()) {
       String line = input.nextLine();
       //System.out.println(line);
       list.add(input);
       if(substring(0,(input).indexof(";"))){
       void passthevaluesintothequue(Queue<String> queue) {
           }

       }
      
       input.close();

}
catch (Exception ex) {
       ex.printStackTrace();
       }
      
       private static void passthevaluesintothequue() {
           }
       {
       list.add(input);
       Object queue;
           printQueue(queue);

       }
       private static void printQueue(Queue<String> queue) {
       for(String s: queue){
       System.out.print(s + " ");
       }
       System.out.println();
       }
  
  
private void printQueue(Object queue) {
               // TODO Auto-generated method stub
              
           }

   PriorityQueue<Patient> pq = new PriorityQueue<Patient>(){
   {
      
       Patient = new Patient("Patient.txt", 2);

       while (pq.size() != 0)
   {
   System.out.println(pq.remove());{
       }
  
   }
   }
}
   }

PatientComparator

package ER;
import java.util.Comparator;

public class PatientComparator implements Comparator<Patient>
{

   public int compare(Patient p1, Patient p2)
{
   if (p1.getCategory() < p2.getCategory())
       return Integer.compare(p1.getCategory(), p2.getCategory());;
  
       return -1;
}
}

Patient class

package ER;
public class Patient {
public Patient next;
  
   public Patient() {
   this.name = "Default Name";
   this.category = 5;
  

   }

   public Patient(String nameIn, int categoryIn) {
   this.name = nameIn;
   this.category = categoryIn;
  
  
   }
protected String name;
protected int category;

public String getName() {
return name;
}
public void setName(String nameIn) {
this.name = nameIn;
}
public int getCategory() {
return category;
}
public void setCategory(int categoryIn) {
this.category = categoryIn;
}
public String toString()
{
return name + category;
}

}