Week 8
Midterm exam!
Intro to Java. Using objects and methods. Input and output.
Downloads:
You can probably download a single bundle of the JDK and NetBeans from the first link.
A simple Java program
// Defines the namespace we're using package simpleprogram; // Our program be defined inside a class public class Main { // This method is run when treating this class as the main program. public static void main(String[] args) { // System is a class that provides useful utilities for programs. // out is the object that provides methods for printing. String message = "This program is boring"; System.out.println(message.toUpperCase()); } }
Using Processing within a standard Java project
After creating a new project in NetBeans, right click on Libraries in the Projects window and choose “Add JAR/Folder…”. Navigate to your Processing installation, and select the file core.jar in the lib folder (core.jar is the main Processing library). With that library available, the following program should compile and run:
package processingtest; import processing.core.*; public class Main extends PApplet { public void setup() { size(500, 500); } public void draw() { if (mousePressed) { line(mouseX, mouseY, pmouseX, pmouseY); } } public static void main(String[] args) { PApplet.main(new String[] {"processingtest.Main"}); } }
Reading
Java for Everyone, chapters 1-3. Much of this is review of concepts we used in Processing.
Homework
All numbered problems are from Java for Everyone. Due Friday, March 18.
- Chapter 1, P1.1, P1.9, P1.15
- Chapter 2, P2.2, P2.3
- Chapter 3, P3.9, P3.15
- Recreate your favorite Processing program in Java.