1 package houseexample; 2 3 import java.util.Iterator ; 4 import java.util.LinkedList ; 5 import java.util.List ; 6 7 15 public class House { 16 17 private final int nb_of_inhibitants; 18 private String name; 19 private List inhibitants; 20 private StringBuffer whiteboard; 21 22 public House(int nb_of_inhibitants) { 23 super(); 24 this.nb_of_inhibitants = nb_of_inhibitants; 25 name = "Default In Code House Name"; 26 inhibitants = new LinkedList (); 27 whiteboard = new StringBuffer (); 28 } 29 30 34 public String getName() { 35 return name; 36 } 37 38 42 public void setName(String name) { 43 this.name = name; 44 } 45 46 public void addInhibitant(Man man) { 47 inhibitants.add(man); 48 } 49 50 public void removeInhibitant(Man man) { 51 inhibitants.remove(man); 52 } 53 54 public Iterator getInhibitants() { 55 return inhibitants.iterator(); 56 } 57 58 public void writeOnBoard(String message) { 59 whiteboard.append(message); 60 } 61 62 public String readBoard() { 63 return whiteboard.toString(); 64 } 65 66 } 67 | Popular Tags |