CS 145 Homework 4 – due before Wednesday, May 9
See the PDF.
CS 145 Lecture 23 – GUIs, Non-zero Gravity
Agenda TIOBE flip Swing GUI framework a tease of inheritance event-driven programming painting dropping circles composition collaboration graphs in SMC law #31: try local first Code DroppingCircles.java package prefinal; import javax.swing.JFrame; public class DroppingCircles { public static void main(String[] args) { JFrame frame = new JFrame(“Drop Circles”); // frame.add(new JButton(“Click me!”)); // frame.add(new JLabel(“Read me!”)); frame.add(new […]
CS 145 Lecture 22 – Stopwatch
Agenda Paragraph.plot takes Image, not 2-D array PPMViewer lab gotchas other instances as parameters invoking object is not a parameter writing a Stopwatch 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, […]
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 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 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 145 Lecture 19 – Passwords, stack vs. heap
Agenda brute force password generation Java is copy-by-value primitives hold values objects are references, which hold addresses (http://xkcd.com/138/) Pointer Fun with Binky stack vs. heap == vs. equals Code Account.java package preexam2; public class Account { public static boolean authenticate(String password) { return password.equals(“horsieso”); } } Cracker.java package preexam2; import java.util.Arrays; public class Cracker { […]