diff --git a/ThinkJava/.classpath b/ThinkJava/.classpath new file mode 100644 index 0000000..6ee61f2 --- /dev/null +++ b/ThinkJava/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/ThinkJava/.gitignore b/ThinkJava/.gitignore new file mode 100644 index 0000000..ae3c172 --- /dev/null +++ b/ThinkJava/.gitignore @@ -0,0 +1 @@ +/bin/ diff --git a/ThinkJava/.project b/ThinkJava/.project new file mode 100644 index 0000000..4b1fa92 --- /dev/null +++ b/ThinkJava/.project @@ -0,0 +1,17 @@ + + + ThinkJava + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/ThinkJava/.settings/org.eclipse.jdt.core.prefs b/ThinkJava/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..7e5c907 --- /dev/null +++ b/ThinkJava/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=9 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=9 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=9 diff --git a/ThinkJava/src/BottlesOnTheWall.java b/ThinkJava/src/BottlesOnTheWall.java new file mode 100644 index 0000000..521b444 --- /dev/null +++ b/ThinkJava/src/BottlesOnTheWall.java @@ -0,0 +1,31 @@ + +public class BottlesOnTheWall { + + public static void bottlesOnTheWall(int bottles) { + if (bottles == 0) { + noBottles(); + } else { + bottlesLyrics(bottles); + bottlesOnTheWall(bottles - 1); + } + } + + public static void noBottles() { + System.out.println("No bottles of beer on the wall,\n" + + "no bottles of beer,\n" + + "ya’ can’t take one down, ya’ can’t pass it around,\n" + + "’cause there are no more bottles of beer on the wall!"); + } + + public static void bottlesLyrics(int bottles) { + System.out.println(bottles + " bottles of beer on the wall,"); + System.out.println(bottles + " bottles of beer, \n" + + "ya’ take one down, ya’ pass it around,"); + } + + public static void main(String[] args) { + bottlesOnTheWall(4); + + } + +} diff --git a/ThinkJava/src/FermatsLastTheorem.java b/ThinkJava/src/FermatsLastTheorem.java new file mode 100644 index 0000000..77e901a --- /dev/null +++ b/ThinkJava/src/FermatsLastTheorem.java @@ -0,0 +1,23 @@ + +public class FermatsLastTheorem { + + public static void checkFermat(int a, int b, int c, int n) { + int left = (int) (Math.pow(a, n) + Math.pow(b, n)); + int right = (int) Math.pow(c,n); + if (n>2) { + if (left == right) { + System.out.println("Holy smokes, Fermat is wrong!"); + } else { + System.out.println("No, that doesn't work"); + } + }else { + System.out.println(left == right); + } + } + + public static void main(String[] args) { + checkFermat(1,5,3,1); + + } + +} diff --git a/ThinkJava/src/Main.java b/ThinkJava/src/Main.java new file mode 100644 index 0000000..83e24ef --- /dev/null +++ b/ThinkJava/src/Main.java @@ -0,0 +1,27 @@ + +public class Main { + + public static void zoop(String fred, int bob) { + System.out.println(fred); + if (bob == 5) { + ping("not "); + } else { + System.out.println("!"); + } + } + + public static void main(String[] args) { + int bizz = 5; + int buzz = 2; + zoop("just for", bizz); + clink(2 * buzz); + } + public static void clink(int fork) { + System.out.print("It's "); + zoop("breakfast ", fork); + } + + public static void ping(String strangStrung) { + System.out.println("any " + strangStrung + "more "); + } +} \ No newline at end of file