final-sample-3-key

final-sample-3-key - CSE 143 Sample Final Exam #3 Key 1....

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

View Full Document Right Arrow Icon
CSE 143 Sample Final Exam #3 Key 1. Statement Output var1.method1(); var1.method2(); var1.method3(); var2.method1(); var2.method2(); var2.method3(); var3.method1(); var4.method1(); var4.method2(); var4.method3(); ((Don) var1).method2(); ((Mike) var2).method2(); ((Raph) var3).method1(); ((Don) var3).method2(); ((Leo) var4).method3(); Raph 1 error error Leo 1 Mike 2/Leo 1/Don 2 Leo 3/Leo 1 error Leo 1 Leo 1/Don 2 error Raph 1/Don 2 Mike 2/Leo 1/Don 2 Raph 1 error Leo 3/Leo 1 2. public class Playa extends Person implements Comparable<Playa> { private Set<Person> fiancees; public Playa(String name) { super(name); fiancees = new HashSet<Person>(); } public void engageTo(Person other) { super.engageTo(other); if (other == null) { fiancees.clear(); } else { // if this were a List, I would need to call contains to avoid duplicates fiancees.add(other); } } public boolean isSingle() { return countFiancees() == 0; } public int countFiancees() { return fiancees.size(); } public int compareTo(Playa other) {
Background image of page 1

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

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

This document was uploaded on 12/17/2011.

Page1 / 3

final-sample-3-key - CSE 143 Sample Final Exam #3 Key 1....

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