i tried to add enum.. not sure why its not working... pls help.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Random;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author ~~ica
*/
public class forma extends HttpServlet {
enum type1{Hearts, Diamonds, Spades, Clover}
public enum type2{
One(1), Two(2), Three(3),Four(4),Five(5),Six(6),Seven(7),Eight(8),
Nine(9),Ten(10),Jack(10), Queen(10),King(10), Ace(11);
private int card;
private type2 (int c){
card = c;
}
public int getCard(){
return card;
}
}
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
final PrintWriter out = response.getWriter();
String start = request.getParameter("start");
if(start.equalsIgnoreCase("yes")){
Random num = new Random();
int n = num.nextInt();
out.println("\n<h3>~~Your Cards~~");
for(n=1; n<=3; n++)
{
type1[] value1 = type1.values();
type1 val1 = value1[n];
type2[] value2 = type2.values();
type2 val2 = value2[n];
out.println("<h1>Card" + n + ": " +val1+" of "+val2);
}
for(type2 sum : type2.values())
out.println("\n<h1>Your total points is " +sum.getCard);
}
else{
out.println("Thank you!!!");
}
try {
/* TODO output your page here
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet forma</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet forma at " + request.getContextPath () + "</h1>");
out.println("</body>");
out.println("</html>");
*/
} finally {
out.close();
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}