diff --git a/casic-shelter/src/main/java/com/casic/missiles/modular/system/utils/DecodeData.java b/casic-shelter/src/main/java/com/casic/missiles/modular/system/utils/DecodeData.java index 340d2ac..6621918 100644 --- a/casic-shelter/src/main/java/com/casic/missiles/modular/system/utils/DecodeData.java +++ b/casic-shelter/src/main/java/com/casic/missiles/modular/system/utils/DecodeData.java @@ -44,63 +44,67 @@ */ public static RobotInfo decodeRobotInfo(byte[] bytes) { RobotInfo robot = new RobotInfo(); - robot.setRobotId(ByteUtils.byteToUnsigned(bytes[4])); - robot.setReceiveTime(TimeUtil.getCurrentTime()); + try { + robot.setRobotId((int) bytes[4]); + robot.setReceiveTime(TimeUtil.getCurrentTime()); - byte[] lngBytes = new byte[4]; - System.arraycopy(bytes, 5, lngBytes, 0, 4); - robot.setLng(covertLngLat(lngBytes)); + byte[] lngBytes = new byte[4]; + System.arraycopy(bytes, 5, lngBytes, 0, 4); + robot.setLng(covertLngLat(lngBytes)); - byte[] latBytes = new byte[4]; - System.arraycopy(bytes, 9, latBytes, 0, 4); - robot.setLat(covertLngLat(latBytes)); + byte[] latBytes = new byte[4]; + System.arraycopy(bytes, 9, latBytes, 0, 4); + robot.setLat(covertLngLat(latBytes)); - robot.setNavigateState(covertState(bytes[13])); - robot.setInstrumentV((float) (ByteUtils.byteToUnsigned(bytes[14]) * 0.1)); - robot.setPowerV((float) ByteUtils.byteToUnsigned(bytes[15])); - robot.setInstrumentE((float) ByteUtils.byteToUnsigned(bytes[16])); - robot.setPowerE((float) ByteUtils.byteToUnsigned(bytes[17])); + robot.setNavigateState(covertState(bytes[13])); + robot.setInstrumentV((float) (ByteUtils.byteToUnsigned(bytes[14]) * 0.1)); + robot.setPowerV((float) ByteUtils.byteToUnsigned(bytes[15])); + robot.setInstrumentE((float) ByteUtils.byteToUnsigned(bytes[16])); + robot.setPowerE((float) ByteUtils.byteToUnsigned(bytes[17])); - byte[] pitchAngleBytes = new byte[2]; - System.arraycopy(bytes, 18, pitchAngleBytes, 0, 2); - robot.setPitchAngle(covertPitchAngle(pitchAngleBytes)); + byte[] pitchAngleBytes = new byte[2]; + System.arraycopy(bytes, 18, pitchAngleBytes, 0, 2); + robot.setPitchAngle(covertPitchAngle(pitchAngleBytes)); - byte[] rollAngleBytes = new byte[2]; - System.arraycopy(bytes, 20, rollAngleBytes, 0, 2); - robot.setRollAngle(covertRollAngle(rollAngleBytes)); + byte[] rollAngleBytes = new byte[2]; + System.arraycopy(bytes, 20, rollAngleBytes, 0, 2); + robot.setRollAngle(covertRollAngle(rollAngleBytes)); - byte[] headingAngleBytes = new byte[2]; - System.arraycopy(bytes, 22, headingAngleBytes, 0, 2); - robot.setHeadingAngle(covertHeadingAngle(headingAngleBytes)); + byte[] headingAngleBytes = new byte[2]; + System.arraycopy(bytes, 22, headingAngleBytes, 0, 2); + robot.setHeadingAngle(covertHeadingAngle(headingAngleBytes)); - byte[] buoyancyBytes = new byte[2]; - System.arraycopy(bytes, 24, buoyancyBytes, 0, 2); - robot.setBuoyancy(covertBuoyancy(buoyancyBytes)); + byte[] buoyancyBytes = new byte[2]; + System.arraycopy(bytes, 24, buoyancyBytes, 0, 2); + robot.setBuoyancy(covertBuoyancy(buoyancyBytes)); - byte[] positionBytes = new byte[2]; - System.arraycopy(bytes, 26, positionBytes, 0, 2); - //滑块位置算法和浮力算法一样 - robot.setPosition(covertBuoyancy(positionBytes)); + byte[] positionBytes = new byte[2]; + System.arraycopy(bytes, 26, positionBytes, 0, 2); + //滑块位置算法和浮力算法一样 + robot.setPosition(covertBuoyancy(positionBytes)); - int status = bytes[28]; - if (status == 0) { - robot.setDetectStatus("没有目标"); - } else { - robot.setDetectStatus("发现目标"); + int status = bytes[28]; + if (status == 0) { + robot.setDetectStatus("没有目标"); + } else { + robot.setDetectStatus("发现目标"); + } + + byte[] targetDisBytes = new byte[2]; + System.arraycopy(bytes, 29, targetDisBytes, 0, 2); + robot.setTargetDistance(covertTargetDistance(targetDisBytes)); + + byte[] targetDirBytes = new byte[2]; + System.arraycopy(bytes, 31, targetDirBytes, 0, 2); + //目标方位算法和航向角算法一样 + robot.setTargetDirection(covertHeadingAngle(targetDirBytes)); + + byte[] targetHzBytes = new byte[2]; + System.arraycopy(bytes, 33, targetHzBytes, 0, 2); + robot.setTargetHertz(covertTargetHertz(targetHzBytes)); + } catch (IndexOutOfBoundsException e) { + e.printStackTrace(); } - - byte[] targetDisBytes = new byte[2]; - System.arraycopy(bytes, 29, targetDisBytes, 0, 2); - robot.setTargetDistance(covertTargetDistance(targetDisBytes)); - - byte[] targetDirBytes = new byte[2]; - System.arraycopy(bytes, 31, targetDirBytes, 0, 2); - //目标方位算法和航向角算法一样 - robot.setTargetDirection(covertHeadingAngle(targetDirBytes)); - - byte[] targetHzBytes = new byte[2]; - System.arraycopy(bytes, 33, targetHzBytes, 0, 2); - robot.setTargetHertz(covertTargetHertz(targetHzBytes)); return robot; } @@ -124,44 +128,48 @@ */ public static String decodeRobotRegion(byte[] bytes) { Map regionMap = new HashMap<>(7); - int count = bytes[5]; - regionMap.put("count", count); + try { + int count = bytes[5]; + regionMap.put("count", count); - byte[] idsBytes = new byte[count]; - System.arraycopy(bytes, 6, idsBytes, 0, count); - StringBuilder builder = new StringBuilder(); - for (int i = 0; i < idsBytes.length; i++) { - if (i != idsBytes.length - 1) { - builder.append(idsBytes[i]).append(","); - } else { - builder.append(idsBytes[i]); + byte[] idsBytes = new byte[count]; + System.arraycopy(bytes, 6, idsBytes, 0, count); + StringBuilder builder = new StringBuilder(); + for (int i = 0; i < idsBytes.length; i++) { + if (i != idsBytes.length - 1) { + builder.append(idsBytes[i]).append(","); + } else { + builder.append(idsBytes[i]); + } } + regionMap.put("robotIds", builder.toString()); + + //经度(4)、纬度(4) + int targetSize = count * (4 + 4); + byte[] targetBytes = new byte[targetSize]; + //起始5个字节,机器人个数1个字节 + System.arraycopy(bytes, 5 + 1 + idsBytes.length, targetBytes, 0, targetBytes.length); + regionMap.put("robotTargets", formatLngLat(targetBytes)); + + int pointCount = bytes[5 + 1 + idsBytes.length + targetBytes.length]; + regionMap.put("pointCount", pointCount); + + byte[] radiusBytes = new byte[2]; + System.arraycopy(bytes, 5 + 1 + idsBytes.length + targetBytes.length + 1, radiusBytes, 0, radiusBytes.length); + regionMap.put("regionRadius", covertTargetDistance(radiusBytes)); + + regionMap.put("contour", bytes[5 + 1 + idsBytes.length + targetBytes.length + 1 + radiusBytes.length]); + + //经度(4)、纬度(4) + int regionSize = pointCount * (4 + 4); + byte[] regionBytes = new byte[regionSize]; + System.arraycopy(bytes, + 5 + 1 + idsBytes.length + targetBytes.length + 1 + radiusBytes.length + 1, + regionBytes, 0, regionBytes.length); + regionMap.put("regionPoints", formatLngLat(regionBytes)); + } catch (IndexOutOfBoundsException e) { + e.printStackTrace(); } - regionMap.put("robotIds", builder.toString()); - - //经度(4)、纬度(4) - int targetSize = count * (4 + 4); - byte[] targetBytes = new byte[targetSize]; - //起始5个字节,机器人个数1个字节 - System.arraycopy(bytes, 5 + 1 + idsBytes.length, targetBytes, 0, targetBytes.length); - regionMap.put("robotTargets", formatLngLat(targetBytes)); - - int pointCount = bytes[5 + 1 + idsBytes.length + targetBytes.length]; - regionMap.put("pointCount", pointCount); - - byte[] radiusBytes = new byte[2]; - System.arraycopy(bytes, 5 + 1 + idsBytes.length + targetBytes.length + 1, radiusBytes, 0, radiusBytes.length); - regionMap.put("regionRadius", covertTargetDistance(radiusBytes)); - - regionMap.put("contour", bytes[5 + 1 + idsBytes.length + targetBytes.length + 1 + radiusBytes.length]); - - //经度(4)、纬度(4) - int regionSize = pointCount * (4 + 4); - byte[] regionBytes = new byte[regionSize]; - System.arraycopy(bytes, - 5 + 1 + idsBytes.length + targetBytes.length + 1 + radiusBytes.length + 1, - regionBytes, 0, regionBytes.length); - regionMap.put("regionPoints", formatLngLat(regionBytes)); return JSON.toJSONString(regionMap); } @@ -170,35 +178,38 @@ */ public static String decodeRobotRoute(byte[] bytes) { Map routeMap = new HashMap<>(5); + try { + byte[] countBytes = new byte[2]; + System.arraycopy(bytes, 5, countBytes, 0, 2); + int count = covertToDec(countBytes); + routeMap.put("routeCount", covertToDec(countBytes)); - byte[] countBytes = new byte[2]; - System.arraycopy(bytes, 5, countBytes, 0, 2); - int count = covertToDec(countBytes); - routeMap.put("routeCount", covertToDec(countBytes)); + //经度(4)、纬度(4)、深度(2)、俯仰角(2)、航向角(2) + int routeSize = count * (4 + 4 + 2 + 2 + 2); + byte[] routeBytes = new byte[routeSize]; + System.arraycopy(bytes, 5 + countBytes.length, routeBytes, 0, routeSize); + routeMap.put("robotRoutes", formatRoute(routeBytes)); - //经度(4)、纬度(4)、深度(2)、俯仰角(2)、航向角(2) - int routeSize = count * (4 + 4 + 2 + 2 + 2); - byte[] routeBytes = new byte[routeSize]; - System.arraycopy(bytes, 5 + countBytes.length, routeBytes, 0, routeSize); - routeMap.put("robotRoutes", formatRoute(routeBytes)); + byte[] sumTimeBytes = new byte[2]; + System.arraycopy(bytes, + 5 + countBytes.length + routeBytes.length, + sumTimeBytes, 0, 2); + routeMap.put("sumTime", covertToDec(sumTimeBytes)); - byte[] sumTimeBytes = new byte[2]; - System.arraycopy(bytes, - 5 + countBytes.length + routeBytes.length, - sumTimeBytes, 0, 2); - routeMap.put("sumTime", covertToDec(sumTimeBytes)); + byte[] sumDistanceBytes = new byte[2]; + System.arraycopy(bytes, + 5 + countBytes.length + routeBytes.length + sumTimeBytes.length, + sumDistanceBytes, 0, 2); + routeMap.put("sumDistance", covertToDec(sumDistanceBytes)); - byte[] sumDistanceBytes = new byte[2]; - System.arraycopy(bytes, - 5 + countBytes.length + routeBytes.length + sumTimeBytes.length, - sumDistanceBytes, 0, 2); - routeMap.put("sumDistance", covertToDec(sumDistanceBytes)); - - byte[] sumPowerBytes = new byte[2]; - System.arraycopy(bytes, - 5 + countBytes.length + routeBytes.length + sumTimeBytes.length + sumDistanceBytes.length, - sumPowerBytes, 0, 2); - routeMap.put("sumPower", covertToDec(sumPowerBytes)); + byte[] sumPowerBytes = new byte[2]; + System.arraycopy(bytes, + 5 + countBytes.length + routeBytes.length + sumTimeBytes.length + sumDistanceBytes.length, + sumPowerBytes, 0, 2); + routeMap.put("sumPower", covertToDec(sumPowerBytes)); + } catch (IndexOutOfBoundsException e) { + e.printStackTrace(); + } return JSON.toJSONString(routeMap); } @@ -208,20 +219,24 @@ */ public static String decodeDirectedTask(byte[] bytes) { Map taskMap = new HashMap<>(2); - byte[] depthBytes = new byte[2]; - System.arraycopy(bytes, 5, depthBytes, 0, 2); - taskMap.put("taskDepth", covertDepth(depthBytes)); + try { + byte[] depthBytes = new byte[2]; + System.arraycopy(bytes, 5, depthBytes, 0, 2); + taskMap.put("taskDepth", covertDepth(depthBytes)); - int directCount = bytes[7]; - taskMap.put("directCount", directCount); + int directCount = bytes[7]; + taskMap.put("directCount", directCount); - List angleList = new ArrayList<>(); - for (int i = 0; i < directCount * 2; i += 2) { - byte[] angleBytes = new byte[2]; - System.arraycopy(bytes, i + 8, angleBytes, 0, 2); - angleList.add(covertHeadingAngle(angleBytes)); + List angleList = new ArrayList<>(); + for (int i = 0; i < directCount * 2; i += 2) { + byte[] angleBytes = new byte[2]; + System.arraycopy(bytes, i + 8, angleBytes, 0, 2); + angleList.add(covertHeadingAngle(angleBytes)); + } + taskMap.put("headingAngle", angleList); + } catch (IndexOutOfBoundsException e) { + e.printStackTrace(); } - taskMap.put("headingAngle", angleList); return JSON.toJSONString(taskMap); } @@ -240,19 +255,22 @@ */ public static String decodeTaskRoute(byte[] bytes) { Map taskMap = new HashMap<>(3); + try { + byte[] depthBytes = new byte[2]; + System.arraycopy(bytes, 5, depthBytes, 0, 2); + taskMap.put("taskDepth", covertDepth(depthBytes)); - byte[] depthBytes = new byte[2]; - System.arraycopy(bytes, 5, depthBytes, 0, 2); - taskMap.put("taskDepth", covertDepth(depthBytes)); + int count = bytes[7]; + taskMap.put("routeCount", count); - int count = bytes[7]; - taskMap.put("routeCount", count); - - //经度(4)、纬度(4) - int routeSize = count * (4 + 4); - byte[] routeBytes = new byte[routeSize]; - System.arraycopy(bytes, 8, routeBytes, 0, routeSize); - taskMap.put("robotRoutes", formatLngLat(routeBytes)); + //经度(4)、纬度(4) + int routeSize = count * (4 + 4); + byte[] routeBytes = new byte[routeSize]; + System.arraycopy(bytes, 8, routeBytes, 0, routeSize); + taskMap.put("robotRoutes", formatLngLat(routeBytes)); + } catch (IndexOutOfBoundsException e) { + e.printStackTrace(); + } return JSON.toJSONString(taskMap); } @@ -261,17 +279,21 @@ */ public static String decodeDirectFlightTask(byte[] bytes) { Map taskMap = new HashMap<>(3); - byte[] depthBytes = new byte[2]; - System.arraycopy(bytes, 5, depthBytes, 0, 2); - taskMap.put("taskDepth", covertDepth(depthBytes)); + try { + byte[] depthBytes = new byte[2]; + System.arraycopy(bytes, 5, depthBytes, 0, 2); + taskMap.put("taskDepth", covertDepth(depthBytes)); - byte[] angleBytes = new byte[2]; - System.arraycopy(bytes, 7, angleBytes, 0, 2); - taskMap.put("headingAngle", covertHeadingAngle(angleBytes)); + byte[] angleBytes = new byte[2]; + System.arraycopy(bytes, 7, angleBytes, 0, 2); + taskMap.put("headingAngle", covertHeadingAngle(angleBytes)); - byte[] timesBytes = new byte[2]; - System.arraycopy(bytes, 9, timesBytes, 0, 2); - taskMap.put("duration", covertToDec(timesBytes)); + byte[] timesBytes = new byte[2]; + System.arraycopy(bytes, 9, timesBytes, 0, 2); + taskMap.put("duration", covertToDec(timesBytes)); + } catch (IndexOutOfBoundsException e) { + e.printStackTrace(); + } return JSON.toJSONString(taskMap); } @@ -280,21 +302,25 @@ */ public static String decodeResideTask(byte[] bytes) { Map taskMap = new HashMap<>(4); - byte[] lngBytes = new byte[4]; - System.arraycopy(bytes, 5, lngBytes, 0, 4); - taskMap.put("lng", covertLngLat(lngBytes)); + try { + byte[] lngBytes = new byte[4]; + System.arraycopy(bytes, 5, lngBytes, 0, 4); + taskMap.put("lng", covertLngLat(lngBytes)); - byte[] latBytes = new byte[4]; - System.arraycopy(bytes, 9, latBytes, 0, 4); - taskMap.put("lat", covertLngLat(latBytes)); + byte[] latBytes = new byte[4]; + System.arraycopy(bytes, 9, latBytes, 0, 4); + taskMap.put("lat", covertLngLat(latBytes)); - byte[] angleBytes = new byte[2]; - System.arraycopy(bytes, 13, angleBytes, 0, 2); - taskMap.put("depth", covertDepth(angleBytes)); + byte[] angleBytes = new byte[2]; + System.arraycopy(bytes, 13, angleBytes, 0, 2); + taskMap.put("depth", covertDepth(angleBytes)); - byte[] timesBytes = new byte[2]; - System.arraycopy(bytes, 15, timesBytes, 0, 2); - taskMap.put("duration", covertToDec(timesBytes)); + byte[] timesBytes = new byte[2]; + System.arraycopy(bytes, 15, timesBytes, 0, 2); + taskMap.put("duration", covertToDec(timesBytes)); + } catch (IndexOutOfBoundsException e) { + e.printStackTrace(); + } return JSON.toJSONString(taskMap); } @@ -303,28 +329,32 @@ */ public static String decodePutTask(byte[] bytes) { Map taskMap = new HashMap<>(4); - byte[] lngBytes = new byte[4]; - System.arraycopy(bytes, 5, lngBytes, 0, 4); - taskMap.put("lng", covertLngLat(lngBytes)); + try { + byte[] lngBytes = new byte[4]; + System.arraycopy(bytes, 5, lngBytes, 0, 4); + taskMap.put("lng", covertLngLat(lngBytes)); - byte[] latBytes = new byte[4]; - System.arraycopy(bytes, 9, latBytes, 0, 4); - taskMap.put("lat", covertLngLat(latBytes)); + byte[] latBytes = new byte[4]; + System.arraycopy(bytes, 9, latBytes, 0, 4); + taskMap.put("lat", covertLngLat(latBytes)); - int count = bytes[13]; - taskMap.put("count", count); + int count = bytes[13]; + taskMap.put("count", count); - byte[] idsBytes = new byte[count]; - System.arraycopy(bytes, 14, idsBytes, 0, count); - StringBuilder builder = new StringBuilder(); - for (int i = 0; i < idsBytes.length; i++) { - if (i != idsBytes.length - 1) { - builder.append(idsBytes[i]).append(","); - } else { - builder.append(idsBytes[i]); + byte[] idsBytes = new byte[count]; + System.arraycopy(bytes, 14, idsBytes, 0, count); + StringBuilder builder = new StringBuilder(); + for (int i = 0; i < idsBytes.length; i++) { + if (i != idsBytes.length - 1) { + builder.append(idsBytes[i]).append(","); + } else { + builder.append(idsBytes[i]); + } } + taskMap.put("ids", builder.toString()); + } catch (IndexOutOfBoundsException e) { + e.printStackTrace(); } - taskMap.put("ids", builder.toString()); return JSON.toJSONString(taskMap); } @@ -332,14 +362,18 @@ * 短信内容 */ public static String decodeSMS(byte[] bytes) { - //帧头、帧长度、帧类型、子类型、机器人ID,CRC16校验码、帧尾总长度=8 - int dataLen = bytes.length - 8; - - byte[] dataBytes = new byte[dataLen]; - System.arraycopy(bytes, 5, dataBytes, 0, dataLen); StringBuilder builder = new StringBuilder(); - for (int dataByte : dataBytes) { - builder.append((char) dataByte); + try { + //帧头、帧长度、帧类型、子类型、机器人ID,CRC16校验码、帧尾总长度=8 + int dataLen = bytes.length - 8; + + byte[] dataBytes = new byte[dataLen]; + System.arraycopy(bytes, 5, dataBytes, 0, dataLen); + for (int dataByte : dataBytes) { + builder.append((char) dataByte); + } + } catch (IndexOutOfBoundsException e) { + e.printStackTrace(); } return builder.toString(); } @@ -349,22 +383,25 @@ */ public static String decodeEnvRequest(byte[] bytes) { Map envMap = new HashMap<>(4); - if (bytes[5] <= 0) { - envMap.put("hour", "0"); + try { + if (bytes[5] <= 0) { + envMap.put("hour", "0"); + } + if (bytes[5] >= 24) { + envMap.put("hour", "24"); + } + envMap.put("hour", String.valueOf(bytes[5])); + + byte[] lngBytes = new byte[4]; + System.arraycopy(bytes, 5 + 1, lngBytes, 0, 4); + envMap.put("lng", covertLngLat(lngBytes)); + + byte[] latBytes = new byte[4]; + System.arraycopy(bytes, 5 + 1 + lngBytes.length, latBytes, 0, 4); + envMap.put("lat", covertLngLat(latBytes)); + } catch (IndexOutOfBoundsException e) { + e.printStackTrace(); } - if (bytes[5] >= 24) { - envMap.put("hour", "24"); - } - envMap.put("hour", String.valueOf(bytes[5])); - - byte[] lngBytes = new byte[4]; - System.arraycopy(bytes, 5 + 1, lngBytes, 0, 4); - envMap.put("lng", covertLngLat(lngBytes)); - - byte[] latBytes = new byte[4]; - System.arraycopy(bytes, 5 + 1 + lngBytes.length, latBytes, 0, 4); - envMap.put("lat", covertLngLat(latBytes)); - return JSON.toJSONString(envMap); } @@ -373,17 +410,21 @@ */ public static String decodeAISRequest(byte[] bytes) { Map aisMap = new HashMap<>(4); - aisMap.put("radius", bytes[5]); + try { + aisMap.put("radius", bytes[5]); - byte[] lngBytes = new byte[4]; - System.arraycopy(bytes, 5 + 1, lngBytes, 0, 4); - aisMap.put("lng", covertLngLat(lngBytes)); + byte[] lngBytes = new byte[4]; + System.arraycopy(bytes, 5 + 1, lngBytes, 0, 4); + aisMap.put("lng", covertLngLat(lngBytes)); - byte[] latBytes = new byte[4]; - System.arraycopy(bytes, 5 + 1 + lngBytes.length, latBytes, 0, 4); - aisMap.put("lat", covertLngLat(latBytes)); + byte[] latBytes = new byte[4]; + System.arraycopy(bytes, 5 + 1 + lngBytes.length, latBytes, 0, 4); + aisMap.put("lat", covertLngLat(latBytes)); - aisMap.put("age", bytes[5 + 1 + lngBytes.length + latBytes.length]); + aisMap.put("age", bytes[5 + 1 + lngBytes.length + latBytes.length]); + } catch (IndexOutOfBoundsException e) { + e.printStackTrace(); + } return JSON.toJSONString(aisMap); } @@ -394,15 +435,19 @@ */ public static ShelterPosition decodeShelterPosition(byte[] bytes) { ShelterPosition shelter = new ShelterPosition(); - byte[] lngBytes = new byte[4]; - System.arraycopy(bytes, 5, lngBytes, 0, 4); - shelter.setLng(covertLngLat(lngBytes)); + try { + byte[] lngBytes = new byte[4]; + System.arraycopy(bytes, 5, lngBytes, 0, 4); + shelter.setLng(covertLngLat(lngBytes)); - byte[] latBytes = new byte[4]; - System.arraycopy(bytes, 9, latBytes, 0, 4); - shelter.setLat(covertLngLat(latBytes)); + byte[] latBytes = new byte[4]; + System.arraycopy(bytes, 9, latBytes, 0, 4); + shelter.setLat(covertLngLat(latBytes)); - shelter.setCreateTime(TimeUtil.getCurrentTime()); + shelter.setCreateTime(TimeUtil.getCurrentTime()); + } catch (IndexOutOfBoundsException e) { + e.printStackTrace(); + } return shelter; }