Exam 1 (Fall 2005) solution

Exam 1 (Fall 2005) solution - if (n >= 0) scoops += n }...

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

View Full Document Right Arrow Icon
Sheet1 Page 1 sPart I 1. A 4. D 7. D 10. A 13. C 16. A 2. E 5. E 8. B 11. E 14. D 17. C 3. B 6. B 9. B 12. C 15. E 18. D Part II 1 TestFlow: x = 12 TestFlow: y = 34 display: b = 34 display: a = 12 confuse: a = 8 display: b = 8 display: a = 12 2 class Cone { private int scoops private String flavor public Cone(String f) { scoops = 0 flavor = f } public void addScoops(int n) { // if n is negative, we will do nothing
Background image of page 1

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

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

Unformatted text preview: if (n >= 0) scoops += n } public int getScoops() { return scoops } public String getFlavor() { return flavor } public void consume() { scoops = 0 flavor = "none" } } 3 Cone chocolate = new Cone("chocolate") Cone vanilla = new Cone("vanilla") chocolate.addScoops(12) Sheet1 Page 2 vanilla.addScoops(8) vanilla.consume()...
View Full Document

This note was uploaded on 03/27/2008 for the course CS 302 taught by Professor Willbenton during the Fall '07 term at Wisconsin.

Page1 / 2

Exam 1 (Fall 2005) solution - if (n >= 0) scoops += n }...

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

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