Difference between revisions of "CSC212 Homework 7 2014"

From dftwiki3
Jump to: navigation, search
Line 10: Line 10:
 
=Problem #1=
 
=Problem #1=
 
<br />
 
<br />
Look at this [[Media:CSC212_heap_javadoc.pdf| javadoc document]];  it is the javadoc (pdf) of the program you have to implement.  It is a heap implemented with an ArrayList of ints.
+
Look at this [[Media:CSC212_heap_javadoc.pdf| javadoc document]];  it is the javadoc (pdf) of the program you have to implement.  It is a heap implemented with an ArrayList of ints.  
 
<br />
 
<br />
 +
* You have to reconstruct it, including all its method, and call the class '''Heap.java'''.
 +
* You will notice that the ''pop()'' method returns the top of the heap, but if the heap is empty, it raises an exception of type '''HeapEmptyException'''.  Its definition is given below.  You should create a separate java file for it, and call it HeapEmptyException.java.  Your program will automatically find it if you declare it in the same Eclipse package.
 +
<br />
 +
::<source lang="java">
 +
 +
public class HeapEmptyException extends Exception{
 +
    //Parameterless Constructor
 +
    public HeapEmptyException() {}
 +
 +
    //Constructor that accepts a message
 +
    public HeapEmptyException(String message){
 +
      super(message);
 +
    }
 +
}
 +
</source>

Revision as of 09:59, 3 November 2014

--D. Thiebaut (talk) 09:51, 3 November 2014 (EST)



Contents


The program is due on Friday, Nov. 14, at 11:55 p.m.


Problem #1


Look at this javadoc document; it is the javadoc (pdf) of the program you have to implement. It is a heap implemented with an ArrayList of ints.

  • You have to reconstruct it, including all its method, and call the class Heap.java.
  • You will notice that the pop() method returns the top of the heap, but if the heap is empty, it raises an exception of type HeapEmptyException. Its definition is given below. You should create a separate java file for it, and call it HeapEmptyException.java. Your program will automatically find it if you declare it in the same Eclipse package.


public class HeapEmptyException extends Exception{
    //Parameterless Constructor
    public HeapEmptyException() {}

    //Constructor that accepts a message
    public HeapEmptyException(String message){
       super(message);
    }
}