예제 #1
0
 /** 스펙을 가지고 찾기 (예를 들어 어른용이라고 검색하면 어른용 장난감이 출력됨) */
 public List<Toy> searchType(ToySpec searchSpec) {
   List<Toy> temp = new ArrayList<Toy>();
   Enumeration<Toy> e = toys.elements();
   while (e.hasMoreElements()) {
     Toy toy = (Toy) e.nextElement();
     ToySpec spec = toy.getSpec();
     if (spec.equals(searchSpec)) {
       temp.add(toy);
     }
   }
   return temp;
 }
예제 #2
0
 // 스펙 비교 검색
 public boolean match(ToySpec spec) {
   boolean boo = false;
   String dest = "", target = ""; // dest : 비교대상, target :비교당하는 객체]
   if (spec.getMap("ToyUser") != null) {
     dest += spec.getMap("ToyUser");
     target += this.getMap("Toyuser");
   }
   if (spec.getMap("ToyType") != null) {
     dest += spec.getMap("ToyType");
     target += this.getMap("ToyType");
   }
   return spec.equals(target);
 }