<html> <pre> //CIS 757 / 790 L.A.T.T.C PROF. AUCIELLO // mondarian /* TOPICS: 1. Testing and setting colors. */ import java.awt.Graphics; import java.awt.Font; import java.awt.Color; import java.lang.Math; import java.util.Date; import java.util.Random; import java.util.*; import java.awt.*; import corejava.*; public class acolor2 extends java.applet.Applet { Font f = new Font("TimesRoman", Font.ITALIC, 24); public void paint(Graphics g) { int rval, gval, bval, x=0, ver=0, hor=0; String graphchar = "\u00df"; Random r=new Random(); while (x < 10000) {hor = Math.abs(r.nextInt()%400+1); ver = Math.abs(r.nextInt()%400+1); rval = Math.abs(r.nextInt()%254+1); rval = Math.abs(rval); System.out.println("rval = "+ rval); gval = Math.abs(r.nextInt()%254+1); bval = Math.abs(r.nextInt()%254+1); g.setFont(f); g.setColor(new Color(rval,gval,bval)); // get random color. g.drawString(graphchar,hor,ver); } } } /* ACTIVITIES: LOOK UP UNICODE ON WEB. WHAT DOES "\u00df" PRODUCE? WRITE THE INITIAL OF YOUR LAST NAME IN UNICODE. LOOK UP MONDARIAN. WHY IS THIS PROGRAM LIKE MONDARIAN'S ART? VARY THE SIZE OF THE FONT. VARY SIZE OF CANVAS AREA. (CHECK INSIDE OF ACOLOR2.HTM) VARY RANGE OF INTEGERS FOR COLORS (255 = MAX) HOW MANY COLOR COMBINATIONS ARE THERE? 256 * 256 * 256 = ? HARD QUESTION: WHERE DO THE RANDOM NUMBERS COME FROM? WHAT IS THE SIGNIFICANCE OF Random r STATEMENT? WHAT DOES r.nextInt() DO? WHY DID I HAVE TO USE Math.abs? WHERE IS THE FONT SET? WHERE IS THE COLOR SET? WHERE IS THE PRINTING ON THE CANVAS? WHAT IS THE SIGNIFICANCE OF system.out.println ? MODIFY IT TO DISPLAY THE VALUES OF THE PROGRAM VARIABLES. HOW CAN I CHANGE THE LOOP SO IT BECOMES INFINITE? This is a special assignment meant to strengthen your programming skills. Take this program apart, line by line, test it, experiment with it. Show what you know. You are expected to follow a pattern of Plan-Do-Check-Act-Verify (repeatedly) and apply Continous Quality Improvement and Innovation [CQII] to this applet, then adapt those work paradigms to all of your computer work. JA. */ </pre> <html>