예제 #1
0
  @RequestMapping(value = "/buildOrder.html", method = RequestMethod.GET)
  public ModelAndView get(HttpServletRequest request) {

    if (LOGGER.isDebugEnabled()) {
      LOGGER.debug("Redirecting to current order details page");
    }

    HttpSession session = request.getSession(true);
    String orderrestaurantid = (String) session.getAttribute("orderrestaurantid");
    String restaurantid = (String) session.getAttribute("restaurantid");
    Search search = (Search) session.getAttribute("search");

    if (orderrestaurantid != null) {
      restaurantid = orderrestaurantid;
    }

    if (restaurantid == null) {
      if (search == null) {
        return new ModelAndView("redirect:/home.html", null);
      } else {
        return new ModelAndView("redirect:/search.html" + search.getQueryString());
      }
    } else {
      Restaurant restaurant = restaurantRepository.findByRestaurantId(restaurantid);
      return new ModelAndView("redirect:/" + restaurant.getUrl());
    }
  }
예제 #2
0
파일: Search.java 프로젝트: daisyb/apHw
 public static void main(String[] args) {
   Random rnd = new Random();
   Search s = new Search(10);
   for (int i = 0; i < 10; i++) {
     s.addTerm(i, rnd.nextInt(15));
   }
   s.sort();
   System.out.println(s);
   System.out.println(s.rbsearch(5));
 }
예제 #3
0
  protected static void searchBasedOnCriteria(UserID user, Scanner scan) {

    assert (user != null && scan != null);

    SearchCriteria criteria = user.getUserCriteria();
    if (criteria != null) { //
      System.out.println("Current search criteria:\n" + criteria);
      System.out.println(
          "Press 1 if you would like to set up new search criteria or "
              + "anything else if you want to use current one");
      String input = scan.next();
      if (input.length() == 1 && input.charAt(0) == '1') user.setUpSearch(scan);
    } else {
      user.setUpSearch(scan);
    }

    Search search = new Search(user);
    printUserList(search.findUsersBasedOnSearchCriteria());
  }
예제 #4
0
  public int makeComputerMove(long timeRemaining) {
    // othellonator makes a move

    Move myMove = null;
    moveCount++;
    System.out.println("(C moveCount = " + moveCount + ")");
    if (this.generateLegalMoves(myColor)) { // evaluate board, do stuff if legal moves found
      String listSize = Integer.toString(getLegalMovesListSize());
      System.out.println("(C Number of moves:" + listSize + " )");

      if (moveCount < 10) {
        myMove = Search.alphaBetaSearch(this, 6, myColor);
      } else if (moveCount >= 10 && moveCount <= 20) {
        myMove = Search.alphaBetaSearch(this, 8, myColor);
      } else {
        myMove = Search.alphaBetaSearch(this, 10, myColor);
      }
      this.applyMove(myColor, myMove); // apply the move returned by the search
      return myMove.getPosition(); // return the position of the move so it can be output
    } else return -1; // signal that no move was found
  }