diff --git a/.gitignore b/.gitignore index 4be9f73..1549133 100644 --- a/.gitignore +++ b/.gitignore @@ -169,3 +169,5 @@ /Semester 3/Assignments/SerialPog2/target/ /Semester 3/Assignments/SerialPogAnt/nbproject/private/ /Semester 3/Assignments/SerialPogAnt/build/ +/Semester 3/GenericStack/target/ +/Semester 3/Assignments/lab6_generics_CalebFontenot/target/ diff --git a/Semester 3/Assignments/MP2-chapter4_CalebFontenot/nbproject/build-impl.xml b/Semester 3/Assignments/MP2-chapter4_CalebFontenot/nbproject/build-impl.xml index 7f93bb7..19de470 100644 --- a/Semester 3/Assignments/MP2-chapter4_CalebFontenot/nbproject/build-impl.xml +++ b/Semester 3/Assignments/MP2-chapter4_CalebFontenot/nbproject/build-impl.xml @@ -120,7 +120,43 @@ is divided into following sections: - + + + + + + + + + + + + + + + + + + + + + + + + + + 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) + @@ -243,20 +279,6 @@ is divided into following sections: - - - - - - - - - - - - - - @@ -344,7 +366,7 @@ is divided into following sections: - + @@ -395,7 +417,7 @@ is divided into following sections: - + @@ -437,7 +459,7 @@ is divided into following sections: - + @@ -516,7 +538,7 @@ is divided into following sections: - + @@ -544,7 +566,7 @@ is divided into following sections: - + @@ -620,7 +642,7 @@ is divided into following sections: - + @@ -851,6 +873,9 @@ is divided into following sections: + + + @@ -900,7 +925,7 @@ is divided into following sections: - + @@ -934,7 +959,7 @@ is divided into following sections: - + @@ -966,7 +991,7 @@ is divided into following sections: - + @@ -1200,7 +1225,7 @@ is divided into following sections: To run this application from the command line without Ant, try: - java -jar "${dist.jar.resolved}" + ${platform.java} -jar "${dist.jar.resolved}" @@ -1302,8 +1327,8 @@ is divided into following sections: - - + + @@ -1496,16 +1521,19 @@ is divided into following sections: + + + - + - + - + diff --git a/Semester 3/Assignments/MP2-chapter4_CalebFontenot/nbproject/genfiles.properties b/Semester 3/Assignments/MP2-chapter4_CalebFontenot/nbproject/genfiles.properties index 7ceb0bc..030ec63 100644 --- a/Semester 3/Assignments/MP2-chapter4_CalebFontenot/nbproject/genfiles.properties +++ b/Semester 3/Assignments/MP2-chapter4_CalebFontenot/nbproject/genfiles.properties @@ -3,6 +3,6 @@ build.xml.script.CRC32=f4beac8b 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=14971581 -nbproject/build-impl.xml.script.CRC32=e3cc13c1 +nbproject/build-impl.xml.data.CRC32=1d3703fe +nbproject/build-impl.xml.script.CRC32=4d538bea nbproject/build-impl.xml.stylesheet.CRC32=12e0a6c2@1.107.0.48 diff --git a/Semester 3/Assignments/MP2-chapter4_CalebFontenot/nbproject/project.properties b/Semester 3/Assignments/MP2-chapter4_CalebFontenot/nbproject/project.properties index 3563b88..41139c7 100644 --- a/Semester 3/Assignments/MP2-chapter4_CalebFontenot/nbproject/project.properties +++ b/Semester 3/Assignments/MP2-chapter4_CalebFontenot/nbproject/project.properties @@ -37,8 +37,7 @@ includes=** # Non-JavaFX jar file creation is deactivated in JavaFX 2.0+ projects jar.archive.disabled=true jar.compress=false -javac.classpath=\ - ${libs.JavaFX20.classpath} +javac.classpath= # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false @@ -47,8 +46,8 @@ javac.modulepath= javac.processormodulepath= javac.processorpath=\ ${javac.classpath} -javac.source=20 -javac.target=20 +javac.source=1.8 +javac.target=1.8 javac.test.classpath=\ ${javac.classpath}:\ ${build.classes.dir} @@ -108,7 +107,7 @@ manifest.custom.permissions= manifest.file=manifest.mf meta.inf.dir=${src.dir}/META-INF mkdist.disabled=false -platform.active=default_platform +platform.active=JDK_1.8 run.classpath=\ ${dist.jar}:\ ${javac.classpath}:\ diff --git a/Semester 3/Assignments/MP2-chapter4_CalebFontenot/nbproject/project.xml b/Semester 3/Assignments/MP2-chapter4_CalebFontenot/nbproject/project.xml index 3fbfa4f..67bdf69 100644 --- a/Semester 3/Assignments/MP2-chapter4_CalebFontenot/nbproject/project.xml +++ b/Semester 3/Assignments/MP2-chapter4_CalebFontenot/nbproject/project.xml @@ -14,6 +14,7 @@ MP2-chapter4_CalebFontenot + diff --git a/Semester 3/Assignments/lab6_generics_CalebFontenot/labGenericsII.pdf b/Semester 3/Assignments/lab6_generics_CalebFontenot/labGenericsII.pdf new file mode 100644 index 0000000..32ea311 Binary files /dev/null and b/Semester 3/Assignments/lab6_generics_CalebFontenot/labGenericsII.pdf differ diff --git a/Semester 3/Assignments/lab6_generics_CalebFontenot/pom.xml b/Semester 3/Assignments/lab6_generics_CalebFontenot/pom.xml new file mode 100644 index 0000000..09dd7b5 --- /dev/null +++ b/Semester 3/Assignments/lab6_generics_CalebFontenot/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + edu.slcc.asdv.caleb + lab6_generics_CalebFontenot + 1.0-SNAPSHOT + jar + + UTF-8 + 17 + 17 + edu.slcc.asdv.caleb.lab6_generics_calebfontenot.Lab6_generics_CalebFontenot + + \ No newline at end of file diff --git a/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/Lab6_generics_CalebFontenot.java b/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/Lab6_generics_CalebFontenot.java new file mode 100644 index 0000000..d5310d3 --- /dev/null +++ b/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/Lab6_generics_CalebFontenot.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package edu.slcc.asdv.caleb.lab6_generics_calebfontenot; + +/** + * + * @author caleb + */ +public class Lab6_generics_CalebFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} 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 new file mode 100644 index 0000000..a19490a --- /dev/null +++ b/Semester 3/Assignments/lab6_generics_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/lab6_generics_calebfontenot/Max.java @@ -0,0 +1,42 @@ +/* + * 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 Max { + + public static Comparable max(Comparable o1, Comparable o2) + { + if (o1.compareTo(o2) > 0) { + return o1; + } else { + return o2; + } + } + public static > 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")); + 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/GenericStack/pom.xml b/Semester 3/GenericStack/pom.xml new file mode 100644 index 0000000..afb0805 --- /dev/null +++ b/Semester 3/GenericStack/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + edu.slcc.asdv.caleb + GenericStack + 1.0-SNAPSHOT + jar + + UTF-8 + 17 + 17 + edu.slcc.asdv.caleb.genericstack.GenericStack + + \ No newline at end of file diff --git a/Semester 3/GenericStack/src/main/java/edu/slcc/asdv/caleb/genericstack/GenericStack.java b/Semester 3/GenericStack/src/main/java/edu/slcc/asdv/caleb/genericstack/GenericStack.java new file mode 100644 index 0000000..ca40c1a --- /dev/null +++ b/Semester 3/GenericStack/src/main/java/edu/slcc/asdv/caleb/genericstack/GenericStack.java @@ -0,0 +1,63 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ +package edu.slcc.asdv.caleb.genericstack; + +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]; + } + + + + @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/GenericStack/src/main/java/edu/slcc/asdv/caleb/genericstack/Max.java b/Semester 3/GenericStack/src/main/java/edu/slcc/asdv/caleb/genericstack/Max.java new file mode 100644 index 0000000..7e074e4 --- /dev/null +++ b/Semester 3/GenericStack/src/main/java/edu/slcc/asdv/caleb/genericstack/Max.java @@ -0,0 +1,23 @@ +/* + * 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.genericstack; + +/** + * + * @author caleb + */ +public class Max { + public static E max(E e1, E e2) { + return e1.compareTo(e2) >= 0 ? e1 : e2; + } + public static void main(String[] args) + { + Object o1 = new Object(); + Object o2 = new Object(); + System.out.println(Max.max(o1, o2)); + System.out.println(Max.max(2, 4)); + System.out.println(Max.max("abc", "defg")); + } +} diff --git a/Semester 3/GenericStack/src/main/java/edu/slcc/asdv/caleb/genericstack/TestStack.java b/Semester 3/GenericStack/src/main/java/edu/slcc/asdv/caleb/genericstack/TestStack.java new file mode 100644 index 0000000..6167b91 --- /dev/null +++ b/Semester 3/GenericStack/src/main/java/edu/slcc/asdv/caleb/genericstack/TestStack.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.genericstack; + +/** + * + * @author caleb + */ +public class TestStack { + public static void main(String[] args) + { + GenericStack gsi = new GenericStack(4); + + gsi.push(10); + gsi.push(20); + // gsi.push(30); + //gsi.push(40); + //gsi.pop(); + //gsi.push(50); + + System.out.println(gsi.toString()); + } +} diff --git a/Semester 3/mavenproject1/pom.xml b/Semester 3/mavenproject1/pom.xml new file mode 100644 index 0000000..576c1cc --- /dev/null +++ b/Semester 3/mavenproject1/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + edu.slcc.asdv.caleb + mavenproject1 + 1.0-SNAPSHOT + jar + + UTF-8 + 17 + 17 + edu.slcc.asdv.caleb.mavenproject1.Mavenproject1 + + \ No newline at end of file diff --git a/Semester 3/mavenproject1/src/main/java/edu/slcc/asdv/caleb/mavenproject1/GenericsTest.java b/Semester 3/mavenproject1/src/main/java/edu/slcc/asdv/caleb/mavenproject1/GenericsTest.java new file mode 100644 index 0000000..7f58dfc --- /dev/null +++ b/Semester 3/mavenproject1/src/main/java/edu/slcc/asdv/caleb/mavenproject1/GenericsTest.java @@ -0,0 +1,43 @@ +/* + * 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.mavenproject1; + +import java.util.ArrayList; + +/** + * + * @author caleb + */ +public class GenericsTest { + public static int f3(ArrayList list) { + return 1; + } + public static int f1(ArrayList list) { + return 1; + } + + public static void f2(Number n) { + + } + void f5() { + + } + + public static void main(String[] args) + { + + ArrayList l1 = new ArrayList(); + f3(l1); + Integer i = 10; + f2(i); + ArrayList l2 = l1; + ArrayList l3 = l1; + f3(i); + f3(new ArrayList()); + + Object o = new A(); + f5((A) ) + } +} diff --git a/Semester 3/mavenproject1/src/main/java/edu/slcc/asdv/caleb/mavenproject1/Mavenproject1.java b/Semester 3/mavenproject1/src/main/java/edu/slcc/asdv/caleb/mavenproject1/Mavenproject1.java new file mode 100644 index 0000000..8d11d98 --- /dev/null +++ b/Semester 3/mavenproject1/src/main/java/edu/slcc/asdv/caleb/mavenproject1/Mavenproject1.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package edu.slcc.asdv.caleb.mavenproject1; + +/** + * + * @author caleb + */ +public class Mavenproject1 { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +}