diff --git a/.gitignore b/.gitignore
index 045d4e8..5c42643 100644
--- a/.gitignore
+++ b/.gitignore
@@ -172,3 +172,6 @@
/Semester 3/GenericStack/target/
/Semester 3/Assignments/lab6_generics_CalebFontenot/target/
/Semester 3/Exams/Projects/ProgramingExam1_CalebFontenot/target/
+/Semester 3/Assignments/MP3_Recursion_CalebFontenot/dist/
+/BigIntegerFibonacci/nbproject/private/
+/BigIntegerFibonacci/build/
diff --git a/BigIntegerFibonacci/build.xml b/BigIntegerFibonacci/build.xml
new file mode 100644
index 0000000..56581a0
--- /dev/null
+++ b/BigIntegerFibonacci/build.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+ Builds, tests, and runs the project BigIntegerFibonacci.
+
+
+
diff --git a/BigIntegerFibonacci/dist/BigIntegerFibonacci.jar b/BigIntegerFibonacci/dist/BigIntegerFibonacci.jar
new file mode 100644
index 0000000..4b40093
Binary files /dev/null and b/BigIntegerFibonacci/dist/BigIntegerFibonacci.jar differ
diff --git a/BigIntegerFibonacci/dist/README.TXT b/BigIntegerFibonacci/dist/README.TXT
new file mode 100644
index 0000000..805f762
--- /dev/null
+++ b/BigIntegerFibonacci/dist/README.TXT
@@ -0,0 +1,32 @@
+========================
+BUILD OUTPUT DESCRIPTION
+========================
+
+When you build an Java application project that has a main class, the IDE
+automatically copies all of the JAR
+files on the projects classpath to your projects dist/lib folder. The IDE
+also adds each of the JAR files to the Class-Path element in the application
+JAR files manifest file (MANIFEST.MF).
+
+To run the project from the command line, go to the dist folder and
+type the following:
+
+java -jar "BigIntegerFibonacci.jar"
+
+To distribute this project, zip up the dist folder (including the lib folder)
+and distribute the ZIP file.
+
+Notes:
+
+* If two JAR files on the project classpath have the same name, only the first
+JAR file is copied to the lib folder.
+* Only JAR files are copied to the lib folder.
+If the classpath contains other types of files or folders, these files (folders)
+are not copied.
+* If a library on the projects classpath also has a Class-Path element
+specified in the manifest,the content of the Class-Path element has to be on
+the projects runtime path.
+* To set a main class in a standard Java project, right-click the project node
+in the Projects window and choose Properties. Then click Run and enter the
+class name in the Main Class field. Alternatively, you can manually type the
+class name in the manifest Main-Class element.
diff --git a/BigIntegerFibonacci/manifest.mf b/BigIntegerFibonacci/manifest.mf
new file mode 100644
index 0000000..328e8e5
--- /dev/null
+++ b/BigIntegerFibonacci/manifest.mf
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+X-COMMENT: Main-Class will be added automatically by build
+
diff --git a/BigIntegerFibonacci/nbproject/build-impl.xml b/BigIntegerFibonacci/nbproject/build-impl.xml
new file mode 100644
index 0000000..d40015a
--- /dev/null
+++ b/BigIntegerFibonacci/nbproject/build-impl.xml
@@ -0,0 +1,1799 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set platform.home
+ Must set platform.bootcp
+ Must set platform.java
+ Must set platform.javac
+
+ The J2SE Platform is not correctly set up.
+ Your active platform is: ${platform.active}, but the corresponding property "platforms.${platform.active}.home" is not found in the project's properties files.
+ Either open the project in the IDE and setup the Platform with the same name or add it manually.
+ For example like this:
+ ant -Duser.properties.file=<path_to_property_file> jar (where you put the property "platforms.${platform.active}.home" in a .properties file)
+ or ant -Dplatforms.${platform.active}.home=<path_to_JDK_home> jar (where no properties file is used)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set src.dir
+ Must set test.src.dir
+ Must set build.dir
+ Must set dist.dir
+ Must set build.classes.dir
+ Must set dist.javadoc.dir
+ Must set build.test.classes.dir
+ Must set build.test.results.dir
+ Must set build.classes.excludes
+ Must set dist.jar
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No tests executed.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must set JVM to use for profiling in profiler.info.jvm
+ Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ To run this application from the command line without Ant, try:
+
+ ${platform.java} -jar "${dist.jar.resolved}"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must select one file in the IDE or set debug.class
+
+
+
+
+ Must set fix.includes
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set profile.class
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This target only works when run from inside the NetBeans IDE.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+
+ Must select one file in the IDE or set run.class
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set javac.includes
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+
+
+
+
+ Must select some files in the IDE or set test.includes
+
+
+
+ Some tests failed; see details above.
+
+
+
+ Must select some files in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+ Some tests failed; see details above.
+
+
+
+
+ Must select one file in the IDE or set test.class
+
+
+
+ Must select one file in the IDE or set test.class
+ Must select some method in the IDE or set test.method
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+ Must select one file in the IDE or set applet.url
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BigIntegerFibonacci/nbproject/genfiles.properties b/BigIntegerFibonacci/nbproject/genfiles.properties
new file mode 100644
index 0000000..7e33c6d
--- /dev/null
+++ b/BigIntegerFibonacci/nbproject/genfiles.properties
@@ -0,0 +1,8 @@
+build.xml.data.CRC32=8269c52e
+build.xml.script.CRC32=12feaf5a
+build.xml.stylesheet.CRC32=f85dc8f2@1.107.0.48
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=8269c52e
+nbproject/build-impl.xml.script.CRC32=f775d689
+nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.107.0.48
diff --git a/BigIntegerFibonacci/nbproject/project.properties b/BigIntegerFibonacci/nbproject/project.properties
new file mode 100644
index 0000000..2efffa4
--- /dev/null
+++ b/BigIntegerFibonacci/nbproject/project.properties
@@ -0,0 +1,97 @@
+annotation.processing.enabled=true
+annotation.processing.enabled.in.editor=false
+annotation.processing.processors.list=
+annotation.processing.run.all.processors=true
+annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+application.title=BigIntegerFibonacci
+application.vendor=caleb
+build.classes.dir=${build.dir}/classes
+build.classes.excludes=**/*.java,**/*.form
+# This directory is removed when the project is cleaned:
+build.dir=build
+build.generated.dir=${build.dir}/generated
+build.generated.sources.dir=${build.dir}/generated-sources
+# Only compile against the classpath explicitly listed here:
+build.sysclasspath=ignore
+build.test.classes.dir=${build.dir}/test/classes
+build.test.results.dir=${build.dir}/test/results
+# Uncomment to specify the preferred debugger connection transport:
+#debug.transport=dt_socket
+debug.classpath=\
+ ${run.classpath}
+debug.modulepath=\
+ ${run.modulepath}
+debug.test.classpath=\
+ ${run.test.classpath}
+debug.test.modulepath=\
+ ${run.test.modulepath}
+# Files in build.classes.dir which should be excluded from distribution jar
+dist.archive.excludes=
+# This directory is removed when the project is cleaned:
+dist.dir=dist
+dist.jar=${dist.dir}/BigIntegerFibonacci.jar
+dist.javadoc.dir=${dist.dir}/javadoc
+dist.jlink.dir=${dist.dir}/jlink
+dist.jlink.output=${dist.jlink.dir}/BigIntegerFibonacci
+endorsed.classpath=
+excludes=
+includes=**
+jar.compress=false
+javac.classpath=
+# Space-separated list of extra javac options
+javac.compilerargs=
+javac.deprecation=false
+javac.external.vm=true
+javac.modulepath=
+javac.processormodulepath=
+javac.processorpath=\
+ ${javac.classpath}
+javac.source=20
+javac.target=20
+javac.test.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+javac.test.modulepath=\
+ ${javac.modulepath}
+javac.test.processorpath=\
+ ${javac.test.classpath}
+javadoc.additionalparam=
+javadoc.author=false
+javadoc.encoding=${source.encoding}
+javadoc.html5=false
+javadoc.noindex=false
+javadoc.nonavbar=false
+javadoc.notree=false
+javadoc.private=false
+javadoc.splitindex=true
+javadoc.use=true
+javadoc.version=false
+javadoc.windowtitle=
+# The jlink additional root modules to resolve
+jlink.additionalmodules=
+# The jlink additional command line parameters
+jlink.additionalparam=
+jlink.launcher=true
+jlink.launcher.name=BigIntegerFibonacci
+main.class=bigintegerfibonacci.BigIntegerFibonacci
+manifest.file=manifest.mf
+meta.inf.dir=${src.dir}/META-INF
+mkdist.disabled=false
+platform.active=Graal_JDK_20
+run.classpath=\
+ ${javac.classpath}:\
+ ${build.classes.dir}
+# Space-separated list of JVM arguments used when running the project.
+# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
+# To set system properties for unit tests define test-sys-prop.name=value:
+run.jvmargs=-Dfile.encoding=UTF-8 -Xms512m -Xmx32G -Xss128M
+run.modulepath=\
+ ${javac.modulepath}
+run.test.classpath=\
+ ${javac.test.classpath}:\
+ ${build.test.classes.dir}
+run.test.modulepath=\
+ ${javac.test.modulepath}
+source.encoding=UTF-8
+src.dir=src
+test.src.dir=test
diff --git a/BigIntegerFibonacci/nbproject/project.xml b/BigIntegerFibonacci/nbproject/project.xml
new file mode 100644
index 0000000..d288e4d
--- /dev/null
+++ b/BigIntegerFibonacci/nbproject/project.xml
@@ -0,0 +1,16 @@
+
+
+ org.netbeans.modules.java.j2seproject
+
+
+ BigIntegerFibonacci
+
+
+
+
+
+
+
+
+
+
diff --git a/BigIntegerFibonacci/src/bigintegerfibonacci/BigIntegerFibonacci.java b/BigIntegerFibonacci/src/bigintegerfibonacci/BigIntegerFibonacci.java
new file mode 100644
index 0000000..c1f2751
--- /dev/null
+++ b/BigIntegerFibonacci/src/bigintegerfibonacci/BigIntegerFibonacci.java
@@ -0,0 +1,47 @@
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
+ */
+package bigintegerfibonacci;
+
+import java.math.BigInteger;
+
+/**
+ *
+ * @author caleb
+ */
+public class BigIntegerFibonacci {
+
+ /**
+ * @param args the command line arguments
+ */
+ private static BigInteger[] fibonacciCache;
+ public static void main(String[] args) {
+ int n = 100000;
+ fibonacciCache = new BigInteger[n + 1];
+ System.out.println("Calculating fibonacci for number " + n + "...");
+ // Precache value to prevent stack overflow
+ for (int i = 0; i <= n; ++i) {
+ fibonacci(i);
+ }
+ System.out.println(fibonacci(n));
+
+ }
+
+ private static BigInteger fibonacci(int n) {
+ // Base case
+ int compareInt = BigInteger.valueOf(n).compareTo(BigInteger.ONE);
+ //System.out.println("value is: " + compareInt);
+
+ if (compareInt == -1 || compareInt == 0){
+ return BigInteger.valueOf(n);
+ }
+ if (fibonacciCache[n] != null) {
+ return fibonacciCache[n];
+ }
+ BigInteger nthFibNumber = (fibonacci(n - 1).add(fibonacci(n - 2)));
+ fibonacciCache[n] = nthFibNumber;
+ return fibonacciCache[n];
+ }
+
+}
diff --git a/BigIntegerFibonacci/src/bigintegerfibonacci/StackSize.java b/BigIntegerFibonacci/src/bigintegerfibonacci/StackSize.java
new file mode 100644
index 0000000..2f764ae
--- /dev/null
+++ b/BigIntegerFibonacci/src/bigintegerfibonacci/StackSize.java
@@ -0,0 +1,35 @@
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package bigintegerfibonacci;
+
+/**
+ *
+ * @author caleb
+ */
+public class StackSize {
+
+ public static void main(String[] args) {
+
+ try {
+ //System.out.println(fact(1 << 15));
+ System.out.println(infinateRecursion(0));
+ }
+ catch (StackOverflowError e) {
+ System.err.println("true recursion level was " + level);
+ System.err.println("reported recursion level was " +
+ e.getStackTrace().length);
+ }
+ }
+
+ private static int level = 0;
+ public static long fact(int n) {
+ level++;
+ return n < 2 ? n : n * fact(n - 1);
+ }
+ public static long infinateRecursion(long n) {
+ level++;
+ return infinateRecursion(n++);
+ }
+}
diff --git a/Semester 3/Assignments/MP3_Recursion_CalebFontenot/Printed HTMLs/BinaryToDecimal.html b/Semester 3/Assignments/MP3_Recursion_CalebFontenot/Printed HTMLs/BinaryToDecimal.html
new file mode 100644
index 0000000..1e5fdc5
--- /dev/null
+++ b/Semester 3/Assignments/MP3_Recursion_CalebFontenot/Printed HTMLs/BinaryToDecimal.html
@@ -0,0 +1,63 @@
+
+
+
+BinaryToDecimal.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 3/Assignments/MP3_Recursion_CalebFontenot/src/mp3_recursion_calebfontenot/BinaryToDecimal.java |
+
+package mp3_recursion_calebfontenot;
+
+
+import java.util.Scanner;
+
+
+
+
+
+
+
+
+
+public class BinaryToDecimal {
+
+ public static void main(String[] args) {
+ Scanner input = new Scanner(System.in);
+ while (true) {
+ System.out.print("Enter a binary number: ");
+ String binary = input.nextLine();
+ System.out.println(binary + " in decimal is " + binaryToDecimal(binary));
+ }
+ }
+
+ public static int binaryToDecimal(String binaryString) {
+ return binaryToDecimal(binaryString, 0, binaryString.length(), 0);
+ }
+
+ public static int binaryToDecimal(String binaryString, int low, int high, int value) {
+ if (low == binaryString.length() - 1) {
+ return value;
+ }
+ if (binaryString.charAt(low) == '1') {
+ return binaryToDecimal(binaryString, ++low, --high, value += Math.pow(2, high));
+ } else {
+ return binaryToDecimal(binaryString, ++low, --high, value);
+ }
+ }
+}
+
+
+
diff --git a/Semester 3/Assignments/MP3_Recursion_CalebFontenot/Printed HTMLs/DecimalToBinary.html b/Semester 3/Assignments/MP3_Recursion_CalebFontenot/Printed HTMLs/DecimalToBinary.html
new file mode 100644
index 0000000..db5545f
--- /dev/null
+++ b/Semester 3/Assignments/MP3_Recursion_CalebFontenot/Printed HTMLs/DecimalToBinary.html
@@ -0,0 +1,86 @@
+
+
+
+DecimalToBinary.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 3/Assignments/MP3_Recursion_CalebFontenot/src/mp3_recursion_calebfontenot/DecimalToBinary.java |
+
+
+
+
+
+package mp3_recursion_calebfontenot;
+
+import java.util.Scanner;
+
+
+
+
+
+public class DecimalToBinary {
+
+ public static void main(String[] args) {
+ Scanner input = new Scanner(System.in);
+ while (true) {
+ System.out.print("Enter a decimal integer: ");
+ int decimal = input.nextInt();
+ System.out.println(decimal + " is " + decimalToBinary(decimal) + " in binary.");
+ }
+ }
+
+ public static String decimalToBinary(int value) {
+ return reverse(decimalToBinary(value, ""));
+ }
+
+ public static String decimalToBinary(int value, String bin) {
+ if (value == 0) {
+ return bin += "";
+ } else if (value > 0) {
+ if (value % 2 == 1) {
+ return decimalToBinary((int) Math.floor(value / 2), bin + "1");
+ } else {
+ return decimalToBinary((int) Math.floor(value / 2), bin + "0");
+ }
+ }
+
+ return "0 naht ssel si eulav";
+
+ }
+ public static String reverse(String input) {
+ String returnString = "";
+ for (int i = input.length() - 1; 0 <= i; --i) {
+ returnString += input.charAt(i);
+ }
+ return returnString;
+ }
+
+ public static String decimalToBinaryIterative(int value) {
+ String bin = "";
+ while (value > 0) {
+ if (value % 2 == 1)
+ bin += "1";
+ else
+ bin += "0";
+
+ value /= 2;
+ }
+ return reverse(bin);
+ }
+}
+
+
+
diff --git a/Semester 3/Assignments/MP3_Recursion_CalebFontenot/Printed HTMLs/Maze.html b/Semester 3/Assignments/MP3_Recursion_CalebFontenot/Printed HTMLs/Maze.html
new file mode 100644
index 0000000..d2a5a22
--- /dev/null
+++ b/Semester 3/Assignments/MP3_Recursion_CalebFontenot/Printed HTMLs/Maze.html
@@ -0,0 +1,397 @@
+
+
+
+Maze.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 3/Assignments/MP3_Recursion_CalebFontenot/src/mp3_recursion_calebfontenot/Maze.java |
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package mp3_recursion_calebfontenot;
+
+import java.util.Optional;
+import javafx.application.Application;
+import javafx.geometry.Pos;
+import javafx.scene.Scene;
+import javafx.scene.control.Alert;
+import javafx.scene.control.Button;
+import javafx.scene.control.ButtonType;
+import javafx.scene.control.Label;
+import javafx.scene.layout.BorderPane;
+import javafx.scene.layout.GridPane;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.StackPane;
+import javafx.scene.paint.Color;
+import javafx.scene.shape.Line;
+import javafx.scene.shape.Rectangle;
+import javafx.stage.Stage;
+
+
+
+
+
+public class Maze extends Application {
+
+ double paneWidth = 600;
+ double paneHeight = 600;
+
+ private Cell[][] board = new Cell[8][8];
+ private Button btFindPath = new Button("Find Path Top Left to Bottom Right");
+ private Button btFindPath2 = new Button("Find Path Top Right to Bottom Left");
+ private Button btClearPath = new Button("Clear Path");
+ private Label lblStatus = new Label();
+
+ @Override
+ public void start(Stage primaryStage) {
+ GridPane gridPane = new GridPane();
+ for (int i = 0; i < 8; i++) {
+ for (int j = 0; j < 8; j++) {
+ gridPane.add(board[i][j] = new Cell(), j, i);
+ }
+ }
+
+ HBox hBox = new HBox(5);
+ hBox.setAlignment(Pos.CENTER);
+ hBox.getChildren().addAll(btFindPath, btFindPath2, btClearPath);
+
+ BorderPane pane = new BorderPane();
+ pane.setTop(lblStatus);
+ BorderPane.setAlignment(lblStatus, Pos.CENTER);
+ pane.setCenter(gridPane);
+ pane.setBottom(hBox);
+
+
+ Scene scene = new Scene(pane, paneWidth, paneHeight + 60);
+ primaryStage.setTitle("Maze");
+ primaryStage.setScene(scene);
+ primaryStage.show();
+
+ btFindPath.setOnAction(e -> findPath());
+ btFindPath2.setOnAction(e -> findPath2());
+ btClearPath.setOnAction(e -> clearPath());
+ showSampleMessage();
+
+ }
+
+ public void showSampleMessage() {
+ Alert a = new Alert(Alert.AlertType.CONFIRMATION);
+
+ a.setTitle("Maze Information");
+ a.setHeaderText(" Put this message in its proper place. ");
+ a.setContentText("This square cannot have an X");
+ Optional<ButtonType> result = a.showAndWait();
+ if (result.get() == ButtonType.OK) {
+ System.out.println("OK ");
+ } else if (result.get() == ButtonType.CANCEL) {
+ System.out.println("CANCEL");
+ }
+ }
+ public void clearCells() {
+ for (int i = 0; i < 8; ++i) {
+ for (int j = 0; j < 8; j++) {
+ board[i][j].resetCell();
+ }
+ }
+ }
+
+ public void findPath() {
+ clearCells();
+ if (findPath(0, 0)) {
+ lblStatus.setText("path found");
+ } else {
+ lblStatus.setText("No path exists");
+ }
+ }
+
+ public void findPath2() {
+ clearCells();
+ if (findPath2(0, 7)) {
+ lblStatus.setText("path found");
+ } else {
+ lblStatus.setText("No path exists");
+ }
+ }
+
+ public boolean findPath(int row, int col) {
+ board[row][col].visit();
+
+ if ((col == 7) && (row == 7)) {
+ board[row][col].selectCell();
+ return true;
+ }
+
+ if ((row > 0) && !board[row - 1][col].marked()
+ && !board[row - 1][col].blocked() && !board[row - 1][col].visited()) {
+ block(row, col);
+
+ if (findPath(row - 1, col)) {
+ board[row][col].selectCell();
+ return true;
+ }
+
+ unblock(row, col);
+ }
+
+ if ((row < 7) && !board[row + 1][col].marked()
+ && !board[row + 1][col].blocked() && !board[row + 1][col].visited()) {
+ block(row, col);
+
+ if (findPath(row + 1, col)) {
+ board[row][col].selectCell();
+ return true;
+ }
+
+ unblock(row, col);
+ }
+
+ if ((col > 0) && !board[row][col - 1].marked()
+ && !board[row][col - 1].blocked() && !board[row][col - 1].visited()) {
+ block(row, col);
+ if (findPath(row, col - 1)) {
+ board[row][col].selectCell();
+ return true;
+ }
+
+ unblock(row, col);
+ }
+
+ if ((col < 7) && !board[row][col + 1].marked()
+ && !board[row][col + 1].blocked() && !board[row][col + 1].visited()) {
+ block(row, col);
+ if (findPath(row, col + 1)) {
+ board[row][col].selectCell();
+ return true;
+ }
+
+ unblock(row, col);
+ }
+
+ return false;
+ }
+
+ public boolean findPath2(int row, int col) {
+ board[row][col].visit();
+
+ if ((col == 0) && (row == 7)) {
+ board[row][col].selectCellGreen();
+ return true;
+ }
+
+ if ((row > 0) && !board[row - 1][col].marked()
+ && !board[row - 1][col].blocked() && !board[row - 1][col].visited()) {
+ block(row, col);
+
+ if (findPath2(row - 1, col)) {
+ board[row][col].selectCellGreen();
+ return true;
+ }
+
+ unblock(row, col);
+ }
+
+ if ((row < 7) && !board[row + 1][col].marked()
+ && !board[row + 1][col].blocked() && !board[row + 1][col].visited()) {
+ block(row, col);
+
+ if (findPath2(row + 1, col)) {
+ board[row][col].selectCellGreen();
+ return true;
+ }
+
+ unblock(row, col);
+ }
+
+ if ((col > 0) && !board[row][col - 1].marked()
+ && !board[row][col - 1].blocked() && !board[row][col - 1].visited()) {
+ block(row, col);
+ if (findPath2(row, col - 1)) {
+ board[row][col].selectCellGreen();
+ return true;
+ }
+
+ unblock(row, col);
+ }
+
+ if ((col < 7) && !board[row][col + 1].marked()
+ && !board[row][col + 1].blocked() && !board[row][col + 1].visited()) {
+ block(row, col);
+ if (findPath2(row, col + 1)) {
+ board[row][col].selectCellGreen();
+ return true;
+ }
+
+ unblock(row, col);
+ }
+
+ return false;
+ }
+
+
+ public void block(int row, int col) {
+ if (row > 0) {
+ board[row - 1][col].block();
+ }
+
+ if (row < 7) {
+ board[row + 1][col].block();
+ }
+
+ if (col > 0) {
+ board[row][col - 1].block();
+ }
+
+ if (col < 7) {
+ board[row][col + 1].block();
+ }
+ }
+
+
+ public void unblock(int row, int col) {
+ if (row > 0) {
+ board[row - 1][col].unblock();
+ }
+
+ if (row < 7) {
+ board[row + 1][col].unblock();
+ }
+
+ if (col > 0) {
+ board[row][col - 1].unblock();
+ }
+
+ if (col < 7) {
+ board[row][col + 1].unblock();
+ }
+ }
+
+ public void clearPath() {
+ for (int row = 0; row < board.length; row++) {
+ for (int col = 0; col < board[row].length; col++) {
+ board[row][col].deselectCell();
+ }
+ }
+ }
+
+ public static void main(String[] args) {
+ launch(args);
+ }
+
+
+ class Cell extends StackPane {
+
+ private boolean marked = false;
+ private boolean visited = false;
+ private boolean blocked = false;
+
+ double width = paneWidth / 8;
+ double height = paneHeight / 8;
+ private Rectangle rectangle = new Rectangle(0, 0, width, height);
+
+ Line line1 = new Line(0, 0, width, height);
+ Line line2 = new Line(width, 0, 0, height);
+
+ public Cell() {
+ this.getChildren().add(rectangle);
+ rectangle.setFill(Color.WHITE);
+ rectangle.setStroke(Color.BLACK);
+
+ this.setOnMousePressed(e
+ -> {
+ marked = !marked;
+ if (marked) {
+ mark();
+ } else {
+ unmark();
+ }
+ });
+ }
+
+ public void mark() {
+ this.getChildren().addAll(line1, line2);
+ }
+
+ public void unmark() {
+ this.getChildren().remove(line1);
+ this.getChildren().remove(line2);
+ }
+
+ public boolean marked() {
+ return marked;
+ }
+
+ public void visit() {
+ visited = true;
+ }
+
+ public boolean visited() {
+ return visited;
+ }
+
+ public boolean blocked() {
+ return blocked;
+ }
+
+ public void block() {
+ blocked = true;
+ }
+
+ public void unblock() {
+ blocked = false;
+ }
+
+ public void selectCell() {
+ if (rectangle.getFill().equals(Color.GREEN)) {
+ rectangle.setFill(Color.YELLOW);
+ } else {
+ rectangle.setFill(Color.RED);
+ }
+
+ }
+
+ public void selectCellGreen() {
+ if (rectangle.getFill().equals(Color.RED)) {
+ rectangle.setFill(Color.YELLOW);
+ } else {
+ rectangle.setFill(Color.GREEN);
+ }
+ }
+
+ public void deselectCell() {
+ rectangle.setFill(Color.WHITE);
+ blocked = false;
+ visited = false;
+ }
+
+ public void resetCell() {
+
+ blocked = false;
+ visited = false;
+ }
+ }
+
+}
+
+
+
diff --git a/Semester 3/Assignments/MP3_Recursion_CalebFontenot/Printed HTMLs/SelectionSortR.html b/Semester 3/Assignments/MP3_Recursion_CalebFontenot/Printed HTMLs/SelectionSortR.html
new file mode 100644
index 0000000..1621a10
--- /dev/null
+++ b/Semester 3/Assignments/MP3_Recursion_CalebFontenot/Printed HTMLs/SelectionSortR.html
@@ -0,0 +1,82 @@
+
+
+
+SelectionSortR.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 3/Assignments/MP3_Recursion_CalebFontenot/src/mp3_recursion_calebfontenot/SelectionSortR.java |
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package edu.slcc.asdv.caleb.lab5.recursion2_calebfontenot;
+
+
+
+
+
+public class SelectionSortR {
+
+ public static void selectionSortR(int[] arr) {
+ selectionSortR(arr, 0, arr.length);
+ }
+
+ public static void swap(int[] arr, int i, int j) {
+ int temp = arr[i];
+ arr[i] = arr[j];
+ arr[j] = temp;
+ printArray(arr);
+ }
+
+ public static void selectionSortR(int[] arr, int i, int n) {
+
+ int min = i;
+ for (int j = i + 1; j < n; ++j) {
+ if (arr[j] < arr[min]) {
+ min = j;
+ }
+ }
+ swap(arr, min, i);
+ if (i + 1 < n) {
+ selectionSortR(arr, i + 1, n);
+ }
+ }
+
+ public static void main(String[] args) {
+ int[] arr = {
+ 10, 1, 20, 3
+ };
+ printArray(arr);
+ selectionSortR(arr);
+
+ }
+
+ public static void printArray(int[] arr) {
+ for (int i = 0; i < arr.length; ++i) {
+ System.out.print(arr[i] + " ");
+ }
+ System.out.println();
+ }
+}
+
+
+
diff --git a/Semester 3/Assignments/MP3_Recursion_CalebFontenot/Printed HTMLs/StringPermuatation.html b/Semester 3/Assignments/MP3_Recursion_CalebFontenot/Printed HTMLs/StringPermuatation.html
new file mode 100644
index 0000000..b0075c4
--- /dev/null
+++ b/Semester 3/Assignments/MP3_Recursion_CalebFontenot/Printed HTMLs/StringPermuatation.html
@@ -0,0 +1,61 @@
+
+
+
+StringPermuatation.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 3/Assignments/MP3_Recursion_CalebFontenot/src/mp3_recursion_calebfontenot/StringPermuatation.java |
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package mp3_recursion_calebfontenot;
+
+import java.util.Scanner;
+
+
+
+
+
+public class StringPermuatation {
+ public static void main(String[] args) {
+ Scanner input = new Scanner(System.in);
+ System.out.print("Enter a string: ");
+ String s = input.nextLine();
+ System.out.println("The permuatation for " + s + " is:");
+ displayPermutation(s);
+ }
+
+ public static void displayPermutation(String s) {
+ displayPermutation("", s);
+ }
+ public static void displayPermutation(String s1, String s2) {
+ if (s2.equals("")) {
+ System.out.println(s1);
+ }
+ for (int i = 0; i < s2.length(); ++i) {
+ displayPermutation(s1.concat("" + s2.charAt(i)), s2.substring(0, i).concat(s2.substring(i + 1)));
+ }
+ }
+}
+
+
+
diff --git a/Semester 3/Assignments/MP3_Recursion_CalebFontenot/src/mp3_recursion_calebfontenot/Maze.java b/Semester 3/Assignments/MP3_Recursion_CalebFontenot/src/mp3_recursion_calebfontenot/Maze.java
index a5670eb..17bc94e 100644
--- a/Semester 3/Assignments/MP3_Recursion_CalebFontenot/src/mp3_recursion_calebfontenot/Maze.java
+++ b/Semester 3/Assignments/MP3_Recursion_CalebFontenot/src/mp3_recursion_calebfontenot/Maze.java
@@ -4,7 +4,6 @@
*/
package mp3_recursion_calebfontenot;
-
import java.util.Optional;
import javafx.application.Application;
import javafx.geometry.Pos;
@@ -26,32 +25,29 @@ import javafx.stage.Stage;
*
* @author caleb
*/
-public class Maze extends Application
-{
+public class Maze extends Application {
- double paneWidth = 440;
- double paneHeight = 440;
+ double paneWidth = 600;
+ double paneHeight = 600;
private Cell[][] board = new Cell[8][8];
private Button btFindPath = new Button("Find Path Top Left to Bottom Right");
+ private Button btFindPath2 = new Button("Find Path Top Right to Bottom Left");
private Button btClearPath = new Button("Clear Path");
private Label lblStatus = new Label();
@Override // Override the start method in the Application class
- public void start(Stage primaryStage)
- {
+ public void start(Stage primaryStage) {
GridPane gridPane = new GridPane();
- for (int i = 0; i < 8; i++)
- {
- for (int j = 0; j < 8; j++)
- {
+ for (int i = 0; i < 8; i++) {
+ for (int j = 0; j < 8; j++) {
gridPane.add(board[i][j] = new Cell(), j, i);
- }
- }
+ }
+ }
HBox hBox = new HBox(5);
hBox.setAlignment(Pos.CENTER);
- hBox.getChildren().addAll(btFindPath, btClearPath);
+ hBox.getChildren().addAll(btFindPath, btFindPath2, btClearPath);
BorderPane pane = new BorderPane();
pane.setTop(lblStatus);
@@ -66,175 +62,217 @@ public class Maze extends Application
primaryStage.show(); // Display the stage
btFindPath.setOnAction(e -> findPath());
+ btFindPath2.setOnAction(e -> findPath2());
btClearPath.setOnAction(e -> clearPath());
showSampleMessage();
}
- public void showSampleMessage()
- {
+ public void showSampleMessage() {
Alert a = new Alert(Alert.AlertType.CONFIRMATION);
a.setTitle("Maze Information");
a.setHeaderText(" Put this message in its proper place. ");
a.setContentText("This square cannot have an X");
Optional result = a.showAndWait();
- if (result.get() == ButtonType.OK)
- {
+ if (result.get() == ButtonType.OK) {
System.out.println("OK ");
- }
- else if (result.get() == ButtonType.CANCEL)
- {
+ } else if (result.get() == ButtonType.CANCEL) {
System.out.println("CANCEL");
- }
+ }
}
-
- public void findPath()
- {
- if (findPath(0, 0))
- {
+ public void clearCells() {
+ for (int i = 0; i < 8; ++i) {
+ for (int j = 0; j < 8; j++) {
+ board[i][j].resetCell();
+ }
+ }
+ }
+
+ public void findPath() {
+ clearCells();
+ if (findPath(0, 0)) {
lblStatus.setText("path found");
- }
- else
- {
+ } else {
lblStatus.setText("No path exists");
- }
+ }
}
- public boolean findPath(int row, int col)
- {
+ public void findPath2() {
+ clearCells();
+ if (findPath2(0, 7)) {
+ lblStatus.setText("path found");
+ } else {
+ lblStatus.setText("No path exists");
+ }
+ }
+
+ public boolean findPath(int row, int col) {
board[row][col].visit();
- if ((col == 7) && (row == 7))
- {
+ if ((col == 7) && (row == 7)) {
board[row][col].selectCell();
return true;
- }
+ }
if ((row > 0) && !board[row - 1][col].marked()
- && !board[row - 1][col].blocked() && !board[row - 1][col].visited())
- {
+ && !board[row - 1][col].blocked() && !board[row - 1][col].visited()) {
block(row, col);
- if (findPath(row - 1, col))
- {
+ if (findPath(row - 1, col)) {
board[row][col].selectCell();
return true;
- }
+ }
unblock(row, col);
- }
+ }
if ((row < 7) && !board[row + 1][col].marked()
- && !board[row + 1][col].blocked() && !board[row + 1][col].visited())
- {
+ && !board[row + 1][col].blocked() && !board[row + 1][col].visited()) {
block(row, col);
- if (findPath(row + 1, col))
- {
+ if (findPath(row + 1, col)) {
board[row][col].selectCell();
return true;
- }
+ }
unblock(row, col);
- }
+ }
if ((col > 0) && !board[row][col - 1].marked()
- && !board[row][col - 1].blocked() && !board[row][col - 1].visited())
- {
+ && !board[row][col - 1].blocked() && !board[row][col - 1].visited()) {
block(row, col);
- if (findPath(row, col - 1))
- {
+ if (findPath(row, col - 1)) {
board[row][col].selectCell();
return true;
- }
+ }
unblock(row, col);
- }
+ }
if ((col < 7) && !board[row][col + 1].marked()
- && !board[row][col + 1].blocked() && !board[row][col + 1].visited())
- {
+ && !board[row][col + 1].blocked() && !board[row][col + 1].visited()) {
block(row, col);
- if (findPath(row, col + 1))
- {
+ if (findPath(row, col + 1)) {
board[row][col].selectCell();
return true;
- }
+ }
unblock(row, col);
- }
+ }
+
+ return false;
+ }
+
+ public boolean findPath2(int row, int col) {
+ board[row][col].visit();
+
+ if ((col == 0) && (row == 7)) {
+ board[row][col].selectCellGreen();
+ return true;
+ }
+
+ if ((row > 0) && !board[row - 1][col].marked()
+ && !board[row - 1][col].blocked() && !board[row - 1][col].visited()) {
+ block(row, col);
+
+ if (findPath2(row - 1, col)) {
+ board[row][col].selectCellGreen();
+ return true;
+ }
+
+ unblock(row, col);
+ }
+
+ if ((row < 7) && !board[row + 1][col].marked()
+ && !board[row + 1][col].blocked() && !board[row + 1][col].visited()) {
+ block(row, col);
+
+ if (findPath2(row + 1, col)) {
+ board[row][col].selectCellGreen();
+ return true;
+ }
+
+ unblock(row, col);
+ }
+
+ if ((col > 0) && !board[row][col - 1].marked()
+ && !board[row][col - 1].blocked() && !board[row][col - 1].visited()) {
+ block(row, col);
+ if (findPath2(row, col - 1)) {
+ board[row][col].selectCellGreen();
+ return true;
+ }
+
+ unblock(row, col);
+ }
+
+ if ((col < 7) && !board[row][col + 1].marked()
+ && !board[row][col + 1].blocked() && !board[row][col + 1].visited()) {
+ block(row, col);
+ if (findPath2(row, col + 1)) {
+ board[row][col].selectCellGreen();
+ return true;
+ }
+
+ unblock(row, col);
+ }
return false;
}
// Temporary block the neighbor to prevent neighboring path
- public void block(int row, int col)
- {
- if (row > 0)
- {
+ public void block(int row, int col) {
+ if (row > 0) {
board[row - 1][col].block();
- }
+ }
- if (row < 7)
- {
+ if (row < 7) {
board[row + 1][col].block();
- }
+ }
- if (col > 0)
- {
+ if (col > 0) {
board[row][col - 1].block();
- }
+ }
- if (col < 7)
- {
+ if (col < 7) {
board[row][col + 1].block();
- }
+ }
}
// Remove the temporary block
- public void unblock(int row, int col)
- {
- if (row > 0)
- {
+ public void unblock(int row, int col) {
+ if (row > 0) {
board[row - 1][col].unblock();
- }
+ }
- if (row < 7)
- {
+ if (row < 7) {
board[row + 1][col].unblock();
- }
+ }
- if (col > 0)
- {
+ if (col > 0) {
board[row][col - 1].unblock();
- }
+ }
- if (col < 7)
- {
+ if (col < 7) {
board[row][col + 1].unblock();
- }
+ }
}
- public void clearPath()
- {
- for (int row = 0; row < board.length; row++)
- {
- for (int col = 0; col < board[row].length; col++)
- {
+ public void clearPath() {
+ for (int row = 0; row < board.length; row++) {
+ for (int col = 0; col < board[row].length; col++) {
board[row][col].deselectCell();
- }
- }
+ }
+ }
}
- public static void main(String[] args)
- {
+ public static void main(String[] args) {
launch(args);
}
// Inner class
- class Cell extends StackPane
- {
+ class Cell extends StackPane {
private boolean marked = false;
private boolean visited = false;
@@ -247,79 +285,83 @@ public class Maze extends Application
Line line1 = new Line(0, 0, width, height);
Line line2 = new Line(width, 0, 0, height);
- public Cell()
- {
+ public Cell() {
this.getChildren().add(rectangle);
rectangle.setFill(Color.WHITE);
rectangle.setStroke(Color.BLACK);
- this.setOnMousePressed(e ->
- {
+ this.setOnMousePressed(e
+ -> {
marked = !marked;
- if (marked)
- {
+ if (marked) {
mark();
- }
- else
- {
+ } else {
unmark();
- }
- });
+ }
+ });
}
- public void mark()
- {
+ public void mark() {
this.getChildren().addAll(line1, line2);
}
- public void unmark()
- {
+ public void unmark() {
this.getChildren().remove(line1);
this.getChildren().remove(line2);
}
- public boolean marked()
- {
+ public boolean marked() {
return marked;
}
- public void visit()
- {
+ public void visit() {
visited = true;
}
- public boolean visited()
- {
+ public boolean visited() {
return visited;
}
- public boolean blocked()
- {
+ public boolean blocked() {
return blocked;
}
- public void block()
- {
+ public void block() {
blocked = true;
}
- public void unblock()
- {
+ public void unblock() {
blocked = false;
}
- public void selectCell()
- {
- rectangle.setFill(Color.RED);
+ public void selectCell() {
+ if (rectangle.getFill().equals(Color.GREEN)) {
+ rectangle.setFill(Color.YELLOW);
+ } else {
+ rectangle.setFill(Color.RED);
+ }
+
}
- public void deselectCell()
- {
+ public void selectCellGreen() {
+ if (rectangle.getFill().equals(Color.RED)) {
+ rectangle.setFill(Color.YELLOW);
+ } else {
+ rectangle.setFill(Color.GREEN);
+ }
+ }
+
+ public void deselectCell() {
rectangle.setFill(Color.WHITE);
blocked = false;
visited = false;
}
+
+ public void resetCell() {
+ //rectangle.setFill(Color.WHITE);
+ blocked = false;
+ visited = false;
+ }
}
}
-
diff --git a/Semester 3/Assignments/MP3_Recursion_CalebFontenot/src/mp3_recursion_calebfontenot/SelectionSortR.java b/Semester 3/Assignments/MP3_Recursion_CalebFontenot/src/mp3_recursion_calebfontenot/SelectionSortR.java
new file mode 100644
index 0000000..92e6225
--- /dev/null
+++ b/Semester 3/Assignments/MP3_Recursion_CalebFontenot/src/mp3_recursion_calebfontenot/SelectionSortR.java
@@ -0,0 +1,53 @@
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package edu.slcc.asdv.caleb.lab5.recursion2_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+public class SelectionSortR {
+
+ public static void selectionSortR(int[] arr) {
+ selectionSortR(arr, 0, arr.length);
+ }
+
+ public static void swap(int[] arr, int i, int j) {
+ int temp = arr[i];
+ arr[i] = arr[j];
+ arr[j] = temp;
+ printArray(arr);
+ }
+
+ public static void selectionSortR(int[] arr, int i, int n) {
+ // Selection sort
+ int min = i;
+ for (int j = i + 1; j < n; ++j) {
+ if (arr[j] < arr[min]) {
+ min = j;
+ }
+ }
+ swap(arr, min, i);
+ if (i + 1 < n) {
+ selectionSortR(arr, i + 1, n);
+ }
+ }
+
+ public static void main(String[] args) {
+ int[] arr = {
+ 10, 1, 20, 3
+ };
+ printArray(arr);
+ selectionSortR(arr);
+
+ }
+
+ public static void printArray(int[] arr) {
+ for (int i = 0; i < arr.length; ++i) {
+ System.out.print(arr[i] + " ");
+ }
+ System.out.println();
+ }
+}
diff --git a/Semester 3/Assignments/MP3_Recursion_CalebFontenot/src/mp3_recursion_calebfontenot/StringPermuatation.java b/Semester 3/Assignments/MP3_Recursion_CalebFontenot/src/mp3_recursion_calebfontenot/StringPermuatation.java
index 88ec478..342625a 100644
--- a/Semester 3/Assignments/MP3_Recursion_CalebFontenot/src/mp3_recursion_calebfontenot/StringPermuatation.java
+++ b/Semester 3/Assignments/MP3_Recursion_CalebFontenot/src/mp3_recursion_calebfontenot/StringPermuatation.java
@@ -20,11 +20,14 @@ public class StringPermuatation {
}
public static void displayPermutation(String s) {
- displayPermutation(" ", s);
+ displayPermutation("", s);
}
public static void displayPermutation(String s1, String s2) {
if (s2.equals("")) {
-
+ System.out.println(s1);
+ }
+ for (int i = 0; i < s2.length(); ++i) {
+ displayPermutation(s1.concat("" + s2.charAt(i)), s2.substring(0, i).concat(s2.substring(i + 1)));
}
}
}
diff --git a/Semester 3/Assignments/lab6_generics_CalebFontenot/Printed HTMLs/GenericStack.html b/Semester 3/Assignments/lab6_generics_CalebFontenot/Printed HTMLs/GenericStack.html
new file mode 100644
index 0000000..f42f5c6
--- /dev/null
+++ b/Semester 3/Assignments/lab6_generics_CalebFontenot/Printed HTMLs/GenericStack.html
@@ -0,0 +1,93 @@
+
+
+
+GenericStack.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/GenericStack.java |
+
+
+
+
+package edu.slcc.asdv.caleb.lab6_generics_calebfontenot;
+
+import java.util.ArrayList;
+import java.util.EmptyStackException;
+
+
+
+
+
+public class GenericStack<T> {
+
+ private T[] elements;
+ ArrayList<T> elementsList = new ArrayList<T>();
+ private int top;
+ static int size = 4;
+
+ public GenericStack(int size) {
+ elements = (T[]) new Object[size];
+ }
+ public GenericStack()
+ {
+ elements = (T[]) new Object[size];
+ }
+ public boolean push (T element) {
+ if (top == size) {
+ throw new StackOverflowError();
+ }
+ elements[top++] = element;
+ elementsList.add(element);
+ return true;
+ }
+
+ public T pop() {
+ if (top == 0) {
+ throw new EmptyStackException();
+ }
+ --top;
+ elementsList.remove(top);
+ return elements[top];
+ }
+
+ public T peek() {
+ if (top == 0) {
+ throw new EmptyStackException();
+ }
+ return elements[top - 1];
+ }
+ public boolean isEmpty() {
+ boolean returnBoolean = false;
+ if (top == 0) {
+ return true;
+ }
+ return returnBoolean;
+ }
+
+
+ @Override
+ public String toString()
+ {
+ String returnString = "";
+ for (int i = top -1; i >= 0; --i) {
+ returnString += elements[i].toString() + ", ";
+ }
+ return returnString;
+ }
+}
+
+
+
diff --git a/Semester 3/Assignments/lab6_generics_CalebFontenot/Printed HTMLs/Max.html b/Semester 3/Assignments/lab6_generics_CalebFontenot/Printed HTMLs/Max.html
new file mode 100644
index 0000000..d0a9a7b
--- /dev/null
+++ b/Semester 3/Assignments/lab6_generics_CalebFontenot/Printed HTMLs/Max.html
@@ -0,0 +1,70 @@
+
+
+
+Max.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/Max.java |
+
+
+
+
+
+package edu.slcc.asdv.caleb.lab6_generics_calebfontenot;
+
+
+ *
+ * @author caleb
+ */
+public class Max {
+
+ public static Comparable max(Comparable o1, Comparable o2)
+ {
+ if (o1.compareTo(o2) > 0) {
+ return o1;
+ } else {
+ return o2;
+ }
+ }
+ public static <E extends Comparable<E>> E maxSafe(E e1, E e2) {
+ if(e1.compareTo(e2) > 0) {
+ return e1;
+ } else {
+ return e2;
+ }
+ }
+
+ public static void main(String[] args)
+ {
+ System.out.println(max(1, 2));
+ try {
+ System.out.println(maxSafe(1, 2));
+ System.out.println(maxSafe("abc", "ABC"));
+ System.out.println();
+ //System.out.println(maxSafe(1, "two"));
+
+ GenericStack stackUnsafe = new GenericStack();
+ GenericStack<Integer> stackSafe = new GenericStack();
+ stackSafe.push(1); stackSafe.push(2);
+ System.out.println(stackSafe);
+ stackUnsafe.push(1); stackUnsafe.push("two");
+ System.out.println("This line compiles but crashes the program " + max(1, "two"));
+ } catch (ClassCastException e) {
+ System.err.println("RAW TYPES ARE UNSAFE " + e.getMessage()) ;
+ }
+ }
+}
+
+
+
diff --git a/Semester 3/Assignments/lab6_generics_CalebFontenot/Printed HTMLs/NoWildCard.html b/Semester 3/Assignments/lab6_generics_CalebFontenot/Printed HTMLs/NoWildCard.html
new file mode 100644
index 0000000..ed8f781
--- /dev/null
+++ b/Semester 3/Assignments/lab6_generics_CalebFontenot/Printed HTMLs/NoWildCard.html
@@ -0,0 +1,56 @@
+
+
+
+NoWildCard.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/NoWildCard.java |
+
+
+
+
+
+package edu.slcc.asdv.caleb.lab6_generics_calebfontenot;
+
+
+
+
+
+public class NoWildCard {
+
+ public static double max(GenericStack<Integer> stack) {
+ double max = Double.MIN_VALUE;
+
+ while (!stack.isEmpty()) {
+ double value = stack.pop().doubleValue();
+ if (value > max) {
+ max = value;
+ }
+ }
+ return max;
+ }
+
+ public static void main(String[] args) {
+ GenericStack<Integer> intStack = new GenericStack<>();
+ intStack.push(1);
+ intStack.push(2);
+ intStack.push(-2);
+ System.out.print("The max number is " + max(intStack));
+ }
+}
+
+
+
diff --git a/Semester 3/Assignments/lab6_generics_CalebFontenot/Printed HTMLs/WildCard.html b/Semester 3/Assignments/lab6_generics_CalebFontenot/Printed HTMLs/WildCard.html
new file mode 100644
index 0000000..122cc2a
--- /dev/null
+++ b/Semester 3/Assignments/lab6_generics_CalebFontenot/Printed HTMLs/WildCard.html
@@ -0,0 +1,60 @@
+
+
+
+WildCard.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/WildCard.java |
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package edu.slcc.asdv.caleb.lab6_generics_calebfontenot;
+
+
+
+
+
+public class WildCard {
+
+ public static double max(GenericStack<? extends Number> stack) {
+ double max = Double.MIN_VALUE;
+
+ while (!stack.isEmpty()) {
+ double value = stack.pop().doubleValue();
+ if (value > max) {
+ max = value;
+ }
+ }
+ return max;
+ }
+
+ public static void main(String[] args) {
+ GenericStack<Integer> intStack = new GenericStack<>();
+ intStack.push(1);
+ intStack.push(2);
+ intStack.push(-2);
+ System.out.print("The max number is " + max(intStack));
+ }
+}
+
+
+
diff --git a/Semester 3/Assignments/lab6_generics_CalebFontenot/Printed HTMLs/WildCard2.html b/Semester 3/Assignments/lab6_generics_CalebFontenot/Printed HTMLs/WildCard2.html
new file mode 100644
index 0000000..0c6027f
--- /dev/null
+++ b/Semester 3/Assignments/lab6_generics_CalebFontenot/Printed HTMLs/WildCard2.html
@@ -0,0 +1,49 @@
+
+
+
+WildCard2.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/WildCard2.java |
+
+
+
+
+
+package edu.slcc.asdv.caleb.lab6_generics_calebfontenot;
+
+
+
+
+
+public class WildCard2 {
+ public static void print(GenericStack<?> stack) {
+ while (!stack.isEmpty()) {
+ System.out.print(stack.pop() + " ");
+ }
+ }
+ public static void main(String[] args) {
+ GenericStack<Integer> intStack = new GenericStack<>();
+ intStack.push(1);
+ intStack.push(2);
+ intStack.push(-2);
+
+ print(intStack);
+ }
+}
+
+
+
diff --git a/Semester 3/Assignments/lab6_generics_CalebFontenot/Printed HTMLs/WildCardWithSuper.html b/Semester 3/Assignments/lab6_generics_CalebFontenot/Printed HTMLs/WildCardWithSuper.html
new file mode 100644
index 0000000..58dbf05
--- /dev/null
+++ b/Semester 3/Assignments/lab6_generics_CalebFontenot/Printed HTMLs/WildCardWithSuper.html
@@ -0,0 +1,52 @@
+
+
+
+WildCardWithSuper.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/WildCardWithSuper.java |
+
+
+
+
+
+package edu.slcc.asdv.caleb.lab6_generics_calebfontenot;
+
+
+
+
+
+public class WildCardWithSuper {
+ public static <T> void add(GenericStack<T> stack1, GenericStack<? super T> stack2) {
+ while(!stack1.isEmpty()) {
+ stack2.push(stack1.pop());
+ }
+ }
+
+ public static void main(String[] args) {
+ GenericStack<String> stack1 = new GenericStack<>();
+ GenericStack<Object> stack2 = new GenericStack<>();
+ stack2.push("one");
+ stack2.push(2);
+ stack1.push("one");
+
+ add(stack1, stack2);
+ WildCard2.print(stack2);
+ }
+}
+
+
+
diff --git a/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/GenericStack.java b/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/GenericStack.java
new file mode 100644
index 0000000..301244b
--- /dev/null
+++ b/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/GenericStack.java
@@ -0,0 +1,69 @@
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ */
+package edu.slcc.asdv.caleb.lab6_generics_calebfontenot;
+
+import java.util.ArrayList;
+import java.util.EmptyStackException;
+
+/**
+ *
+ * @author caleb
+ */
+public class GenericStack {
+
+ private T[] elements;
+ ArrayList elementsList = new ArrayList();
+ private int top;
+ static int size = 4;
+
+ public GenericStack(int size) {
+ elements = (T[]) new Object[size];
+ }
+ public GenericStack()
+ {
+ elements = (T[]) new Object[size];
+ }
+ public boolean push (T element) {
+ if (top == size) {
+ throw new StackOverflowError();
+ }
+ elements[top++] = element;
+ elementsList.add(element);
+ return true;
+ }
+
+ public T pop() {
+ if (top == 0) {
+ throw new EmptyStackException();
+ }
+ --top;
+ elementsList.remove(top);
+ return elements[top];
+ }
+
+ public T peek() {
+ if (top == 0) {
+ throw new EmptyStackException();
+ }
+ return elements[top - 1];
+ }
+ public boolean isEmpty() {
+ boolean returnBoolean = false;
+ if (top == 0) {
+ return true;
+ }
+ return returnBoolean;
+ }
+
+
+ @Override
+ public String toString()
+ {
+ String returnString = "";
+ for (int i = top -1; i >= 0; --i) {
+ returnString += elements[i].toString() + ", ";
+ }
+ return returnString;
+ }
+}
diff --git a/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/Max.java b/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/Max.java
index a19490a..57f5eb6 100644
--- a/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/Max.java
+++ b/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/Max.java
@@ -34,6 +34,12 @@ public class Max {
System.out.println(maxSafe("abc", "ABC"));
System.out.println();
//System.out.println(maxSafe(1, "two"));
+
+ GenericStack stackUnsafe = new GenericStack();
+ GenericStack stackSafe = new GenericStack();
+ stackSafe.push(1); stackSafe.push(2);
+ System.out.println(stackSafe);
+ stackUnsafe.push(1); stackUnsafe.push("two");
System.out.println("This line compiles but crashes the program " + max(1, "two"));
} catch (ClassCastException e) {
System.err.println("RAW TYPES ARE UNSAFE " + e.getMessage()) ;
diff --git a/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/NoWildCard.java b/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/NoWildCard.java
new file mode 100644
index 0000000..5d5e175
--- /dev/null
+++ b/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/NoWildCard.java
@@ -0,0 +1,32 @@
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package edu.slcc.asdv.caleb.lab6_generics_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+public class NoWildCard {
+
+ public static double max(GenericStack stack) {
+ double max = Double.MIN_VALUE;
+
+ while (!stack.isEmpty()) {
+ double value = stack.pop().doubleValue();
+ if (value > max) {
+ max = value;
+ }
+ }
+ return max;
+ }
+
+ public static void main(String[] args) {
+ GenericStack intStack = new GenericStack<>();
+ intStack.push(1);
+ intStack.push(2);
+ intStack.push(-2);
+ System.out.print("The max number is " + max(intStack));
+ }
+}
diff --git a/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/WildCard.java b/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/WildCard.java
new file mode 100644
index 0000000..334eafb
--- /dev/null
+++ b/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/WildCard.java
@@ -0,0 +1,32 @@
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package edu.slcc.asdv.caleb.lab6_generics_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+public class WildCard {
+
+ public static double max(GenericStack extends Number> stack) {
+ double max = Double.MIN_VALUE;
+
+ while (!stack.isEmpty()) {
+ double value = stack.pop().doubleValue();
+ if (value > max) {
+ max = value;
+ }
+ }
+ return max;
+ }
+
+ public static void main(String[] args) {
+ GenericStack intStack = new GenericStack<>();
+ intStack.push(1);
+ intStack.push(2);
+ intStack.push(-2);
+ System.out.print("The max number is " + max(intStack));
+ }
+}
diff --git a/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/WildCard2.java b/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/WildCard2.java
new file mode 100644
index 0000000..b27eff0
--- /dev/null
+++ b/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/WildCard2.java
@@ -0,0 +1,25 @@
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package edu.slcc.asdv.caleb.lab6_generics_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+public class WildCard2 {
+ public static void print(GenericStack> stack) {
+ while (!stack.isEmpty()) {
+ System.out.print(stack.pop() + " ");
+ }
+ }
+ public static void main(String[] args) {
+ GenericStack intStack = new GenericStack<>();
+ intStack.push(1);
+ intStack.push(2);
+ intStack.push(-2);
+
+ print(intStack);
+ }
+}
diff --git a/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/WildCardWithSuper.java b/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/WildCardWithSuper.java
new file mode 100644
index 0000000..6e6ce8e
--- /dev/null
+++ b/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/WildCardWithSuper.java
@@ -0,0 +1,28 @@
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package edu.slcc.asdv.caleb.lab6_generics_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+public class WildCardWithSuper {
+ public static void add(GenericStack stack1, GenericStack super T> stack2) {
+ while(!stack1.isEmpty()) {
+ stack2.push(stack1.pop());
+ }
+ }
+
+ public static void main(String[] args) {
+ GenericStack stack1 = new GenericStack<>();
+ GenericStack