예제 #1
0
 /* (non-Javadoc)
  * Get to the next state, depending on the mode.
  * @see com.eric.state.StateInterface#getForward(com.eric.demo.Demo, java.lang.String)
  *
  */
 public boolean getForward(Demo demo, String mode) {
   if (mode.equals("name")) {
     StateInterface searchByNameState = new SearchByNameState(this.manager);
     demo.setState(searchByNameState);
   } else if (mode.equals("mobile")) {
     StateInterface searchByMobileState = new SearchByMobileState(this.manager);
     demo.setState(searchByMobileState);
   } else if (mode.equals("address")) {
     StateInterface searchByAddressState = new SearchByAddressState(this.manager);
     demo.setState(searchByAddressState);
   } else {
     System.out.println("you can search by `name`, `mobile` or `address`.");
     System.out.println("regular expression can be used to query.");
   }
   return true;
 }
예제 #2
0
파일: Demo.java 프로젝트: hupan/AddressBook
 /* (non-Javadoc)
  * @see java.lang.Runnable#run()
  */
 public void run() {
   Demo demo = new Demo();
   demo.execute();
 }