Question: Complete the SaferRobot.java code according to the comments: import becker.robots.*; public class Safer Robot extends Robot public Safer Robot(City aCity, int Street, int anAvenue, Direction

Complete the SaferRobot.java code according to the comments: import becker.robots.*; public class Safer Robot extends Robot public Safer Robot(City aCity, int Street, int anAvenue, Direction aDirection, int numThings) { super(acity, aStreet, anAvenue, Direction, numThings); } * This moveSafely method moves the robot forward without crashing into * walls and without leaving the default view of the city by never going * past avenue 6. It also returns how many blocks it moved. */ public int moveSafelyo { int blocksMoved - 0; while (frontIsClear()) { this.move(); blocksMoved++; if (this.getAvenuel) 6) { // Do NOT use the "break" keyword } } return blocksMoved; } public static void main(String[] args) { City robotown = new City(); Safer Robot robo = new SaferRobot(robotown, 0, 0, Direction. EAST, 0); int moved = robo.moveSafely(); System.out.println("robo just moved + moved + " blocks."); } 11
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
