Java+Lab+2

Lab 2: Methods
Download the zip file above. Extract the files, then open the folder in DrJava. All the code you write for this assignment should be written in this folder. The purpose of this lab is to test how well you can break down complex problems into short and meaningful methods. As much as possible, you should aim to **minimize duplicate instruction sequences by declaring appropriate well-named methods.**As a rough guideline, each method you declare should typically contain fewer than 10 statements. For each additional method that you declare, include before/after comments.

Exercise 1: cleanSquare
In this exercise, the robot initially finds itself in the following situation: Complete the method, so that it makes all the dark cells light. After runs, the world should appear as follows (with the robot in any position, facing any direction): Be sure to break the problem down into appropriate and well-named helper methods.

Exercise 2: darkenComb
In this exercise, the robot finds itself in the following comb-shaped world: Complete the method, so that it makes all the cells dark. After runs, the world should appear as follows (with the robot in any position, facing any direction): Be sure to break the problem down into appropriate and well-named helper methods.

Exercise 3: makeCheckered
In this exercise, the robot finds itself in the following empty world: Complete the method, so that it darkens half the cells to form the checkerboard pattern shown here (leaving the robot in any position, facing any direction): Be sure to break the problem down into appropriate and well-named helper methods.

Challenge
Create a robot world .txt file that contains a large rectangular region of light-colored cells. Create a file called Clock.java. In it, declare a method called, which should darken some of the cells so as to look like the time on a digital clock. For example, you might display the time 10:59 as follows: However, your code must be written in such a way so that it can show //any// time on a 12-hour digital clock. And, by changing only the code in the method itself, you should be able to re-program your method to show any time //in less than 10 seconds//.