OrderSet - OrderSet s = new OrderSet s.insert(10 s.insert(5...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.*; i public class OrderSet extends Vector { public void insert(int x) { for(int i = 0; i < size(); i++) { if(x < ((Integer)get(i)).intValue()) { add(i, new Integer(x)); return; } } // if it is bigger than all element add(new Integer(x)); } public int getInteger(int index) { return ((Integer)get(index)).intValue(); } public static void main(String[] args) {
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: OrderSet s = new OrderSet(); s.insert(10); s.insert(5); s.insert(15); System.out.println(s); s.insert(7); System.out.println(s); s.insert(-5); System.out.println(s); s.insert(30); System.out.println(s); s.insert(28); System.out.println(s); s.insert(0); System.out.println(s); S int num; num = s.getInteger(3); System.out.println(num); } }...
View Full Document

This note was uploaded on 12/17/2010 for the course JAVA 021210 taught by Professor Michael during the Spring '10 term at NYU.

Ask a homework question - tutors are online