This project has two parts: Part A and Part B.;Using jGrasp, create a project for Lab 4, and complete the following tasks.;Part A;Create a class called Location with the following specifications;Private int fields x, y and z, initialized to zero.;An empty default constructor.;An overloaded constructor that sets all three field values.;Accessors for all three fields, creating read-only properties.;Public methods changeX, changeY and changeZ with int parameter that increments the appropriate field by the parameter value.;Public method getLocation that returns a String displaying the values of x, y and z in the format of (x, y, z).;Note: This class must ONLY be called and accessed from the Guide class defined below.;Create a class called Guide with the following specifications;Private Location field location.;Six private constant String class variables called UP, DOWN, LEFT, RIGHT, IN, and OUT set to U, D, L, R, I, and O respectively.;A default constructor that creates the location class field object.;Public method move with a String parameter specifying the direction, and that uses the direction value using if..else if statements to check the direction parameter against the class constants UP, DOWN, etc., changing the value of the location x, y or z fields by calling changeX, changeY or changeZ. DOWN, LEFT, and IN would pass -1, while UP, RIGHT and OUT would pass +1. The method should then return the current location as a String.;Public method getLocation that returns a String containing the current location.;Test your classes by creating a Guide object and calling the move method with the following sequence: U, U, U, L, O, O, O, O, O. When completed, display the location.;As an alternative, you may also use the Scanner object to accept keyboard input, using the do..while syntax [Extra Credit - Chapter 5].;Part B;Update the Guide class with the following specifications;Change the move method by replacing the if..else if syntax with a switch statement. Use block comments to comment the if..else if code.;Public method setRandom that returns the current location, with three int parameters: xMax, yMax and zMax. This method will reset the Guide location object to either 0, 0, 0, or to random x, y and z values based on the values of xMax, yMax and zMax. For example, if xMax is 50, your code must select a random number for x between -50 and +50.;Public method getDistance that calculates the distance from a Guide parameter object to the current Guide instance, and returns this distance. If the Guide parameter is null, the distance should be 0. Use the following webpage to determine the mathematical formula, and a calculator to validate your calculations: http://easycalculation.com/analytical/distance3.php.;Test your changes creating a new Guide object, and calling the setRandom method, using values of 5, 10, 15.;Calculate the distance from the new Guide object from the original Guide object (pass the new Guide as a parameter).;Output the distance using the DecimalFormat object, using a format specifier that supports commas to the left of the decimal place, and three decimal places.;Deliverables;Create a single ZIP file that contains your complete jGrasp project folder with the lab assignment. Remember to properly name both your jGrasp project, your Java source files and classes, and the single ZIP file. You must also include a UML diagram of your developed classes, and you must generate and include JavaDocs, which means you MUST comment your code using JavaDoc standards.
Paper#71471 | Written in 18-Jul-2015Price : $82