|
home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
Dog d1 = new Dog(); Dog d2 = new Dog(); Dog d3; d3 = d1; d1.ageOneYear(); d1.getAge() d2.getAge() d3.getAge() |
01. class Glumberpmp { 03. private java.util.List<String> aphorisms; 04. 05. 06. public java.util.List<String> getAphorisms() { 07. return this.aphorisms; 08. } 09. 10. public Glumberpmp( int n ) { 12. aphorisms = new java.util.List<String>(); 13. 14. aphorisms.add( "Don't procrastinate now; wait 'til later." ); 15. if (n > 99) { 16. aphorisms.add( "Absence makes the heart go wander." ); 17. } 18. else { 19. aphorisms.add( "Familiarity breeds attempt." ); 20. } 21. 22. } 23. 24. 25. String getAbbreviatedWisdom() { 26. String wisdom = "I think: "; 27. for ( String a : this.getAphorisms() ) { 28. if (! a.equals("")) { 29. wisdom = wisdom + a.charAt(0) + "..."; 30. } 31. } 32. return wisdom; 33. } 34. 35. } |
/** Look for whether a particular PizzaServer has a classmate * in a list of PizzaServers. * @param p A particular PizzaServer. * @param employees A list of pizzaServers. * @return whether or not: a member of `employees' went to the same * high school as `p', yet is not identically the same as `p'. */ |
/** Check whether a list has two PizzaServers which both went * to the same high school. * @param workers A list of pizzaServers. * @return whether or not any two *different* members of `workers' both * went to the same High School. */ |
1Near the left-hand-side, have your variables -- small labeled boxes, with the labels to the left of the box, and its value inside the box. On the right-hand-side, have large boxes for objects, with the name of the class above the object, and inside the box show each of its fields, just like BlueJ's inspection window for an object. ↩
home—info—exams—lectures—labs—hws
Recipe—Laws—lies—syntax—java.lang docs—java.util docs
©2007, Ian Barland, Radford University Last modified 2007.Aug.27 (Mon) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |