The objective of this assignment is to develop your


Assignment Objective

The objective of this assignment is to develop your programming and problem solving skills in a step-by-step manner, assisted with visualization.

Visualization helps you to easily identify any problems with your algorithm. Students are expected to devise a strategy before attempting to code any part (trial and error will cause you to go in circles).

Students will be awarded partial marks for explaining a valid strategy, even if the program is not working.

The different stages of this assignment are also designed to gradually introduce different concepts such as loops, arrays, selection, methods and recursion.

Assessment

The assignment is designed to test multiple competencies required for successful software development. Therefore the assessment evaluates all skills required not just the code itself. You will be assessed on your ability to comply with requirements as set out in this document which include developing capabilities in:

1. Programming Style: Adherence to a standard naming convention, documentation of your program and consistency in your style.

2. Refactoring Design and Code: Refining your code making it easier to maintain and understand.

3. Incorporating other Parts of Software Development Lifecycle: Incorporating practices such as test case development covering various configurations and test execution.

4. Algorithm Development: Demonstrate your ability to come up with an efficient strategy. The code should closely resemble your logical solution.

Programming Fundamentals

Progress Marks and Submission

There will be two progress assessment points during the semester each carrying 5 marks. Each assessment will be conducted during your scheduled lab session. You are expected to attend your regular scheduled lab for the progress assessments. Your final submission through WebLearn should include your code, reports and test cases and test results highlighting the number of moves for specific configurations (to be released later).

Assignment Overview ( What you need to do)

Write a program to move the stack of blocks from source to target with specific order and constraints (Some of these constraints will be automatically imposed by the Robot object). Movement of Robot arms, picking and dropping are controlled using the Robot methods described below.

The methods of Robot class:

up(), down(), extend(), contract(), raise(), lower(), pick(), drop(),speedUp(), slowDown()

- The height (h) of the main arm can be changed by 1 unit using methods up() and down(). The height (h) of the this arm must lie in the range 2 to 14, and is initially set to 2.

- The second arm can be moved horizontally by 1 unit using extend() or contract(). The width (w) must lie in the range 1 to 10, and is initially set to 1.

- The depth (d) of the third arm can be changed by 1 unit using lower() or raise(). The depth cannot be less than 0 but must be less than the height of the main arm ( d < h ). In the initial position depth d is set to 0 (it is not visible).

- The target column for all blocks is in column 1 while source is in column 10. The column 9 can be used as a temporary location for parts D and E.

- An item can be picked from the top of the stack of blocks at source using pick().

The Assessment Tasks

The specification for each task is set out below. Note these are requirements B to D are inclusive , i.e., the requirement set for Part D automatically meets all previous requirements from Parts A - C.

Standard Tasks

Part A The height of bars are pre -determined and set at 4.The height of the blocks are predetermined and set at 2.

Part B The user provides the heights of bars at runtime, but values supplied must be in the range 1 - 8.

Part C The user also provides the heights of blocks at runtime, but values supplied must be in the range 1 - 4. In addition the total height of all the blocks cannot exceed 12.

Part D The user can also specify and order in which the blocks should be placed at the destination.

Additional Task

Part E Part E requires you to specify the blocks in descending order of heights at the source. These blocks should be moved to the target with the limitation that a larger block cannot be placed on top of a smaller block.

The following page also provides examples with screenshots to clarify the requirements.

Programming Fundament

Program Screenshots for Parts A to D

Part A: All blocks at source are of size 2 and all bars are of size 4.

Part B: All blocks at source are of height 2 as before but the bar heights may vary.

Part C: Block sizes can be specified in the range 1-4 Bar sizes can be specified in the range 1 to 8. Example Input: java Robot 543623 34121

Part D: This part allows user to specify the bar heights and block heights as well the order in which blocks must be placed in the Target. Example Input: java Robot 23456 2341 1234

Note the required order in the target must be a permutation of the block heights specified.

4 Programming Fundamentals

Part E: This part specifies an additional ordering constraint which prevents a larger block being placed over a smaller block. Example Input: java Robot 543623 43321 ordered

Note this part requires block heights to be in descending order.

Standard Requirements (20 marks in total)

A. Assume all the bars are of height 4 units and the blocks are of height 2 units respectively. Complete the control() method of the RobotControl class to move all the blocks to the respective targets.

(No input needed).

B. Allow the user to supply the heights of the 6 bars as command line arguments where the heights of the bars may vary from 1 to 8.

Complete the control() method of the RobotControl class to move all the blocks to the respective targets.
Sample input (bar heights): 734561. Based on these inputs, int array barHeights[] will be automatically set as in: barHeights[0] = 7; barHeights[1] = 3; .... barHeights[5] = 1;

C. Allow the user to supply the heights of the 6 obstacles as well as the height of the four blocks as command line arguments. Complete the control() method of the RobotControl class to move all the blocks to the respective targets.

Sample Input bar heights and block heights : 876054 2312.

Based on these inputs int arrays barHeights[], blockHeights[]) will be automatically set as in . barHeights[0] = 8; barHeights[1] = 7; .... barHeights[5] = 4;

blockHeights[0] = 2; blockHeights[1] = 3; ... blockHeights[3] = 2;

D. Allow the blocks to be placed in the specified order. The required order will be passed as the array argument required[] which you can make use in the program.

Sample Input bar heights and block heights : 876054 2312 3221 barHeights[0] = 8; barHeights[1] = 7; .... barHeights[5] = 4;

blockHeights[0] = 2; blockHeights[1] = 3; ... blockHeights[3] = 2; required[0] = 3; required[1] = 2; ... required[3] = 1;

Bonus

E. Allow the blocks to be moved such that a block cannot be placed over a smaller block. The block heights input therefore must therefore be in descending order.

The code you need to write to control the Robot moves

For all four sections you are required to complete the control() method of the RobotControl class shown below. The control() method will be automatically called when the program is run. RobotControl class has a reference r set to refer to the Robot object. You are free to make use of other methods of your own.

class RobotControl

{ private Robot r;

public RobotControl(Robot r)

{ this.r = r;

}

public void control(int barHeights[], int blockHeights[],int required[], boolean ordered) { // write your code and comments here

// to control robot using r.up(); r.extend() ...

}

}

You are required to adhere to all standard java coding conventions, which include correct and consistent indentation of code, use of appropriate identifiers for variables and comments describing the main logic program. However, avoid commenting code that is obvious to the reader (for example, x = 5; // assigning 5 to x). You can also make the program structure clearer by subdividing your code into blocks or methods.

Attachment:- Java Assignment.rar

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: The objective of this assignment is to develop your
Reference No:- TGS02269504

Expected delivery within 24 Hours