teaching machines

CS 145 Lecture 7 – Random and Naming Our Code

September 17, 2014 by . Filed under cs145, fall 2014, lectures.

Agenda

TODO

Code

Circle.java

package lecture0917;

import java.util.Random;

public class Circle {
  public static void main(String[] args) {
    Random generator = new Random();

    System.out.println("<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\">");
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);
    printCircle(generator);

    System.out.println("</svg>");
  }
  
  public static void printCircle(Random g) {
    int cx = g.nextInt(1000);
    int cy = g.nextInt(600);
    int r = g.nextInt(23) + 1;
    int red = g.nextInt(256);
    int green = g.nextInt(256);
    int blue = g.nextInt(256);
    System.out.printf("<circle cx=\"%d\" cy=\"%d\" r=\"%d\" stroke=\"black\" stroke-width=\"2\" fill=\"rgb(%d, %d, %d)\" />%n",
                      cx, cy, r, red, green, blue);
  }
}

Haiku

on roboflowers.com:
Happy birthday, #NAME!
Love you forever + 1,
#CUSTOMERID