Commit 624d5403 by Pedro Rolon

Se agregó código para ordenar las cartas del ejercicio 3

parent f61f5997
......@@ -6,6 +6,8 @@ import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Collections;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
......@@ -56,9 +58,37 @@ public class ManoDoc extends HttpServlet {
System.out.println(nombreJugada);
System.out.println("************************");
ArrayList<String> manoString = new ArrayList<String>();
for(int i=0; i<mano.length;i++) {
if(mano[i].valor.equals("A")) {
mano[i].valor = "R";
}
else if(mano[i].valor.equals("T")){
mano[i].valor = "10";
}
manoString.add(mano[i].valor+mano[i].palo);
}
Collections.sort(manoString);
for(int i=0; i<mano.length; i++) {
if(manoString.get(i).charAt(0)=='R') {
mano[i] = new Carta("A"+manoString.get(i).charAt(1));
}
else if(manoString.get(i).charAt(0)=='1' && manoString.get(i).charAt(1)=='0'){
mano[i] = new Carta("T"+manoString.get(i).charAt(2));
}
else {
mano[i] = new Carta(manoString.get(i));
}
}
request.setAttribute("mano", mano);
request.setAttribute("nombreJugada", nombreJugada);
RequestDispatcher rd = getServletContext().getRequestDispatcher("/WEB-INF/jsp/mano_doc.jsp");
rd.forward(request, response);
}
......@@ -72,7 +102,7 @@ public class ManoDoc extends HttpServlet {
public static String obtenerJson(String myURL) {
System.setProperty("http.agent", "Chrome");
System.out.println("Requeted URL:" + myURL);
System.out.println("Requested URL:" + myURL);
StringBuilder sb = new StringBuilder();
URLConnection urlConn = null;
InputStreamReader in = null;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment