CS 145 Lab 10 – Choose-your-own
Reminder Show your completed lab 9 checkpoints to your instructor or TA in the first 20 minutes of this lab. Checkpoint #1 Answering only your professor’s questions only takes you so far. Composing your own is where the money is. Write a checkpoint-type problem for others to solve. Require the development of an object with instance variables, […]
CS 330 Lecture 32 – Scheme, Part II
Agenda why functional? why not functional? reverse engineering finish merge program this double, square, cosine higher-order functions map and filter variable-length argument lists symbolic differentiation TODO http://en.wikipedia.org/wiki/Method_chaining http://www.paulgraham.com/icad.html Reverse Engineering Program This Choose one or both: Write contains, which takes two arguments: a list and an atom. Return true if the list contains the atom. […]
CS 145 Lab 9 – Objects
Prelab Read chapter 8! Reminder Show your completed lab 8 checkpoints to your instructor or TA in the first 20 minutes of this lab. Object-orientation As we’ve seen in lecture, objects are the marriage of data (instance variables, declared at the class level) and methods. Up until now, our programming has been action- or procedure-oriented. We wrote […]
CS 145 Lecture 21 – 2-D arrays, Image
Agenda 2-D arrays (or arrays of arrays) writing an image portable graymap Code Birthday2.java package preexam2; import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; public class Birthday2 { public static void main(String[] args) throws FileNotFoundException { File file = new File(“/home/user/bdays.csv”); Scanner in = new Scanner(file); int[][] counters = new int[12][31]; while (in.hasNextInt()) { int month = […]
CS 145 Lecture 20 – NDeckerBurger, our first object
Agenda objects instance variables constructors methods static vs. instance Code NDeckerBurger.java package prefinal; public class NDeckerBurger { private int nDecks; private boolean hasCheese; public static final int CALORIES_PER_DECK = 211; public NDeckerBurger(int givenDeckCount) { nDecks = givenDeckCount; } public NDeckerBurger(int givenDeckCount, boolean hasCheese) { nDecks = givenDeckCount; this.hasCheese = hasCheese; } public int getDeckCount() { […]
CS 330 Lecture 31 – Hi, Scheme
Agenda Thinking functionally recursion over iteration chaining vs. sequence atoms, lists, and S-expressions Polish notation car, cdr, cons, cond our first functions arithmetic expressions logical expressions factorial lambda list functions length contains nth-element merge remove map filter TODO http://racket-lang.org/ Program This Choose one or both: Write contains, which takes two arguments: a list and an […]
CS 145 Homework 3 – due before Monday, April 30
See the PDF. Homework 4 will be assigned April 30 and due before May 11 — do your best to stay on top of things!
CS 145 Exam 2
Exam See the PDF. Results
CS 330 Lecture 30 – ANTLR and C++
Agenda A Cartesian grid walker language Translating calculator + functions to C++ TODO New ANTLR C++ target: http://www.antlr.org/wiki/pages/viewpage.action?pageId=29130826 ANTLR C++ REPL Code makefile all: cart CartesianLexer.cpp CartesianParser.cpp: Cartesian.g Player.h java -jar antlr-3.4-with-cpp.jar Cartesian.g cart: cart_interpreter.cpp CartesianLexer.cpp CartesianParser.cpp Player.h g++ -I include -o cart cart_interpreter.cpp CartesianLexer.cpp CartesianParser.cpp clean: rm -f CartesianLexer.cpp CartesianParser.cpp cart CartesianLexer.hpp CartesianParser.hpp Cartesian.g […]
CS 330 Lecture 29 – Garbage Collection
Agenda how does polymorphism work? Jim Blinn’s terrible approach the elegant vtable approach garbage collection programmers don’t get explicit reclamation right OS does reclaim memory when program stops what happens when… … we don’t call free? … we call free twice? … we call free once but leave pointer untouched? some approaches: mark-and-sweep stop-and-copy reference […]