teaching machines

CS 145 Lecture 11 – Finalizing the big three

March 6, 2012 by . Filed under cs145, lectures, spring 2012.

Agenda

TODO

Reverse Engineering

Code

MrRight.java

public class MrRight {
	public static boolean getTrue() {
		System.out.println("true");
		return true;
	}

	public static boolean getFalse() {
		System.out.println("false");
		return false;
	}

	public static void main(String[] args) {
//		boolean b = getTrue() && getFalse();
//		boolean b = getFalse() && getTrue();
		boolean b = getTrue() || getFalse();
	}
	
	public static boolean isLeap(int year) {
		boolean isMultipleOf4 = year % 4 == 0;
		boolean isMultipleOf100 = year % 100 == 0;
		boolean isMultipleOf400 = year % 400 == 0;
		
		return isMultipleOf4 && (isMultipleOf400 || !isMultipleOf100);
	}

	public static boolean isMrRight(boolean isTall, boolean isDark,
			boolean isHandsome, boolean isRich) {
		return (isTall && isDark && isHandsome) || isRich;
	}
}

Haiku

Sequence, loops, and if.
Elements. Like N, O, H.
Better wear goggles.