CSI Summer 2010 Sample Final Key

CSI Summer 2010 Sample Final Key - QUESTION 1 Add full...

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: QUESTION 1 Add full Javadoc compliant comments to the following method. Be sure to describe the behavior of the method. For full credit, also add comments in the method to explain each block of code. public static int doesSomething(Picture a, Color c) { int n = 0; for(int x = 0; x < a.getWidth(); x++) for(int y = 0; y < a.getHeight(); y++) if(a.getPixel(x,y).colorDistance(c) <= 1) n++; return n; } Introduction to Computer Science CSI201 Summer 2010 SAMPLE QUESTIONS FOR FINAL QUESTION 2 Create a method called rollDie() that will simulate rolling a die. The method should return a random integer that will be either 1, 2, 3, 4, 5, or 6. Csi 201 - Sample Final - Summer 2010 Page 2 public static int rollDie() { Random randGen = new Random(); return randGen.nextInt(6) + 1; } QUESTION 2 Create a method called rollDie() that will simulate rolling a die. The method should return a random integer that will be either 1, 2, 3, 4, 5, or 6....
View Full Document

This note was uploaded on 02/07/2011 for the course CSI 201 taught by Professor Doanne during the Spring '08 term at SUNY Albany.

Page1 / 5

CSI Summer 2010 Sample Final Key - QUESTION 1 Add full...

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

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