CIS068 / 2
Lab Assignment #1
Friday, 1/31/2003
1. Modify the program Colortest.java in the following ways:
- [2 POINTS]
Size the array as 8 x 8 fields. Instead of using red and blue define all fields as increasing GRAYVALUES from black to white in the usual reading order (from upper left to lower right).
Different GRAYVALUES are achieved by setting the red, green and blue values to the same amount. Allowed are integer values between [0..255].
- [3 POINTS]
Don’t’t show a rectangle, but a triangle, i.e.: the first row only shows 1, the second 2, the 3rd 3 (a.s.o.)grayvalue-fields. Set the remaining fields to blue (red = 0, green = 0, blue = 255).
- [2 POINTS]
Pass the size of the array as arguments of main, e.g. a 7x7 array is created by calling the program as ‘java CIS068Colortest 7 7’.
Hint: an integer- number n given as a String s is converted to int by: int n = (new Integer(s)).intValue() .
Make sure that only numbers between [1..32] are possible as input.
- [3 POINTS]
Write a new class named ‘ColortestRealTriangle’ by copying your CIS068Colortest (watch out: filename and classname must match in Java !). Then modify the array-structure to a triangle, i.e. the first row contains only one column, the 2nd two … the 8th eight columns. This triangle should show exactly the grayvalues of part b), dropping the blue fields.
In this part you will also have to modify the paint – method ! To cope with this, you only have to understand the nested ‘for’ – loop in there.
Total: 10 Points
The result, i.e. the Java-sources of Colortest.java and ColortestRealTriangle.java must be WELL DOCUMENTED !
Please mail the result to the following address:
c068200@Lucas.cis.temple.edu
which is the mail address of your TA (Venu Raja) for this course.
Assignment must be finished by Friday, 2/7/2003, 12:00 am.
The unmodified program Colortest.java can be downloaded (...rightclick...) from
HERE