i am doing a project with a group i have to deal with orders by kind then linked to the driver who will be taking the first customer. the driver can be free or back in 10 min. i have started with the order list with the customer, i have…
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.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
implements Comparator
Either remove the above or correctly code the class.
Read how to code here:
Click Here
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
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?
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
What code will call the compare() method?
When will it be called?
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
Please post the full text of the error messages.
Where in the posted code do you add anything to the queue?
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
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.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
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.
JamesCherrill
... trying to help
8,512 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,455
Skill Endorsements: 30
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
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
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.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16