KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > houseexample > House


1 package houseexample;
2
3 import java.util.Iterator JavaDoc;
4 import java.util.LinkedList JavaDoc;
5 import java.util.List JavaDoc;
6
7 /**
8  * @author delpiano
9  *
10  * To change this generated comment edit the template variable "typecomment":
11  * Window>Preferences>Java>Templates.
12  * To enable and disable the creation of type comments go to
13  * Window>Preferences>Java>Code Generation.
14  */

15 public class House {
16
17     private final int nb_of_inhibitants;
18     private String JavaDoc name;
19     private List JavaDoc inhibitants;
20     private StringBuffer JavaDoc 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 JavaDoc();
27         whiteboard = new StringBuffer JavaDoc();
28     }
29
30     /**
31      * Returns the name.
32      * @return String
33      */

34     public String JavaDoc getName() {
35         return name;
36     }
37
38     /**
39      * Sets the name.
40      * @param name The name to set
41      */

42     public void setName(String JavaDoc 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 JavaDoc getInhibitants() {
55         return inhibitants.iterator();
56     }
57     
58     public void writeOnBoard(String JavaDoc message) {
59         whiteboard.append(message);
60     }
61     
62     public String JavaDoc readBoard() {
63         return whiteboard.toString();
64     }
65
66 }
67
Popular Tags