teaching machines

CS 145 Lecture 4

September 19, 2011 by . Filed under cs145, fall 2011, lectures.

Agenda

Code

Placemarker.java

package lecture;

import java.util.Scanner;

public class Placemarker {
  public static void main(String[] args) {
    System.out.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
    System.out.println("<kml xmlns=\"http://www.opengis.net/kml/2.2\">");
    System.out.println("<Document>");
    System.out.println("<Style id=\"seethrough\"><PolyStyle><color>7fffffff</color></PolyStyle></Style>");

    handlePlacemark();
    handlePlacemark();
    handlePlacemark();
    
    System.out.println("</Document>");
    System.out.println("</kml>");
  }
  
  public static void handlePlacemark() {
    Scanner in = new Scanner(System.in);

    System.out.print("Name: ");
    String name = in.nextLine();
    System.out.print("Description: ");
    String description = in.nextLine();
    System.out.print("Lon lat: ");
    double lon = in.nextDouble();
    double lat = in.nextDouble();
    
    System.out.println("<Placemark>");
    System.out.println("<name>" + name + "</name>");
    System.out.println("<description>" + description + "</description>");
    System.out.println(" <Point>");
    System.out.println("<coordinates>" + lon + ", " + lat + "</coordinates>");
    System.out.println("</Point>");
    System.out.println("</Placemark>");
  }
}

GeometryFun.java

package lecture;

public class GeometryFun {

  
  public double getAreaOfCircle(double radius) {
    double area = radius * radius * Math.PI;
    return area;
  }
}

TODO

Haiku

she makes great omelettes
but ev’ryday, Robot Mom?
a method addict