Chapter-6

Chapter-6 - Using the Java Library...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
COE318 Fall 2008, Olivia Das, Elec. and Comp. 1 Using the Java Library http://java.sun.com/javase/6/docs/api/ System String Scanner Math Integer …. import statement
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
COE318 Fall 2008, Olivia Das, Elec. and Comp. 2 Chap-5: Bug in the game 1 -> miss 2 -> miss 3 -> miss 4 -> hit 5 -> hit 6 -> hit You took 6 guesses 4 -> hit 4 -> hit 4 -> hit You took 3 guesses
Background image of page 2
COE318 Fall 2008, Olivia Das, Elec. and Comp. 3 public String checkYourSelf(String guess ){ int guess = Integer.parseInt( guess ); String result = “MISS”; for( int cell : locationCells ){ if (guess == cell) { result = “HIT”; numOfHits++; break; } } if(numOfHits == locationCells.length) result = “KILL”; return result; }
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
COE318 Fall 2008, Olivia Das, Elec. and Comp. 4 The ArrayList Class ArrayList class is part of java.util package ArrayList band = new ArrayList(); add things in it band.add( new String(“Paul”) ); band.add( new Integer(2) ); [ ] syntax cannot be used also Vector class…
Background image of page 4
COE318 Fall 2008, Olivia Das, Elec. and Comp.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 12

Chapter-6 - Using the Java Library...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online