posted 4 years ago

I am in urgent need of help, in 2 hours my homework will be due and I haven't got the slightest clue how to fix everything

Please, if anybody can help me finish this, I am seriously begging you.

this is the HeapPriorityQueue class I have so far:

this should implement

this wil be the Driver class

but I am getting these Problems:

Description Resource Path Location Type

Java Problem

Bound mismatch: The type String is not a valid substitute for the bounded parameter <V extends Comparable<K>> of the type HeapPriorityQueue<K,V> HeapPriorityQueueDriver.java /MP7/src/simon/mp7 line 6 Java Problem

Bound mismatch: The type K is not a valid substitute for the bounded parameter <K extends Comparable<K>> of the type Entry<K,V> HeapPriorityQueue.java /MP7/src/simon/mp7 line 199 Java Problem

The serializable class UnderflowException does not declare a static final serialVersionUID field of type long UnderflowException.java /test/src/test line 8 Java Problem

Bound mismatch: The type K is not a valid substitute for the bounded parameter <K extends Comparable<K>> of the type Entry<K,V> HeapPriorityQueue.java /MP7/src/simon/mp7 line 193 Java Problem

Bound mismatch: The type K is not a valid substitute for the bounded parameter <K extends Comparable<K>> of the type Entry<K,V> HeapPriorityQueue.java /MP7/src/simon/mp7 line 187 Java Problem

The method compareTo(K) is undefined for the type K HeapPriorityQueue.java /MP7/src/simon/mp7 line 126 Java Problem

The method compareTo(K) is undefined for the type K HeapPriorityQueue.java /MP7/src/simon/mp7 line 104 Java Problem

The method compareTo(K) is undefined for the type K HeapPriorityQueue.java /MP7/src/simon/mp7 line 100 Java Problem

Bound mismatch: The type K is not a valid substitute for the bounded parameter <K extends Comparable<K>> of the type PriorityQueue<K,V> HeapPriorityQueue.java /MP7/src/simon/mp7 line 5 Java Problem

and this Console Message:

Exception in thread "main" java.lang.Error: Unresolved compilation problem:

Bound mismatch: The type String is not a valid substitute for the bounded parameter <V extends Comparable<K>> of the type HeapPriorityQueue<K,V>

at simon.mp7.HeapPriorityQueueDriver.main(HeapPriorityQueueDriver.java:6)

Please, if anybody can help me finish this, I am seriously begging you.

this is the HeapPriorityQueue class I have so far:

this should implement

this wil be the Driver class

but I am getting these Problems:

Description Resource Path Location Type

Java Problem

Bound mismatch: The type String is not a valid substitute for the bounded parameter <V extends Comparable<K>> of the type HeapPriorityQueue<K,V> HeapPriorityQueueDriver.java /MP7/src/simon/mp7 line 6 Java Problem

Bound mismatch: The type K is not a valid substitute for the bounded parameter <K extends Comparable<K>> of the type Entry<K,V> HeapPriorityQueue.java /MP7/src/simon/mp7 line 199 Java Problem

The serializable class UnderflowException does not declare a static final serialVersionUID field of type long UnderflowException.java /test/src/test line 8 Java Problem

Bound mismatch: The type K is not a valid substitute for the bounded parameter <K extends Comparable<K>> of the type Entry<K,V> HeapPriorityQueue.java /MP7/src/simon/mp7 line 193 Java Problem

Bound mismatch: The type K is not a valid substitute for the bounded parameter <K extends Comparable<K>> of the type Entry<K,V> HeapPriorityQueue.java /MP7/src/simon/mp7 line 187 Java Problem

The method compareTo(K) is undefined for the type K HeapPriorityQueue.java /MP7/src/simon/mp7 line 126 Java Problem

The method compareTo(K) is undefined for the type K HeapPriorityQueue.java /MP7/src/simon/mp7 line 104 Java Problem

The method compareTo(K) is undefined for the type K HeapPriorityQueue.java /MP7/src/simon/mp7 line 100 Java Problem

Bound mismatch: The type K is not a valid substitute for the bounded parameter <K extends Comparable<K>> of the type PriorityQueue<K,V> HeapPriorityQueue.java /MP7/src/simon/mp7 line 5 Java Problem

and this Console Message:

Exception in thread "main" java.lang.Error: Unresolved compilation problem:

Bound mismatch: The type String is not a valid substitute for the bounded parameter <V extends Comparable<K>> of the type HeapPriorityQueue<K,V>

at simon.mp7.HeapPriorityQueueDriver.main(HeapPriorityQueueDriver.java:6)

posted 4 years ago

You have this as the class definition:

The interface is this:

And you are creating an instance like this:

Do you see how your class definition says "A HeapPriorityQueue with keys of some type K, and whose value, V, is a Comparable for the Key". Does that make sense? Note it doesn't follow the interface which says "A PriorityQueue with keys of some type K which must be Comparable to Ks, and whose value, V, is of some type."

Then look at your instance. You try to make a HeapPriorityQueue whose K is Integer, and the rule for V is that it must be Comparable<Integer>, but you put a String in there. Is a String Comparable<Integer>?

`public class HeapPriorityQueue<K,V extends Comparable<K>> implements PriorityQueue<K, V>`The interface is this:

`public interface PriorityQueue<K extends Comparable<K>,V>`And you are creating an instance like this:

`PriorityQueue<Integer, String> queue = new HeapPriorityQueue<Integer, String>()`Do you see how your class definition says "A HeapPriorityQueue with keys of some type K, and whose value, V, is a Comparable for the Key". Does that make sense? Note it doesn't follow the interface which says "A PriorityQueue with keys of some type K which must be Comparable to Ks, and whose value, V, is of some type."

Then look at your instance. You try to make a HeapPriorityQueue whose K is Integer, and the rule for V is that it must be Comparable<Integer>, but you put a String in there. Is a String Comparable<Integer>?

Steve

Simon Go

Greenhorn

Posts: 2