teaching machines

CS 145 Lecture 12 – Logic

September 29, 2014 by . Filed under cs145, fall 2014, lectures.

Agenda

TODO

Blackbox

Code

Logical.java

package lecture0229;

public class Logical {
  public static void main(String[] args) {
    // boolean playedInParsnip = true;
    // boolean playedInSunlight = true;
    // boolean hasBlisters = playedInParsnip && playedInSunlight;
    // System.out.println(hasBlisters);
    
    boolean isTall = false;
    boolean isDark = false;
    boolean isHandsome = false;
    boolean isRich = true;
    boolean isMrRight = (isTall && isDark && isHandsome) || isRich;
    System.out.println(isMrRight);
    
    String filename = "family.JPEG".toLowerCase();
    boolean isImage = filename.endsWith(".jpg") ||
                      filename.endsWith(".png") ||
                      filename.endsWith(".gif") ||
                      filename.endsWith(".tiff") ||
                      filename.endsWith(".bmp") ||
                      filename.endsWith(".webp");
    System.out.println(isImage);
  }
}

Haiku

on decision-making:
Yes, no, I don’t know
I rolled the third. Skip my turn?
Or act anyway?