diff --git a/lab1/Collatz.java b/lab1/Collatz.java index ddca4e8..9d33650 100644 --- a/lab1/Collatz.java +++ b/lab1/Collatz.java @@ -2,10 +2,26 @@ * @author YOUR NAME HERE */ public class Collatz { + + /** Buggy implementation of nextNumber! */ + public static int nextNumber(int n) { + if (n == 128) { + return 1; + } else if (n == 5) { + return 3 * n + 1; + } else { + return n * 2; + } + } + public static void main(String[] args) { int n = 5; System.out.print(n + " "); - + while (n != 1) { + n = nextNumber(n); + System.out.print(n + " "); + } + System.out.println(); } } diff --git a/lab4/flik/Flik.java b/lab4/flik/Flik.java new file mode 100644 index 0000000..27f5bc6 --- /dev/null +++ b/lab4/flik/Flik.java @@ -0,0 +1,13 @@ +package flik; + +/** An Integer tester created by Flik Enterprises. + * @author Josh Hug + * */ +public class Flik { + /** @param a Value 1 + * @param b Value 2 + * @return Whether a and b are the same */ + public static boolean isSameNumber(Integer a, Integer b) { + return a == b; + } +} diff --git a/lab4/flik/HorribleSteve.java b/lab4/flik/HorribleSteve.java new file mode 100644 index 0000000..3c435fd --- /dev/null +++ b/lab4/flik/HorribleSteve.java @@ -0,0 +1,14 @@ +package flik; + +public class HorribleSteve { + public static void main(String [] args) throws Exception { + int i = 0; + for (int j = 0; i < 500; ++i, ++j) { + if (!Flik.isSameNumber(i, j)) { + throw new Exception( + String.format("i:%d not same as j:%d ??", i, j)); + } + } + System.out.println("i is " + i); + } +} diff --git a/lab4/pom.xml b/lab4/pom.xml new file mode 100644 index 0000000..eba0263 --- /dev/null +++ b/lab4/pom.xml @@ -0,0 +1,44 @@ + + + 4.0.0 + + + CS61B + 61BMasterPom + 1.0-SNAPSHOT + ../library-sp21/javalib/masterpom.xml + + + CS61B + lab4 + 1.0-SNAPSHOT + + + ${project.basedir} + ${project.basedir} + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.14 + 1.14 + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + + -J-XX:+ShowCodeDetailsInExceptionMessages + + + + + + +