diff --git a/.gitignore b/.gitignore index 0b5c3ba..ccd0144 100644 --- a/.gitignore +++ b/.gitignore @@ -117,3 +117,5 @@ /Semester 2/Assignments/lab6-Exceptions_CalebFontenot/target/ /Semester 2/Assignments/fileClassTest/target/ /Semester 2/Assignments/lab7_CalebFontenot/target/ +/Semester 2/Assignments/lab8_CalebFontenot/target/ +/Semester 2/Assignments/lab8_2_CalebFontenot/target/ diff --git a/Semester 2/Assignments/AbstractMethod/pom.xml b/Semester 2/Assignments/AbstractMethod/pom.xml new file mode 100644 index 0000000..45b3dd8 --- /dev/null +++ b/Semester 2/Assignments/AbstractMethod/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + com.calebfontenot + AbstractMethod + 1.0-SNAPSHOT + jar + + UTF-8 + 17 + 17 + com.calebfontenot.abstractmethod.AbstractMethod + + \ No newline at end of file diff --git a/Semester 2/Assignments/AbstractMethod/src/main/java/com/calebfontenot/abstractmethod/AbstractMethod.java b/Semester 2/Assignments/AbstractMethod/src/main/java/com/calebfontenot/abstractmethod/AbstractMethod.java new file mode 100644 index 0000000..4c4a0fb --- /dev/null +++ b/Semester 2/Assignments/AbstractMethod/src/main/java/com/calebfontenot/abstractmethod/AbstractMethod.java @@ -0,0 +1,67 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package com.calebfontenot.abstractmethod; + +/** + * + * @author caleb + */ +public class AbstractMethod { +} +public abstract class A { + abstract void f1(); + public static void main(String[] args) + { + A a = new B(); + b.f1(); + //A a = new B(); + a.f1(); + D d = new D(); + d.f1(); + d.f2(); + A[] a1 = new A[3]; + A[] a1= new A[2]; + } +} + +class B extends A { + @Override + void f1() { + System.out.println("f1"); + } +} + +class C extends A { + @Override + void f2() { + System.out.println("f2"); + } +} + +class D extends C { + void f3() { + System.out.println("f3"); + } +} + +abstract class E extends B { + @Override + void f1() { + System.out.println("f1"); + } + @Override + void x() { + System.out.println("x"); + } +} +abstract class F extends A { + @Override + void f1() { + throw new UnsupportedOperationException("Not supported yet."); + } + @Override + abstract void x(); + } +} \ No newline at end of file diff --git a/Semester 2/Assignments/AbstractMethod/src/main/java/com/calebfontenot/abstractmethod/LargestNumbers.java b/Semester 2/Assignments/AbstractMethod/src/main/java/com/calebfontenot/abstractmethod/LargestNumbers.java new file mode 100644 index 0000000..2bfabb2 --- /dev/null +++ b/Semester 2/Assignments/AbstractMethod/src/main/java/com/calebfontenot/abstractmethod/LargestNumbers.java @@ -0,0 +1,39 @@ +/* + * 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 com.calebfontenot.abstractmethod; + +/** + * + * @author caleb + */ +import java.util.ArrayList; +import java.math.*; + +public class LargestNumbers { + public static void main(String[] args) { + ArrayList list = new ArrayList(); + list.add(45); // Add an integer + list.add(3445.53); // Add a double + // Add a BigInteger + list.add(new BigInteger("3432323234344343101")); + // Add a BigDecimal + list.add(new BigDecimal("2.0909090989091343433344343")); + + System.out.println("The largest number is " + + getLargestNumber(list)); + } + + public static Number getLargestNumber(ArrayList list) { + if (list == null || list.size() == 0) + return null; + + Number number = list.get(0); + for (int i = 1; i < list.size(); i++) + if (number.doubleValue() < list.get(i).doubleValue()) + number = list.get(i); + + return number; + } +} \ No newline at end of file diff --git a/Semester 2/Assignments/AbstractMethod/src/main/java/com/calebfontenot/abstractmethod/TestCalendar.java b/Semester 2/Assignments/AbstractMethod/src/main/java/com/calebfontenot/abstractmethod/TestCalendar.java new file mode 100644 index 0000000..f5c58f9 --- /dev/null +++ b/Semester 2/Assignments/AbstractMethod/src/main/java/com/calebfontenot/abstractmethod/TestCalendar.java @@ -0,0 +1,48 @@ +/* + * 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 com.calebfontenot.abstractmethod; + +/** + * + * @author caleb + */ +import java.util.*; + +public class TestCalendar { + + public static void main(String[] args) + { + // Construct a Gregorian calendar for the current date and time + Calendar calendar = new GregorianCalendar(); + System.out.println("Current time is " + new Date()); + System.out.println("YEAR: " + calendar.get(Calendar.YEAR)); + System.out.println("MONTH: " + calendar.get(Calendar.MONTH)); + System.out.println("DATE: " + calendar.get(Calendar.DATE)); + System.out.println("HOUR: " + calendar.get(Calendar.HOUR)); + System.out.println("HOUR_OF_DAY: " + + calendar.get(Calendar.HOUR_OF_DAY)); + System.out.println("MINUTE: " + calendar.get(Calendar.MINUTE)); + System.out.println("SECOND: " + calendar.get(Calendar.SECOND)); + System.out.println("DAY_OF_WEEK: " + + calendar.get(Calendar.DAY_OF_WEEK)); + System.out.println("DAY_OF_MONTH: " + + calendar.get(Calendar.DAY_OF_MONTH)); + System.out.println("DAY_OF_YEAR: " + + calendar.get(Calendar.DAY_OF_YEAR)); + System.out.println("WEEK_OF_MONTH: " + + calendar.get(Calendar.WEEK_OF_MONTH)); + System.out.println("WEEK_OF_YEAR: " + + calendar.get(Calendar.WEEK_OF_YEAR)); + System.out.println("AM_PM: " + calendar.get(Calendar.AM_PM)); + + // Construct a calendar for September 11, 2001 + Calendar calendar1 = new GregorianCalendar(2001, 8, 11); + String[] dayNameOfWeek = {"Sunday", "Monday", "Tuesday", "Wednesday", + "Thursday", "Friday", "Saturday"}; + System.out.println("September 11, 2001 is a " + + dayNameOfWeek[calendar1.get(Calendar.DAY_OF_WEEK) - 1]); + System.out.println(calendar1.get(Calendar.MONTH)); + } +} diff --git a/Semester 2/Assignments/AbstractMethod/target/classes/.netbeans_automatic_build b/Semester 2/Assignments/AbstractMethod/target/classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29 diff --git a/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/A.class b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/A.class new file mode 100644 index 0000000..9e9d346 Binary files /dev/null and b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/A.class differ diff --git a/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/AbstractMethod.class b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/AbstractMethod.class new file mode 100644 index 0000000..72e6608 Binary files /dev/null and b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/AbstractMethod.class differ diff --git a/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/Animal.class b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/Animal.class new file mode 100644 index 0000000..835894b Binary files /dev/null and b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/Animal.class differ diff --git a/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/Apple.class b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/Apple.class new file mode 100644 index 0000000..b115be7 Binary files /dev/null and b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/Apple.class differ diff --git a/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/B.class b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/B.class new file mode 100644 index 0000000..0133667 Binary files /dev/null and b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/B.class differ diff --git a/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/C.class b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/C.class new file mode 100644 index 0000000..dae2656 Binary files /dev/null and b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/C.class differ diff --git a/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/Chicken.class b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/Chicken.class new file mode 100644 index 0000000..d4d07ae Binary files /dev/null and b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/Chicken.class differ diff --git a/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/D.class b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/D.class new file mode 100644 index 0000000..6aa051b Binary files /dev/null and b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/D.class differ diff --git a/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/E.class b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/E.class new file mode 100644 index 0000000..277a488 Binary files /dev/null and b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/E.class differ diff --git a/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/Edible.class b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/Edible.class new file mode 100644 index 0000000..ad86c77 Binary files /dev/null and b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/Edible.class differ diff --git a/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/F.class b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/F.class new file mode 100644 index 0000000..bfe9864 Binary files /dev/null and b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/F.class differ diff --git a/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/Fruit.class b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/Fruit.class new file mode 100644 index 0000000..0501cad Binary files /dev/null and b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/Fruit.class differ diff --git a/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/LargestNumbers.class b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/LargestNumbers.class new file mode 100644 index 0000000..0de0496 Binary files /dev/null and b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/LargestNumbers.class differ diff --git a/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/Orange.class b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/Orange.class new file mode 100644 index 0000000..d12037e Binary files /dev/null and b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/Orange.class differ diff --git a/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/TestCalendar.class b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/TestCalendar.class new file mode 100644 index 0000000..da6d930 Binary files /dev/null and b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/TestCalendar.class differ diff --git a/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/Tiger.class b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/Tiger.class new file mode 100644 index 0000000..60fb5f9 Binary files /dev/null and b/Semester 2/Assignments/AbstractMethod/target/classes/com/calebfontenot/abstractmethod/Tiger.class differ diff --git a/Semester 2/Assignments/AbstractMethod/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/Semester 2/Assignments/AbstractMethod/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/Semester 2/Assignments/AbstractMethod/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/Semester 2/Assignments/AbstractMethod/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..2b078b0 --- /dev/null +++ b/Semester 2/Assignments/AbstractMethod/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,2 @@ +/home/caleb/ASDV-WebDev/Assignments/JavaScript/AbstractMethod/src/main/java/com/calebfontenot/abstractmethod/LargestNumbers.java +/home/caleb/ASDV-WebDev/Assignments/JavaScript/AbstractMethod/src/main/java/com/calebfontenot/abstractmethod/AbstractMethod.java diff --git a/Semester 2/Assignments/AbstractMethod/target/test-classes/.netbeans_automatic_build b/Semester 2/Assignments/AbstractMethod/target/test-classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29 diff --git a/Semester 2/Assignments/lab8_2_CalebFontenot/labInterfaces2.pdf b/Semester 2/Assignments/lab8_2_CalebFontenot/labInterfaces2.pdf new file mode 100644 index 0000000..fbc3695 Binary files /dev/null and b/Semester 2/Assignments/lab8_2_CalebFontenot/labInterfaces2.pdf differ diff --git a/Semester 2/Assignments/lab8_2_CalebFontenot/pom.xml b/Semester 2/Assignments/lab8_2_CalebFontenot/pom.xml new file mode 100644 index 0000000..63f81be --- /dev/null +++ b/Semester 2/Assignments/lab8_2_CalebFontenot/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + com.calebfontenot + lab8_2_CalebFontenot + 1.0-SNAPSHOT + jar + + UTF-8 + 17 + 17 + com.calebfontenot.lab8_2_calebfontenot.Lab8_2_CalebFontenot + + \ No newline at end of file diff --git a/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/Lab8_2_CalebFontenot.java b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/Lab8_2_CalebFontenot.java new file mode 100644 index 0000000..c4f3a69 --- /dev/null +++ b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/Lab8_2_CalebFontenot.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package com.calebfontenot.lab8_2_calebfontenot; + +/** + * + * @author caleb + */ +public class Lab8_2_CalebFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/NumberX.java b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/NumberX.java new file mode 100644 index 0000000..a6ae12c --- /dev/null +++ b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/NumberX.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 com.calebfontenot.lab8_2_calebfontenot; + +/** + * + * @author caleb + */ +public class NumberX implements Comparable { + int x; + public NumberX(int x) { + this.x = x; + } + @Override + public int compareTo(NumberX o) + { + if (this.x == o.x) { + return 0; + } else if (this.x > o.x) { + return 1; + } else { + return -1; + } + } + public static void main(String[] args) + { + NumberX x1 = new NumberX(10); + NumberX x2 = new NumberX(20); + NumberX x3 = new NumberX(30); + System.out.println(x1.compareTo(x2)); + System.out.println(x1.compareTo(x3)); + System.out.println(x2.compareTo(x1)); + } + + @Override + public String toString() + { + return "NumberX{" + "x=" + x + '}'; + } +} diff --git a/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/SortComparableObjects.java b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/SortComparableObjects.java new file mode 100644 index 0000000..9899f4c --- /dev/null +++ b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/SortComparableObjects.java @@ -0,0 +1,34 @@ +/* + * 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 com.calebfontenot.lab8_2_calebfontenot; + +/** + * + * @author caleb + */ +import java.math.*; +import java.util.Arrays; + +public class SortComparableObjects { + public static void main(String[] args) { + NumberX[] numbers = {new NumberX(20), new NumberX(1), new NumberX(3)}; + Arrays.sort(numbers); + for (NumberX number: numbers) { + System.out.println(number); + } + String[] cities = {"Savannah", "Boston", "Atlanta", "Tampa"}; + java.util.Arrays.sort(cities); + for (String city: cities) + System.out.print(city + " "); + System.out.println(); + + BigInteger[] hugeNumbers = {new BigInteger("2323231092923992"), + new BigInteger("432232323239292"), + new BigInteger("54623239292")}; + java.util.Arrays.sort(hugeNumbers); + for (BigInteger number: hugeNumbers) + System.out.print(number + " "); + } +} \ No newline at end of file diff --git a/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/Interface1.java b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/Interface1.java new file mode 100644 index 0000000..1d389ec --- /dev/null +++ b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/Interface1.java @@ -0,0 +1,13 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package com.calebfontenot.lab8_2_calebfontenot.interfacesGrouped; + +/** + * + * @author caleb + */ +public interface Interface1 { + abstract void I1(); +} diff --git a/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/Interface2.java b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/Interface2.java new file mode 100644 index 0000000..0eb6b70 --- /dev/null +++ b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/Interface2.java @@ -0,0 +1,13 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package com.calebfontenot.lab8_2_calebfontenot.interfacesGrouped; + +/** + * + * @author caleb + */ +public interface Interface2 { + abstract void I2(); +} diff --git a/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/InterfaceGrouped1.java b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/InterfaceGrouped1.java new file mode 100644 index 0000000..5194162 --- /dev/null +++ b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/InterfaceGrouped1.java @@ -0,0 +1,23 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package com.calebfontenot.lab8_2_calebfontenot.interfacesGrouped; + +/** + * + * @author caleb + */ +public interface InterfaceGrouped1 extends Interface1, Interface2 { + int x = 10; //public static shared by all who implement or extend the interface + abstract void IG1(); + + static void staticMethodOfInterface() { + System.out.println("A static method inside an Interface is shared by every class" + + " that implements Interface InterfaceGrouped1."); + } + default void defaultMethodOfInterface() { + System.out.println("The default implementation was used as there was no overriding" + + " by a class that was implemented the Interface InterfaceGrouped1."); + } +} diff --git a/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/TestInterfaces.java b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/TestInterfaces.java new file mode 100644 index 0000000..97f0a05 --- /dev/null +++ b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/TestInterfaces.java @@ -0,0 +1,39 @@ +/* + * 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 com.calebfontenot.lab8_2_calebfontenot.interfacesGrouped; + +/** + * + * @author caleb + */ +public class TestInterfaces implements InterfaceGrouped1 { + @Override + public void IG1() { + System.out.println("TestInterfaces:IG1()"); + } + @Override + public void I1() { + System.out.println("TestInterfaces:I1()"); + } + @Override + public void I2() { + System.out.println("testInterfaces:I2()"); + } + @Override + public void defaultMethodOfInterface() { + System.out.println("overriden implementation of defaultMethodOfInterface"); + } + public static void main(String[] args) + { + System.out.println(TestInterfaces.x); + + InterfaceGrouped1.staticMethodOfInterface(); + TestInterfaces ti = new TestInterfaces(); + ti.I1(); + ti.I2(); + ti.IG1(); + ti.defaultMethodOfInterface(); + } +} diff --git a/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/European.java b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/European.java new file mode 100644 index 0000000..6d56c80 --- /dev/null +++ b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/European.java @@ -0,0 +1,14 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package com.calebfontenot.lab8_2_calebfontenot.interfacesGrouped.fun; + +/** + * + * @author caleb + */ +public interface European extends Language, Religion, War { + void whatCountry(); + +} diff --git a/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/French.java b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/French.java new file mode 100644 index 0000000..e8d4dd9 --- /dev/null +++ b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/French.java @@ -0,0 +1,41 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package com.calebfontenot.lab8_2_calebfontenot.interfacesGrouped.fun; + +/** + * + * @author caleb + */ +public class French implements European +{ + @Override + public void whatCountry() { + System.out.println("+++ I am from France! +++"); + } + + @Override + public void speakLanguage() + { + System.out.println("speak French"); + } + + @Override + public void practiceReligion() + { + System.out.println("Roman Catholic"); + } + + @Override + public void WWI() + { + System.out.println("In WW1 the French won -- Allies!"); + } + + @Override + public void WWII() + { + System.out.println("In WW2 the French wan -- Allies!"); + } +} diff --git a/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/German.java b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/German.java new file mode 100644 index 0000000..4d96c8c --- /dev/null +++ b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/German.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 com.calebfontenot.lab8_2_calebfontenot.interfacesGrouped.fun; + +/** + * + * @author caleb + */ +public class German implements European { + + @Override + public void whatCountry() + { + System.out.println("+++ I am from Germany! +++"); + } + @Override + public void speakLanguage() + { + System.out.println("speak German"); + } + + @Override + public void practiceReligion() + { + System.out.println("Protestant"); + } + + @Override + public void WWI() + { + System.out.println("in WW1 the Germans lost -- Axis!"); + } + + + @Override + public void WWII() + { + System.out.println("in WW2 the Germans lost -- Axis!"); + } + +} diff --git a/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/Italian.java b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/Italian.java new file mode 100644 index 0000000..6cf6c9b --- /dev/null +++ b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/Italian.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 com.calebfontenot.lab8_2_calebfontenot.interfacesGrouped.fun; + +/** + * + * @author caleb + */ +public class Italian implements European { + + @Override + public void whatCountry() + { + System.out.println("+++ I am from Itally! +++"); + } + + @Override + public void speakLanguage() + { + System.out.println("speak Italian"); + } + + @Override + public void practiceReligion() + { + System.out.println("paganism"); + } + + @Override + public void WWI() + { + System.out.println("in WW1 the Italians won -- Allies!"); + } + + @Override + public void WWII() + { + System.out.println("In WW2 the Italians lost -- Axis!"); + } + +} diff --git a/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/Language.java b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/Language.java new file mode 100644 index 0000000..72aece1 --- /dev/null +++ b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/Language.java @@ -0,0 +1,13 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package com.calebfontenot.lab8_2_calebfontenot.interfacesGrouped.fun; + +/** + * + * @author caleb + */ +public interface Language { + void speakLanguage(); +} diff --git a/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/Religion.java b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/Religion.java new file mode 100644 index 0000000..402fd05 --- /dev/null +++ b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/Religion.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package com.calebfontenot.lab8_2_calebfontenot.interfacesGrouped.fun; + +/** + * + * @author caleb + */ +public interface Religion { + public void practiceReligion(); + default void beforeChrist() { + System.out.println("paganism"); + } +} diff --git a/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/Russian.java b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/Russian.java new file mode 100644 index 0000000..4275223 --- /dev/null +++ b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/Russian.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 com.calebfontenot.lab8_2_calebfontenot.interfacesGrouped.fun; + +/** + * + * @author caleb + */ +public class Russian implements European { + + @Override + public void whatCountry() + { + System.out.println("+++ I am from Russia! +++"); + } + + @Override + public void speakLanguage() + { + System.out.println("speak Russian"); + } + + @Override + public void practiceReligion() + { + System.out.println("Orthodox"); + } + + @Override + public void WWI() + { + System.out.println("In WW1 the Russians won -- Allies!"); + } + + @Override + public void WWII() + { + System.out.println("In WW2 the Russians won -- Allies!"); + } + +} diff --git a/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/TestEuropeans.java b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/TestEuropeans.java new file mode 100644 index 0000000..50a93fa --- /dev/null +++ b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/TestEuropeans.java @@ -0,0 +1,60 @@ +/* + * 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 com.calebfontenot.lab8_2_calebfontenot.interfacesGrouped.fun; + +import java.util.ArrayList; + +/** + * + * @author caleb + */ +public class TestEuropeans { + + public static void testWithArrayList() + { + ArrayList europeans = new ArrayList(); + + europeans.add(new French()); + europeans.add(new German()); + europeans.add(new Russian()); + europeans.add(new Italian()); + + for(European man: europeans) { + man.whatCountry(); + man.beforeChrist(); + man.practiceReligion(); + man.speakLanguage(); + man.WWI(); + man.WWII(); + } + } + public static void testWithArrayOfObjects() { + European[] europeans = { + new French(), + new German(), + new Russian(), + new Italian() + }; + for (European person: europeans) { + person.whatCountry(); + person.beforeChrist(); + person.practiceReligion(); + person.speakLanguage(); + person.WWI(); + person.WWII(); + } + } + public static void testWithArrayOfInterfaces() { + Interface[] interfaceArr = { + + } + } + public static void main(String[] args) + { + testWithArrayList(); + System.out.println("-------------------"); + testWithArrayOfObjects(); + } +} diff --git a/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/War.java b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/War.java new file mode 100644 index 0000000..f49ed3f --- /dev/null +++ b/Semester 2/Assignments/lab8_2_CalebFontenot/src/main/java/com/calebfontenot/lab8_2_calebfontenot/interfacesGrouped/fun/War.java @@ -0,0 +1,14 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package com.calebfontenot.lab8_2_calebfontenot.interfacesGrouped.fun; + +/** + * + * @author caleb + */ +public interface War { + void WWI(); + void WWII(); +} diff --git a/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Animal.html b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Animal.html new file mode 100644 index 0000000..4590f64 --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Animal.html @@ -0,0 +1,38 @@ + + + +Animal.java + + + + +
/home/caleb/ASDV-Java/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Animal.java
+
+/*
+ * 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 com.calebfontenot.lab8_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+public abstract class Animal {
+    public abstract String sound();
+}
+
+
+ diff --git a/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Apple.html b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Apple.html new file mode 100644 index 0000000..c7b5377 --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Apple.html @@ -0,0 +1,44 @@ + + + +Apple.java + + + + +
/home/caleb/ASDV-Java/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Apple.java
+
+/*
+ * 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 com.calebfontenot.lab8_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+public class Apple extends Fruit{
+
+    @Override
+    public String howToEat()
+    {
+        return "Apple: Make apple cider.";
+    }
+}
+
+
+ diff --git a/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Brocoli.html b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Brocoli.html new file mode 100644 index 0000000..8c73102 --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Brocoli.html @@ -0,0 +1,42 @@ + + + +Brocoli.java + + + + +
/home/caleb/ASDV-Java/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Brocoli.java
+
+/*
+ * 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 com.calebfontenot.lab8_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+public class Brocoli extends Fruit {
+    @Override
+    public String howToEat() {
+        return "Brocolli: Steam it";
+    }
+}
+
+
+ diff --git a/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Chicken.html b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Chicken.html new file mode 100644 index 0000000..187a942 --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Chicken.html @@ -0,0 +1,47 @@ + + + +Chicken.java + + + + +
/home/caleb/ASDV-Java/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Chicken.java
+
+/*
+ * 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 com.calebfontenot.lab8_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+public class Chicken extends Animal implements Edible {
+    @Override
+    public String sound() {
+        return "Chicken: cock-a-doodle-do!";
+    }
+    @Override 
+    public String howToEat() {
+        return "Chicken: Fry it!";
+    }
+}
+
+
+ diff --git a/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Duck.html b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Duck.html new file mode 100644 index 0000000..5205b0d --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Duck.html @@ -0,0 +1,47 @@ + + + +Duck.java + + + + +
/home/caleb/ASDV-Java/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Duck.java
+
+/*
+ * 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 com.calebfontenot.lab8_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+public class Duck extends Animal implements Edible {
+    @Override
+    public String howToEat() {
+        return "Duck: Roast it!";
+    }
+    
+    @Override
+    public String sound() {
+        return "Duck: Quack! Quack! Quack!";
+    }
+}
+
+
+ diff --git a/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Edible.html b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Edible.html new file mode 100644 index 0000000..da3086d --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Edible.html @@ -0,0 +1,39 @@ + + + +Edible.java + + + + +
/home/caleb/ASDV-Java/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Edible.java
+
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
+ */
+package com.calebfontenot.lab8_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+public interface Edible {
+    String howToEat();
+}
+
+
+ diff --git a/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Fruit.html b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Fruit.html new file mode 100644 index 0000000..14fb4e0 --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Fruit.html @@ -0,0 +1,37 @@ + + + +Fruit.java + + + + +
/home/caleb/ASDV-Java/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Fruit.java
+
+/*
+ * 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 com.calebfontenot.lab8_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+public abstract class Fruit implements Edible{
+    
+}
+
+
+ diff --git a/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/House.html b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/House.html new file mode 100644 index 0000000..8035374 --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/House.html @@ -0,0 +1,164 @@ + + + +House.java + + + + +
/home/caleb/ASDV-Java/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/House.java
+
+/*
+ * 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 com.calebfontenot.lab8_calebfontenot;
+
+import java.util.Date;
+
+/**
+ *
+ * @author caleb
+ */
+public class House implements Cloneable{
+    
+    private int id;
+    private double area;
+    private Date whenBuilt;
+
+    public House(int id, double area)
+    {
+        this.id = id;
+        this.area = area;
+        this.whenBuilt = new Date();
+    }
+
+    @Override
+    protected Object clone() throws CloneNotSupportedException
+    {
+        Object o = super.clone();
+        ((House) o).whenBuilt = new Date(this.whenBuilt.getTime());
+        return o;
+    }
+
+    
+    
+    /**
+     * Get the value of whenBuilt
+     *
+     * @return the value of whenBuilt
+     */
+    public Date getWhenBuilt()
+    {
+        return whenBuilt;
+    }
+
+    /**
+     * Set the value of whenBuilt
+     *
+     * @param whenBuilt new value of whenBuilt
+     */
+    public void setWhenBuilt(Date whenBuilt)
+    {
+        this.whenBuilt = whenBuilt;
+    }
+
+
+    /**
+     * Get the value of area
+     *
+     * @return the value of area
+     */
+    public double getArea()
+    {
+        return area;
+    }
+
+    /**
+     * Set the value of area
+     *
+     * @param area new value of area
+     */
+    public void setArea(double area)
+    {
+        this.area = area;
+    }
+
+    /**
+     * Get the value of id
+     *
+     * @return the value of id
+     */
+    public int getId()
+    {
+        return id;
+    }
+
+    /**
+     * Set the value of id
+     *
+     * @param id new value of id
+     */
+    public void setId(int id)
+    {
+        this.id = id;
+    }
+
+    @Override
+    public String toString()
+    {
+        return "House{" + "id=" + id + ", area=" + area + ", whenBuilt=" + whenBuilt + '}';
+    }
+    
+    public int compareTo(House o) {
+        if (this.getId() == o.getId() &&
+                this.getArea() == o.getArea() &&
+                this.getWhenBuilt().equals(o.getWhenBuilt())) {
+            return 0;
+        }
+        if (this.area > o.area) {
+            return 1;
+        } else if (this.area < o.area) {
+            return -1;
+        } else {
+            return -2; // Same area for this and o but either var id or var whenBuilt are different
+        }
+    }
+
+public static void main(String[] args) throws CloneNotSupportedException, InterruptedException {
+    House house1 = new House(1, 1000);
+    House house2 = (House) house1.clone();
+    house2.whenBuilt.setDate(8);
+    System.out.println(house1);
+    System.out.println(house2);
+    House house3 = new House(3, 2000);
+    House house4 = new House(4, 2000);
+    System.out.println("house 1 and house 2 are identical: "+ house1.compareTo(house2));
+    System.out.println("house 3 and house 3 have the same area: " + house3.compareTo(house4));
+    System.out.println("House 4 is harger than house 2: " + house4.compareTo(house2));
+    
+
+}
+    
+}
+
+
+ diff --git a/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Orange.html b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Orange.html new file mode 100644 index 0000000..6b521bc --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Orange.html @@ -0,0 +1,45 @@ + + + +Orange.java + + + + +
/home/caleb/ASDV-Java/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Orange.java
+
+/*
+ * 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 com.calebfontenot.lab8_calebfontenot;
+
+import com.calebfontenot.lab8_calebfontenot.Fruit;
+
+/**
+ *
+ * @author caleb
+ */
+public class Orange extends Fruit {
+    
+    @Override
+    public String howToEat() {
+        return "Orange: Make orange juice.";
+    }
+}
+
+
+ diff --git a/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Test.html b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Test.html new file mode 100644 index 0000000..82ebd23 --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Test.html @@ -0,0 +1,63 @@ + + + +Test.java + + + + +
/home/caleb/ASDV-Java/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Test.java
+
+/*
+ * 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 com.calebfontenot.lab8_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+public class Test {
+    Edible getEdible() {
+        Edible e = new Edible() {
+            @Override
+            public String howToEat() {
+                return "Beans: make a soup";
+            }
+        };
+        return e;
+    }
+/*
+Comparable getComparable() {
+        Comparable c = new Comparable() {
+            @Override
+            public int compareTo(Object o) {
+                return == "dummy value" ? ((o.hashCode() == 11 ? 1 : -1) : 0;
+            }
+        };
+        return c;
+    }
+*/
+    public static void main(String[] args)
+    {
+        Edible[] edible = {new Chicken()};
+    }
+}
+
+
+ diff --git a/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/TestEdible.html b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/TestEdible.html new file mode 100644 index 0000000..61bf59c --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/TestEdible.html @@ -0,0 +1,90 @@ + + + +TestEdible.java + + + + +
/home/caleb/ASDV-Java/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/TestEdible.java
+
+/*
+ * 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 com.calebfontenot.lab8_calebfontenot;
+
+import java.util.ArrayList;
+
+/**
+ *
+ * @author caleb
+ */
+
+
+public class TestEdible {
+    public static void testWithArrayList() {
+        ArrayList<Edible> edible = new ArrayList();
+        
+        edible.add(new Chicken());
+        edible.add(new Apple());
+        edible.add(new Orange());
+        edible.add(new Duck());
+        edible.add(new Brocoli());
+
+        for (Edible eat: edible) {
+            System.out.println(eat.howToEat());
+        }
+    }
+    public static void testWithArrayOfInterfaces() {
+        Edible[] edible = {
+        new Chicken(), new Apple(), new Orange(), new Duck(), new Brocoli()
+    };
+        for (int i = 0; i < edible.length; ++i) {
+            System.out.println(edible[i].howToEat());
+        }
+    }
+    public static void testWithArrayOfObjects() {
+        Object[] objects = {
+            new Tiger(), new Chicken(), new Apple(), new Duck(), new Brocoli()
+        };
+        for (int i = 0; i < objects.length; ++i) {
+            if (objects[i] instanceof Edible) {
+                System.out.println(((Edible) objects[i]).howToEat());
+            }
+            if (objects[i] instanceof Animal) {
+                System.out.println(((Animal) objects[i]).sound());
+            }
+        }
+    }
+    public static void main(String[] args)
+    {
+        testWithArrayOfObjects();
+        System.out.println("-------------------");
+        testWithArrayOfInterfaces();
+        System.out.println("------------------ ");
+        testWithArrayList();
+    }
+}
+
+
+
+
+ diff --git a/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Tiger.html b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Tiger.html new file mode 100644 index 0000000..6075795 --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/Printed HTMLs/Tiger.html @@ -0,0 +1,46 @@ + + + +Tiger.java + + + + +
/home/caleb/ASDV-Java/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Tiger.java
+
+/*
+ * 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 com.calebfontenot.lab8_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+public class Tiger extends Animal {
+
+    @Override
+    public String sound()
+    {
+        return "Tiger: ROAAAAAAAR!";
+    }
+    
+}
+
+
+ diff --git a/Semester 2/Assignments/lab8_CalebFontenot/lab8AbstractNinterfaces.pdf b/Semester 2/Assignments/lab8_CalebFontenot/lab8AbstractNinterfaces.pdf new file mode 100644 index 0000000..5f5621c Binary files /dev/null and b/Semester 2/Assignments/lab8_CalebFontenot/lab8AbstractNinterfaces.pdf differ diff --git a/Semester 2/Assignments/lab8_CalebFontenot/pom.xml b/Semester 2/Assignments/lab8_CalebFontenot/pom.xml new file mode 100644 index 0000000..5d0df92 --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + com.calebfontenot + lab8_CalebFontenot + 1.0-SNAPSHOT + jar + + UTF-8 + 17 + 17 + com.calebfontenot.lab8_calebfontenot.Lab8_CalebFontenot + + \ No newline at end of file diff --git a/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Animal.java b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Animal.java new file mode 100644 index 0000000..236cf77 --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Animal.java @@ -0,0 +1,13 @@ +/* + * 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 com.calebfontenot.lab8_calebfontenot; + +/** + * + * @author caleb + */ +public abstract class Animal { + public abstract String sound(); +} diff --git a/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Apple.java b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Apple.java new file mode 100644 index 0000000..97cb907 --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Apple.java @@ -0,0 +1,18 @@ +/* + * 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 com.calebfontenot.lab8_calebfontenot; + +/** + * + * @author caleb + */ +public class Apple extends Fruit{ + + @Override + public String howToEat() + { + return "Apple: Make apple cider."; + } +} diff --git a/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Brocoli.java b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Brocoli.java new file mode 100644 index 0000000..ba274df --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Brocoli.java @@ -0,0 +1,16 @@ +/* + * 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 com.calebfontenot.lab8_calebfontenot; + +/** + * + * @author caleb + */ +public class Brocoli extends Fruit { + @Override + public String howToEat() { + return "Brocolli: Steam it"; + } +} diff --git a/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Chicken.java b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Chicken.java new file mode 100644 index 0000000..fd03d74 --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Chicken.java @@ -0,0 +1,20 @@ +/* + * 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 com.calebfontenot.lab8_calebfontenot; + +/** + * + * @author caleb + */ +public class Chicken extends Animal implements Edible { + @Override + public String sound() { + return "Chicken: cock-a-doodle-do!"; + } + @Override + public String howToEat() { + return "Chicken: Fry it!"; + } +} diff --git a/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Duck.java b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Duck.java new file mode 100644 index 0000000..04e3315 --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Duck.java @@ -0,0 +1,21 @@ +/* + * 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 com.calebfontenot.lab8_calebfontenot; + +/** + * + * @author caleb + */ +public class Duck extends Animal implements Edible { + @Override + public String howToEat() { + return "Duck: Roast it!"; + } + + @Override + public String sound() { + return "Duck: Quack! Quack! Quack!"; + } +} diff --git a/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Edible.java b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Edible.java new file mode 100644 index 0000000..4117e51 --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Edible.java @@ -0,0 +1,13 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package com.calebfontenot.lab8_calebfontenot; + +/** + * + * @author caleb + */ +public interface Edible { + String howToEat(); +} diff --git a/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Fruit.java b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Fruit.java new file mode 100644 index 0000000..727c2a4 --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Fruit.java @@ -0,0 +1,13 @@ +/* + * 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 com.calebfontenot.lab8_calebfontenot; + +/** + * + * @author caleb + */ +public abstract class Fruit implements Edible{ + +} diff --git a/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/House.java b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/House.java new file mode 100644 index 0000000..d4cc373 --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/House.java @@ -0,0 +1,133 @@ +/* + * 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 com.calebfontenot.lab8_calebfontenot; + +import java.util.Date; + +/** + * + * @author caleb + */ +public class House implements Cloneable{ + + private int id; + private double area; + private Date whenBuilt; + + public House(int id, double area) + { + this.id = id; + this.area = area; + this.whenBuilt = new Date(); + } + + @Override + protected Object clone() throws CloneNotSupportedException + { + Object o = super.clone(); + ((House) o).whenBuilt = new Date(this.whenBuilt.getTime()); + return o; + } + + + + /** + * Get the value of whenBuilt + * + * @return the value of whenBuilt + */ + public Date getWhenBuilt() + { + return whenBuilt; + } + + /** + * Set the value of whenBuilt + * + * @param whenBuilt new value of whenBuilt + */ + public void setWhenBuilt(Date whenBuilt) + { + this.whenBuilt = whenBuilt; + } + + + /** + * Get the value of area + * + * @return the value of area + */ + public double getArea() + { + return area; + } + + /** + * Set the value of area + * + * @param area new value of area + */ + public void setArea(double area) + { + this.area = area; + } + + /** + * Get the value of id + * + * @return the value of id + */ + public int getId() + { + return id; + } + + /** + * Set the value of id + * + * @param id new value of id + */ + public void setId(int id) + { + this.id = id; + } + + @Override + public String toString() + { + return "House{" + "id=" + id + ", area=" + area + ", whenBuilt=" + whenBuilt + '}'; + } + + public int compareTo(House o) { + if (this.getId() == o.getId() && + this.getArea() == o.getArea() && + this.getWhenBuilt().equals(o.getWhenBuilt())) { + return 0; + } + if (this.area > o.area) { + return 1; + } else if (this.area < o.area) { + return -1; + } else { + return -2; // Same area for this and o but either var id or var whenBuilt are different + } + } + +public static void main(String[] args) throws CloneNotSupportedException, InterruptedException { + House house1 = new House(1, 1000); + House house2 = (House) house1.clone(); + house2.whenBuilt.setDate(8); + System.out.println(house1); + System.out.println(house2); + House house3 = new House(3, 2000); + House house4 = new House(4, 2000); + System.out.println("house 1 and house 2 are identical: "+ house1.compareTo(house2)); + System.out.println("house 3 and house 3 have the same area: " + house3.compareTo(house4)); + System.out.println("House 4 is harger than house 2: " + house4.compareTo(house2)); + + +} + +} diff --git a/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Lab8_CalebFontenot.java b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Lab8_CalebFontenot.java new file mode 100644 index 0000000..bb464b9 --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Lab8_CalebFontenot.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package com.calebfontenot.lab8_calebfontenot; + +/** + * + * @author caleb + */ +public class Lab8_CalebFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Orange.java b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Orange.java new file mode 100644 index 0000000..2a66f3b --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Orange.java @@ -0,0 +1,19 @@ +/* + * 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 com.calebfontenot.lab8_calebfontenot; + +import com.calebfontenot.lab8_calebfontenot.Fruit; + +/** + * + * @author caleb + */ +public class Orange extends Fruit { + + @Override + public String howToEat() { + return "Orange: Make orange juice."; + } +} diff --git a/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Test.java b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Test.java new file mode 100644 index 0000000..92d63c6 --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Test.java @@ -0,0 +1,36 @@ +/* + * 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 com.calebfontenot.lab8_calebfontenot; + +/** + * + * @author caleb + */ +public class Test { + Edible getEdible() { + Edible e = new Edible() { + @Override + public String howToEat() { + return "Beans: make a soup"; + } + }; + return e; + } +/* +Comparable getComparable() { + Comparable c = new Comparable() { + @Override + public int compareTo(Object o) { + return == "dummy value" ? ((o.hashCode() == 11 ? 1 : -1) : 0; + } + }; + return c; + } +*/ + public static void main(String[] args) + { + Edible[] edible = {new Chicken()}; + } +} diff --git a/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/TestEdible.java b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/TestEdible.java new file mode 100644 index 0000000..19b2ed8 --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/TestEdible.java @@ -0,0 +1,60 @@ +/* + * 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 com.calebfontenot.lab8_calebfontenot; + +import java.util.ArrayList; + +/** + * + * @author caleb + */ + + +public class TestEdible { + public static void testWithArrayList() { + ArrayList edible = new ArrayList(); + + edible.add(new Chicken()); + edible.add(new Apple()); + edible.add(new Orange()); + edible.add(new Duck()); + edible.add(new Brocoli()); + + for (Edible eat: edible) { + System.out.println(eat.howToEat()); + } + } + public static void testWithArrayOfInterfaces() { + Edible[] edible = { + new Chicken(), new Apple(), new Orange(), new Duck(), new Brocoli() + }; + for (int i = 0; i < edible.length; ++i) { + System.out.println(edible[i].howToEat()); + } + } + public static void testWithArrayOfObjects() { + Object[] objects = { + new Tiger(), new Chicken(), new Apple(), new Duck(), new Brocoli() + }; + for (int i = 0; i < objects.length; ++i) { + if (objects[i] instanceof Edible) { + System.out.println(((Edible) objects[i]).howToEat()); + } + if (objects[i] instanceof Animal) { + System.out.println(((Animal) objects[i]).sound()); + } + } + } + public static void main(String[] args) + { + testWithArrayOfObjects(); + System.out.println("-------------------"); + testWithArrayOfInterfaces(); + System.out.println("------------------ "); + testWithArrayList(); + } +} + + diff --git a/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Tiger.java b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Tiger.java new file mode 100644 index 0000000..8343568 --- /dev/null +++ b/Semester 2/Assignments/lab8_CalebFontenot/src/main/java/com/calebfontenot/lab8_calebfontenot/Tiger.java @@ -0,0 +1,19 @@ +/* + * 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 com.calebfontenot.lab8_calebfontenot; + +/** + * + * @author caleb + */ +public class Tiger extends Animal { + + @Override + public String sound() + { + return "Tiger: ROAAAAAAAR!"; + } + +}