1 22 package test.implementation.modelmbean.support; 23 44 public class User { 45 46 private long id = System.currentTimeMillis(); 47 private String name = ""; 48 private String address = ""; 49 private String password = null; 50 private String [] numbers = new String [3]; 51 52 58 public User(long id) 59 { 60 this.id = id; 61 } 62 63 68 public User() 69 { 70 } 71 72 73 81 public long getID() { 82 return id; 83 } 84 85 86 87 93 public void setID(long id) { 94 this.id = id; 95 } 96 97 98 99 107 public String getName() { 108 return name; 109 } 110 116 public void setName(String name) { 117 118 120 this.name = name; 121 } 122 123 124 125 133 public String getAddress() { 134 return address; 135 } 136 137 143 public void setAddress(String address) { 144 this.address = address; 145 } 146 147 148 149 157 public String [] getPhoneNumbers() { 158 return numbers; 159 } 160 166 public void setPhoneNumbers(String [] numbers) { 167 this.numbers = numbers; 168 } 169 170 171 172 180 public void setPassword(String passwd) { 181 this.password = passwd; 182 } 183 184 185 187 193 public String printInfo() { 194 return 195 "User: " + getName() +"\n"+ 196 "Address: " + getAddress() +"\n"+ 197 "Phone #: " + getPhoneNumbers()[0] +"\n"+ 198 "Phone #: " + getPhoneNumbers()[1] +"\n"+ 199 "Phone #: " + getPhoneNumbers()[2] +"\n"; 200 } 201 202 208 public void addPhoneNumber(String number) { 209 for (int i = 0; i < numbers.length; ++i) 210 if (numbers[i] == null) { 211 numbers[i] = number; 212 break; 213 } 214 } 215 216 222 public void removePhoneNumber(int index) { 223 if (index < 0 || index >= numbers.length) 224 return; 225 226 numbers[index] = null; 227 } 228 } 229 230 231 | Popular Tags |