teaching machines

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 Lab 9

Reminder Show your completed lab 8 checkpoints to your TA or instructor in the first 20 minutes of this lab. Checkpoint 1 One of the steps to mastery of a subject is to formulate your own questions. So, for your first checkpoint, please write three questions, one on each of the following topics: logical operators […]

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 […]

CS 145 Preassignment 3 – due before 11/16

See the PDF. When you download speccheck_pre3.jar, make sure the filename ends in “.jar”.

CS 145 Lab 8

Reminder Show your instructor or TA your already completed checkpoints from lab 7 in the first 20 minutes of this lab. Arrays As discussed in class and in your textbook, arrays are simply number collections of data. We can have arrays of primitives and we can have arrays of objects. Making an array looks similar […]

CS 145 Lecture 16 – Arrays

Agenda named data vs. numbered data arrays mapping month numbers to names the birthday problem Code Birthdays Birthdayarator.java package lecture; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Birthdayarator { public static void main(String[] args) throws FileNotFoundException { Scanner in = new Scanner(new File(“/home/cjohnson/Desktop/bdays.txt”)); String[] names = new String[12]; names[0] = “January”; names[1] = “February”; […]

1 196 197 198 199 200 204