import java.math.*; import javax.imageio.*; import java.awt.image.*; import java.awt.event.*; import java.awt.*; import java.security.spec.*; import java.security.*; import java.lang.management.*; import java.lang.ref.*; import java.lang.reflect.*; import java.net.*; import java.io.*; import javax.swing.table.*; import javax.swing.text.*; import javax.swing.event.*; import javax.swing.*; import java.util.concurrent.atomic.*; import java.util.concurrent.*; import java.util.regex.*; import java.util.List; import java.util.zip.*; import java.util.*; public class main { public static String googleMe(String command) { List word = new ArrayList(); String url = "https://www.google.com/search?q="; for (String singleWord : command.split(" ")) { word.add(singleWord); } if (word.get(0).toLowerCase().equals("google")) { for (int i = 1; i < word.size(); i++) { url += urlencode(word.get(i)) + "+"; } return url; } return ""; } // gooooogleMe public static String bingMe(String command) { List word = new ArrayList(); String url = "https://bing.com/search?q="; for (String singleWord : command.split(" ")) { word.add(singleWord); } if (word.get(0).toLowerCase().equals("bing")) { for (int i = 1; i < word.size(); i++) { url += urlencode(word.get(i)) + "+"; } return url; } return ""; } // biiiiiingMe static String answer(String s) { String x = googleMe(s); if (!isEmpty(x)) return x; return bingMe(s); } static boolean isEmpty(Collection c) { return c == null || c.isEmpty(); } static boolean isEmpty(String s) { return s == null || s.length() == 0; } static String urlencode(String x) { try { return URLEncoder.encode(unnull(x), "UTF-8"); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } static String unnull(String s) { return s == null ? "" : s; } static List unnull(List l) { return l == null ? emptyList() : l; } static List emptyList() { return Collections.emptyList(); } }