Question: package com.dronerecon.ws; import javax.servlet.*; import javax.servlet.http.*; import java.io.*; import java.util.*; import java.security.SecureRandom; /** * * @author Your Name Here :-) */ public class DroneDataService extends

package com.dronerecon.ws;

import javax.servlet.*;

import javax.servlet.http.*;

import java.io.*;

import java.util.*;

import java.security.SecureRandom;

/**

*

* @author Your Name Here :-)

*/

public class DroneDataService extends HttpServlet{

public void doGet(HttpServletRequest request,

HttpServletResponse response)

throws ServletException, IOException {

response.setContentType("application/json;charset=utf-8");

response.addHeader("Access-Control-Allow-Origin", "*");

PrintWriter out = response.getWriter();

// ##############################

// 1. Get params passed in.

// Get the following parameters from the request object and put them into strings:

// area_id

// tilex

// tiley

// totalcols

// totalrows

// ##############################

String sarea_id = Integer.parseInt.request.getParameter("area_id"));

String stilex = Integer.parseInt.request.getParameter("tilex"));

String stiley = Integer.parseInt.request.getParameter("tiley"));

String stotalcols = Integer.parseInt.request.getParameter("totalcols"));

String stotalrows = Integer.parseInt.request.getParameter("totalrows"));

// ##############################

// 2. Default value of beginning direction.

String sDirection = right;

// Set a string called sDirection to "right".

// ##############################

// ##############################

// 3. Calculate next drone move.

// Determine next tile to move to.

// Base this on current x and y.

// Change sDirection if necessary.

// Drone must serpentine from top left of grid back and forth down.

// If rows are done, change sDirection to "stop".

// ##############################

// ##############################

// 4. Format & Return JSON string to caller.

/* Return via out.println() a JSON string like this:

{"area_id":"[area id from above]", "nextTileX":"[next tile x]", "nextTileY":"[next tile y]", "direction":"[direction string from above]"}

*/

// ##############################

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!