CS 145 Lecture 22 – Designing objects
Agenda writing a Stopwatch objects hide information managing a “dungeon” with objects writing a flashlight Code Stopwatch.java package lecture; public class Stopwatch { /** Time at which stopwatch is started */ private long startTime; /** Time at which stopwatch is stopped */ private long stopTime; /** * Starts stopwatch. */ public void start() { startTime […]
CS 491 Lecture 21 – Bluecheckers
Agenda explore GLSurfaceView hook GLSurfaceView.Renderer callbacks up to our C++ renderer incorporate UI events 3-D on Android Android offers a special GLSurfaceView for fast rendering. It also provides Java bindings for the OpenGL library. This added layer can reduce performance, so ultimately we’re going to want to use our low-level C++ code to do all […]
CS 491 Lecture 20 – OpenGL ES
Agenda discuss the OpenGL framework develop 3-D on the desktop in C++ migrate C++ to our Android device using JNI get a lit sphere running on a mobile device OpenGL ES It comes time in everyone’s life for a little 3-D. The process of taking 3-D objects and showing them on a 2-D screen is […]
CS 145 Lecture 21 – Our own objects
Agenda command-line arguments writing an NDeckerBurger class writing a class: Figure out what it needs to do. (Methods.) Figure out what its persistent state is. (Instance variables.) Figure out how to initialize the state. (Constructor.) midterm 2 Code CommandLineArguments.java package lecture; public class CommandLineArguments { public static void main(String[] args) { // for (int i […]
CS 145 Lecture 20 – Midterm 2 Review
Things to know The test is hand-written. You may write SOP instead of System.out.println. You need not import any classes. One page of handwritten notes is allowed. The front page of the exam will contain compact documentation for the Scanner, Random, and String classes. A strategy: on questions where you are asked to write a […]
CS 145 Lecture 19 – 2-D arrays
Agenda What does this do? Code Imager.java package lecture; import java.awt.Color; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.Random; import javax.imageio.ImageIO; public class Imager { public static void main(String[] args) throws IOException { int width = 512; int height = 256; int[][] pixels = new int[height][width]; // noisify(pixels); stripes(pixels); writeToFile(pixels); } private static void noisify(int[][] […]
CS 145 Lecture 18 – Searching arrays
Agenda linear search the truth behind objects: references stack vs. heap null Code States.java package lecture; import java.util.Scanner; public class States { private static String[] states = { “Alabama”, “Alaska”, “Arizona”, “Arkansas”, “California”, “Colorado”, “Connecticut”, “Delaware”, “Florida”, “Georgia”, “Hawaii”, “Idaho”, “Illinois”, “Indiana”, “Iowa”, “Kansas”, “Kentucky”, “Louisiana”, “Maine”, “Maryland”, “Massachusetts”, “Michigan”, “Minnesota”, “Mississippi”, “Missouri”, “Montana”, “Nebraska”, […]
CS 491 Lecture 19 – Smile and Wave
Agenda mixing widgets and SurfaceView write a custom camera app enhancing the camera preview Mixing widgets and SurfaceView An unfortunate consequence of switching to a SurfaceView is that our gestures no longer get recognized. GestureOverlayView and SurfaceView do not play well together. No documentation I can find details their incompatibility, but gesture recognition simply doesn’t […]
CS 491 Lecture 18 – Falling Math Part II
Agenda implement gestures continuous rendering SurfaceView Expression Before we dig any deeper, let’s push our expression code out to a class. I’ve provided most of it: But these problems remain: Randomly generate an expression that evaluates to a single digit. Allow it to fall delta seconds, acted upon by gravity. Gestures In Android 1.6, gestures […]
CS 145 Lecture 17 – Arrays
Agenda arrays in life writing a fill method writing a raffle state/capital lookup Code Fill.java package lecture; public class Fill { public static void main(String[] args) { double[] series = fill(12, 54, 10); for (int i = 0; i < series.length; ++i) { System.out.println(series[i]); } } /** * Create a list of length items, whose […]