Difference between revisions of "CSC212 Lab 6 Solutions 2014"

From dftwiki3
Jump to: navigation, search
Line 39: Line 39:
 
addToHead( el );
 
addToHead( el );
 
else {
 
else {
tail.next = new IntSLLNode( el );
+
tail.next = new IntSLLNode2( el );
 
tail = tail.next;
 
tail = tail.next;
}
+
length++;
length++;
+
}
 
}
 
}
 
 
Line 65: Line 65:
 
System.out.println( "+===========================================\n| List:");
 
System.out.println( "+===========================================\n| List:");
 
System.out.println( isEmpty()? "| is empty": "| is not empty" );
 
System.out.println( isEmpty()? "| is empty": "| is not empty" );
System.out.println( "| contains " + length + " elements" );
+
System.out.println( "| contains " + length + " element" + ((length!=1)? "s":"" ) );
 
System.out.print( "| elements: " );
 
System.out.print( "| elements: " );
 
printAll();
 
printAll();
 
System.out.println( "+===========================================" );
 
System.out.println( "+===========================================" );
 
}
 
}
 +
 
 
 
public static void main(String[] args) {
 
public static void main(String[] args) {

Revision as of 12:15, 1 October 2014

--D. Thiebaut (talk) 13:04, 1 October 2014 (EDT)




...