For this lab assignment, you are to take an image and create a new image that will show multiple instances of the images stacked one on top of another.
The program in Lect1020d.java may be useful in completing this project. This code repeats part of a picture horizontally two times.
For this lab, you must complete the following:
To get the user's input, we will use the getIntNumber() method of the SimpleInput class. The SimpleInput class is one of the classes in the bookCAlasses directory. This method will display a "pop-up" window that will prompt the user to enter an integer value.
The getIntNumber() has two ways it can be used. In either way, it takes a String parameter will be displayed as a message when the user is prompted for the input. That is the only parameter for the first way that getIntNumber() can be used. The other way also takes two more parameter which specify the range the number enter by the user must be in. The following code shows both of these ways.
// declare in integer variable to store the number entered by the user. int value; // prompt the user for the number value = SimpleInput.getIntNumber ("Please enter an integer value."); // display the value entered by the user System.out.println ("The user entered: " + value); // prompt the user for a number within a range of values value = SimpleInput.getIntNumber ("Please enter an integer value between 1 and 10.", 1, 10); // display the value entered by the user System.out.println ("The user entered: " + value); |
For this lab, you can use either form of the getIntNumber() method that you want. If probably makes sense to use second version of the method. The lower number in the range should be one. Values less than one don't really make any sense. (Perhaps the value of zero could make sense, if you wanted to run the program that didn't create any duplicates of the image. But then why run the program at all?) The upper number in the range could be somewhere around 10, because creating more than 10 duplicates would make the final image quite large.
As we copy the images onto the resulting canvas, we must make sure the Y coordinate of the resulting image would equal to the Y coordinate of the original pixel plus (the height of the image multiplied by a value specifying which copy is being created.
Your code should add one more NESTED loop to the code used during lectures: