You can not use the < or > operators to compare boolean expressions. the equals() method returns a boolean value.
true < false or true > false does not make sense. You can test for equality: == or !=

Where is the definition of the Orders1 class? Does it correctly define the method used in the Comparator interface?

import java.io.*;
import java.util.PriorityQueue;
//import java.lang.Comparable;
import java.util.Comparator;
import java.util.*;

public class Orders1 implements Comparator {


    private String Name;
    private String Kind;
    private String PickUp;
    private String DropOff;
    private String TypeOfService;
    private String Requirements;



    public Orders1(String Name, String Kind, String PickUp, String DropOff, String TypeOfService, String Requirements) {
        this.Name = Name;
        this.Kind = Kind;
        this.PickUp = PickUp;
        this.DropOff = DropOff;
        this.TypeOfService = TypeOfService;
        this.Requirements = Requirements;
    }

the error is now != being an illegal start

public int compare(Orders1 orderA, Orders1 orderB){

                if(orderA.getKind() == ("urgent") && != orderB.getKind() == ("urgent")){
                    return 1;

                  if(orderA.getKind() == ("urgent") < orderB.getKind() == ("booked_in_advance")){
                    return 1;

                 if(orderB.getKind() == ("booked in advance") > orderA.getKind() == ("urgent")){

                return 1;

            }
        }
    }


            }

You should use the equals() method to compare Strings.

What is the logic for your use of the < and > operators? Why are you using them?

In the Orders1 class definition, where is the method required by this:

implements Comparator

my logic comes from all the e.g i have seen where urgent is less than booked in advance, urgent is the higher priority
and where booked in advance is greater than urgent so urgent is the higher priority.

 public String getName() {
        return Name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String Name) {
        this.Name = Name;
    }

    /**
     * @return the kind
     */
    public String getKind() {
        return Kind;
    }

    /**
     * @param kind the kind to set
     */
    public void setKind(String Kind) {
        this.Kind = Kind;
    }

    /**
     * @return the pick up
     */
    public String getPickUp() {
        return PickUp;
    }

    /**
     * @param pick up the pick up to set
     */
    public void setPickUp(String PickUp) {
        this.PickUp = PickUp;
    }

    /**
         * @return the drop off
         */
        public String getDropOff() {
            return DropOff;
        }

        /**
         * @param drop off the drop off to set
         */
        public void setDropOff(String DropOff) {
            this.DropOff = DropOff;
    }

    /**
         * @return the type of service
         */
        public String getTypeOfService() {
            return TypeOfService;
        }

        /**
         * @param type of service the type of service to set
         */
        public void setTypeOfService(String TypeOfService) {
            this.TypeOfService = TypeOfService;
    }

    /**
         * @return the requirements
         */
        public String getRequirements() {
            return Requirements;
        }

        /**
         * @param requirements the requirements to set
         */
        public void setRequirements(String Requirements) {
            this.Requirements = Requirements;
    }

You should add an int field to the class with the priority that you can use with the > and < operators

i did this

 private int priority;






 this.priority = priority;



/**
             * @return the priority
             */
            public int getPriority() {
                return priority;
            }

            /**
             * @param requirements the priority to set
             */
            public void setPriority(int priority) {
                this.priority = priority;
    }



PriorityQueue<Orders1> queue = new PriorityQueue<Orders1>(179, new Comparator<Orders1>(){

                public int compare(Orders1 orderA, Orders1 orderB){

                if(orderA.getKind().equals("urgent") && ! orderB.getKind().equals("urgent")){
                    return 1;

                  if(orderA.getPriority().equals("urgent") < orderB.getPriority().equals("booked_in_advance")){
                    return 1;

                 if(orderB.getPriority().equals("booked in advance") > orderA.getPriority().equals("urgent")){

                return 1;

            }
        }
    }


            }

is what i added and changed
and beside the Comparator error the other errors are the .equals and its pointing to the . saying int cannot be dereferenced but when i change to == its saying incomaparable types : boolean and java.lang.String

The code still has the < and > between booleans.
You don't need to test the Strings with equals() if you have the priority from getPriority()

if(orderB.getPriority("booked_in_advance") > orderA.getPriority("urgent")){

is it like this
and what is the problem with the . between orderB.getPriority
it says getPriority in Orders1 cannot be applied to (java.lang.String)

Look at where the getPriority() method is defined. Does it take any arguments?

i changed it to this and this and now i am stuck with the comparator prblem i mentioned before

PriorityQueue<Orders1> queue = new PriorityQueue<Orders1>(179, new Comparator<Orders1>(){

                public int compare(Orders1 orderA, Orders1 orderB){

                if(orderA.getKind().equals("urgent") && ! orderB.getKind().equals("urgent")){
                    return 1;

                  if(orderA.getPriority() < orderB.getPriority()){
                    return 1;

                 if(orderB.getPriority() > orderA.getPriority()){

                return 1;

            }
        }
    }


            }


        });

Are there any errors? Please post the full text.

Why does the method always return a value of 1? It should return different values depending on A and B.

Orders1 is not an abstract and does not override abstract method compare(java.lang.Object, java.lang.Object) in java.util.Comparator




public class Orders1 implements Comparator{

it is pointing to the c in class
do you mean like this

PriorityQueue<Orders1> queue = new PriorityQueue<Orders1>(179, new Comparator<Orders1>(){

                public int compare(Orders1 orderA, Orders1 orderB){

                if(orderA.getKind().equals("urgent") && ! orderB.getKind().equals("urgent")){
                    return 1;

                  if(orderA.getPriority() < orderB.getPriority()){
                    return 1;

                 if(orderB.getPriority() > orderA.getPriority()){

                return -1;

            }
        }
    }


            }


        });

implements Comparator

Either remove the above or correctly code the class.

Read how to code here:
Click Here

i am still trying to be able to use the priority queue but all i am getting is the file being read it is not sorted at all.

import java.io.*;
import java.util.PriorityQueue;
//import java.lang.Comparable;
import java.util.Comparator;
import java.util.*;

public class Orders1 implements Comparator<Orders1>{


    private String Name;
    private String Kind;
    private String PickUp;
    private String DropOff;
    private String TypeOfService;
    private String Requirements;
    private int priority;



    public Orders1(String Name, String Kind, String PickUp, String DropOff, String TypeOfService, String Requirements, int priority) {
        this.Name = Name;
        this.Kind = Kind;
        this.PickUp = PickUp;
        this.DropOff = DropOff;
        this.TypeOfService = TypeOfService;
        this.Requirements = Requirements;
        this.priority = priority;
    }

    /**
     * @return the name
     */
    public String getName() {
        return Name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String Name) {
        this.Name = Name;
    }

    /**
     * @return the kind
     */
    public String getKind() {
        return Kind;
    }

    /**
     * @param kind the kind to set
     */
    public void setKind(String Kind) {
        this.Kind = Kind;
    }

    /**
     * @return the pick up
     */
    public String getPickUp() {
        return PickUp;
    }

    /**
     * @param pick up the pick up to set
     */
    public void setPickUp(String PickUp) {
        this.PickUp = PickUp;
    }

    /**
         * @return the drop off
         */
        public String getDropOff() {
            return DropOff;
        }

        /**
         * @param drop off the drop off to set
         */
        public void setDropOff(String DropOff) {
            this.DropOff = DropOff;
    }

    /**
         * @return the type of service
         */
        public String getTypeOfService() {
            return TypeOfService;
        }

        /**
         * @param type of service the type of service to set
         */
        public void setTypeOfService(String TypeOfService) {
            this.TypeOfService = TypeOfService;
    }

    /**
         * @return the requirements
         */
        public String getRequirements() {
            return Requirements;
        }

        /**
         * @param requirements the requirements to set
         */
        public void setRequirements(String Requirements) {
            this.Requirements = Requirements;
    }

    /**
             * @return the priority
             */
            public int getPriority() {
                return priority;
            }

            /**
             * @param requirements the priority to set
             */
            public void setPriority(int priority) {
                this.priority = priority;
    }



              public int compare(Orders1 orderA, Orders1 orderB){

                            if(orderA.getPriority() < orderB.getPriority())

                            return -1;

                            else if(orderA.getPriority() > orderB.getPriority())

                            return 1;

                            else

                            return 0;



            }

            public String toString(){

            return  "\t" + Name + "\t\t" + Kind + "\t\t" + PickUp + "\t\t" + DropOff + "\t\t" + TypeOfService + "\t\t" + Requirements;
        }





            /*public int compareTo(Object otherKind){

                            if(booked_in_advance() > urgent)

                            return 1;

                            else if(booked_in_advance < urgent)

                            return -1;

                            else

                            return 0;

            }*/

            PriorityQueue<Orders1> priorityQueue = new PriorityQueue<Orders1>();



        public static void main (String []args) throws IOException
            {

            String out="";
                  BufferedReader in = new BufferedReader(new FileReader("companyOrders.txt"));
                String str;
                while ((str = in.readLine()) != null)
                 {
                    out+=str+"\n";
                }
                in.close();
                System.out.print(out);
    }
        //Orders1[] orders1 = new Orders1[100];



            /*  while (!prioritQueue.isEmpty()) {
                      System.out.println(priorityQueue.remove());
 }*/


            //Orders1 o1 = newOrders1("booked in advance",



    }

Where is the code and logic that will do any sorting?

Can you print out the contents of the queue that shows what order it is created in?

 public int compare(Orders1 orderA, Orders1 orderB){

                            if(orderA.getPriority() < orderB.getPriority())

                            return -1;

                            else if(orderA.getPriority() > orderB.getPriority())

                            return 1;

                            else

                            return 0;

What code will call the compare() method?
When will it be called?

i getting about six errors with it like illegal from the w and the !
; expected and others

                while (!prioritQueue.isEmpty()) {
                      System.out.println(priorityQueue.remove());
 }

Please post the full text of the error messages.

Where in the posted code do you add anything to the queue?

all the examples i have seen is where you add to the queue but none where you read in a file

You do not need a file for testing the queue. Just hardcode some calls to the add() method 4+ times and printout the contents of the queue to see if it is sorted correctly.
Save the reading of the file for the next project. Get the queue to work now.

i learn by direct examples so don't have to guess and do a run around when there are examples of direct path

Examples are OK when you're writing something that has already been written meny times, but far less useful when you are doing anything new. Reading and using the API JavaDoc is an absolutely essential Java skill that you need to start practicing now.

Put this in the main method to add some items to the queue for testing:

priorityQueue.add(new Orders1(...)); // add some items to the queue
priorityQueue.add(new Orders1(...));
priorityQueue.add(new Orders1(...));
priorityQueue.add(new Orders1(...));
System.out.println("pQ=" + priorityQueue); // Show its contents

from what i have seen in priority queue online they don' have the addElement and remove within their code is it seperate, is it suppose to be there somewhere because this is what i have now and i have an error saying

the method addElement (Orders1[]) is undefined for the type og PriorityQueue<Orders1>



import java.io.*;
import java.util.PriorityQueue;
import java.lang.Comparable;
//import java.util.Comparator;
import java.util.*;
import java.io.FileReader;
import java.util.Scanner;
import java.io.FileInputStream;
//import java.lang.*;

public class Orders1 implements Comparable<Orders1>{


    private String Name;
    private String Kind;
    private String PickUp;
    private String DropOff;
    private String TypeOfService;
    private String Requirements;
    private int priority;



    public Orders1(String Name, String Kind, String PickUp, String DropOff, String TypeOfService, String Requirements, int priority) {
        this.Name = Name;
        this.Kind = Kind;
        this.PickUp = PickUp;
        this.DropOff = DropOff;
        this.TypeOfService = TypeOfService;
        this.Requirements = Requirements;
        this.priority = priority;
    }

    /**
     * @return the name
     */
    public String getName() {
        return Name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String Name) {
        this.Name = Name;
    }

    /**
     * @return the kind
     */
    public String getKind() {
        return Kind;
    }

    /**
     * @param kind the kind to set
     */
    public void setKind(String Kind) {
        this.Kind = Kind;
    }

    /**
     * @return the pick up
     */
    public String getPickUp() {
        return PickUp;
    }

    /**
     * @param pick up the pick up to set
     */
    public void setPickUp(String PickUp) {
        this.PickUp = PickUp;
    }

    /**
         * @return the drop off
         */
        public String getDropOff() {
            return DropOff;
        }

        /**
         * @param drop off the drop off to set
         */
        public void setDropOff(String DropOff) {
            this.DropOff = DropOff;
    }

    /**
         * @return the type of service
         */
        public String getTypeOfService() {
            return TypeOfService;
        }

        /**
         * @param type of service the type of service to set
         */
        public void setTypeOfService(String TypeOfService) {
            this.TypeOfService = TypeOfService;
    }

    /**
         * @return the requirements
         */
        public String getRequirements() {
            return Requirements;
        }

        /**
         * @param requirements the requirements to set
         */
        public void setRequirements(String Requirements) {
            this.Requirements = Requirements;
    }

    /**
             * @return the priority
             */
            public int getPriority() {
                return priority;
            }

            /**
             * @param requirements the priority to set
             */
            public void setPriority(int priority) {
                this.priority = priority;
    }

                public boolean addElement(){


                }


              public int compareTo(Orders1 order){

                            if(order instanceof Orders1){
                                Orders1 orders1 = (Orders1) order;
                                if(this.priority > orders1.getPriority())
                                    return 1;



                                else if(this.priority < orders1.getPriority())

                                    return -1;


                            }
                            return 0;








            }

            public String toString(){

            return  "\t" + Name + "\t\t" + Kind + "\t\t" + PickUp + "\t\t" + DropOff + "\t\t" + TypeOfService + "\t\t" + Requirements;
        }




        public static void main (String []args) throws IOException
            {

           /* String out="";
                  BufferedReader in = new BufferedReader(new FileReader("companyOrders.txt"));
                String str;
                while ((str = in.readLine()) != null)
                 {
                    out+=str+"\n";
                }
                in.close();
                System.out.print(out);
    }*/


            File file = new File("companyOrders.txt");

                    FileReader inputFile = new FileReader(file);

                    Scanner scan = new Scanner(file);


            //Orders1 o1 = newOrders1("booked in advance",
                  Orders1[] orders1 = new Orders1[180];
                    PriorityQueue<Orders1> pq = new PriorityQueue<Orders1>();


                    while(scan.hasNext()){

                    }

                    System.out.println("Before Priority Order");

                    while(scan.hasNext())

                                {  

                                     pq.addElement(orders1);



                                }


                    System.out.println("Put in Priority Order: "); 

                        while(!pq.isEmpty())

                        {

                            System.out.println(pq.remove()+ " ");

                        }



                        System.out.println();

                            }

}




    }
}

i am adding your e.g but getting errors with new saying cannot find symbol
constructor Orders1(java.lang.String

cannot find symbol
constructor Orders1(java.lang.String

You need to study how to call the constructor of a class to create an instance of a class.

i have an error saying

Please post the full text of any error messages. Your one line does not show all the information in the message.

Your attempt at testing the PQ is too complicated. Do it the simple way:
create a PQ
add 4 items to the PQ
print out the contents of the PQ

Nothing more just those 4 steps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.