All pastes #981884 Raw Edit

Driver

public text v1 · immutable
·published 2008-04-12 02:47 UTC
rendered paste body
class Driver {
	public static void main(String[] args) {
		IntList a = new IntList(null);
		IntList b = a.cons(2);
		IntList c = b.cons(1);

		IntList d = new IntList(null);
		IntList e = d.cons(4);
		IntList f = e.cons(3);

		System.out.println("Values of IntList a - f");
		a.print();
		b.print();
		c.print();
		d.print();
		e.print();
		f.print();

// #2 
		System.out.println("#2. Check if f contains 3 " + f.contains(3));
		System.out.println("#2. Check if f contains 4 " + f.contains(4));
// #3 
		System.out.println("#3. Check if f = f " + f.equals(f));
		System.out.println("#3. Check if f = c " + f.equals(c));
// #4
		IntList g = c.append(f);	
		System.out.print("#4. g = c.append(f)  "); g.print();
// #5
		IntList h = g.reverse();
		System.out.print("#5. h = g.reverse()  "); h.print();
// #6
		System.out.print("#6. h.reverseME(); h.print()  "); h.reverseME(); h.print();

// #9
		System.out.print("9. i = g.appendRec(f) "); 
		IntList i = g.appendRec(f); i.print();
// #7
		System.out.println("7. i.sort().print() "); i.sort().print();
// #8

// #10
		Int fifteen = new Int(15);
		Int three = new Int(3);
		System.out.println("10. fifteen.plus(three) " + fifteen.plus(three));
		System.out.println("10. fifteen.minus(three) " + fifteen.minus(three));
		System.out.println("10. fifteen.times(three) " + fifteen.times(three));
		System.out.println("10. fifteen.div(three) " + fifteen.div(three));
		System.out.println("10. fifteen.isPrime() " + fifteen.isPrime());
		System.out.println("10. three.isPrime() " + three.isPrime());
		System.out.println("10. Int.toString() is called with \" \" + Int.value above");

		System.out.println("For page 291 #1 use Queue/PriorityQueue directly for testing as they have their own main() method");
		System.out.println("For page 291 #2 use AHash/AList/SizedAList for testing as they also have their own main() method");
		
	}
}