diff --git a/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/Circle.html b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/Circle.html
new file mode 100644
index 0000000..23b301e
--- /dev/null
+++ b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/Circle.html
@@ -0,0 +1,81 @@
+
+
+
+Circle.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/Circle.java
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package com.calebfontenot.mp5_calebfontenot;
+
+
+
+
+
+public class Circle extends GeometricObject {
+ private double diameter ;
+
+ public Circle(double diameter) {
+ this .diameter = diameter;
+ System.out .println(" Circle Diameter: " + diameter);
+ }
+
+ @Override
+ public double getArea () {
+ double radius = diameter / 2 ;
+ return Math.PI * Math.pow (radius, 2 );
+ }
+
+ @Override
+ public double getPerimeter () {
+ return Math.PI * diameter ;
+ }
+
+ @Override
+ public String toString () {
+ return " Circle{ " + " diameter= " + diameter + ' } ' ;
+ }
+
+ @Override
+ public int compareTo (Object t) {
+ System.out .println(this .getArea() + " , " + ((Circle) t).getArea());
+ if (this .getArea() < ((Circle) t).getArea()) {
+ return -1 ;
+ } else if (this .getArea() > ((Circle) t).getArea()) {
+ return 1 ;
+ } else {
+ return 0 ;
+ }
+ }
+
+ @Override
+ public int compareTo () {
+ throw new UnsupportedOperationException(" No compare object supplied! " );
+ }
+
+}
+
+
+
diff --git a/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/Combinations.html b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/Combinations.html
new file mode 100644
index 0000000..9c4053f
--- /dev/null
+++ b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/Combinations.html
@@ -0,0 +1,177 @@
+
+
+
+Combinations.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/Combinations.java
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package com.calebfontenot.mp5_calebfontenot;
+
+
+
+
+
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+class Combinations
+{
+
+ private static void findCombinations (String[] A, int i, int k,
+ Set<List<String>> subarrays,
+ List<String> out)
+ {
+ if (A.length == 0 || k > A.length )
+ {
+ return ;
+ }
+
+
+ if (k == 0 )
+ {
+ subarrays.add(new ArrayList<>(out));
+ return ;
+ }
+
+
+ for (int j = i; j < A.length ; j++)
+ {
+
+
+ out.add(A[j]);
+ findCombinations (A, j + 1 , k - 1 , subarrays, out);
+ out.remove(out.size() - 1 );
+ }
+ }
+
+ private static Set<List<String>> findCombinations (String[] A, int k)
+ {
+ Set<List<String>> subarrays = new HashSet<>();
+ findCombinations (A, 0 , k, subarrays, new ArrayList<>());
+ return subarrays;
+ }
+
+ private static Set<List<String>> findAllCombinations (String[] A)
+ {
+ Set<List<String>> subarrays = new HashSet<>();
+ for (int k = 1 ; k <= A.length ; ++k)
+ {
+ findCombinations (A, 0 , k, subarrays, new ArrayList<>());
+ }
+ return subarrays;
+ }
+
+
+ A
+
+
+ public static ArrayList<String> allCombinations (String[] A)
+ {
+ Set<List<String>> set = findAllCombinations (A);
+ ArrayList<String> all = new ArrayList<String>();
+ Iterator it = set.iterator();
+ while (it.hasNext())
+ {
+ List<String> list = (List<String>) it.next();
+ String s1 = "" ;
+ for (String s2 : list)
+ {
+ s1 += s2;
+ }
+ all.add(s1);
+ }
+ Collections.sort (all, new Comparator<String>(){
+ @Override
+ public int compare (String o1, String o2)
+ {
+ return o1.length() - o2.length();
+ }
+ });
+ return all;
+ }
+
+
+ A
+
+
+ public static ArrayList<String> allCombinations (String a)
+ {
+ String[] A = new String[a.length()];
+ for (int i = 0 ; i < A.length ; ++i)
+ {
+ A[i] = Character.toString (a.charAt(i));
+ }
+ Set<List<String>> set = findAllCombinations (A);
+ ArrayList<String> all = new ArrayList<String>();
+ Iterator it = set.iterator();
+ while (it.hasNext())
+ {
+ List<String> list = (List<String>) it.next();
+ String s1 = "" ;
+ for (String s2 : list)
+ {
+ s1 += s2;
+ }
+ all.add(s1);
+ }
+
+ Collections.sort (all, new Comparator<String>(){
+ @Override
+ public int compare (String o1, String o2)
+ {
+ return o1.length() - o2.length();
+ }
+ });
+ return all;
+ }
+
+ public static void main (String[] args)
+ {
+ String[] A =
+ {
+ " 1 " , " 2 " , " 3 " , " 4 "
+ };
+ int = 2 ;
+
+
+ System.out .println(a llCombinations (A));
+ System.out .println(a llCombinations (" 1234 " ));
+
+ }
+}
+
+
+
+
diff --git a/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/FD.html b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/FD.html
new file mode 100644
index 0000000..fffd7fb
--- /dev/null
+++ b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/FD.html
@@ -0,0 +1,124 @@
+
+
+
+FD.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/FD.java
+
+package com.calebfontenot.mp5_calebfontenot;
+
+
+
+
+
+
+public class FD
+{
+
+ private String lhs ;
+
+ private String rhs ;
+
+
+
+ lhs
+ rhs
+
+
+
+ public FD(String lhs, String rhs)
+ throws IllegalArgumentException
+ {
+ if (lhs == null || rhs == null )
+ throw new IllegalArgumentException( " the LHS and/or RHS cannot be null. " );
+
+ if (lhs.length() < 1 || rhs.length() < 1 )
+ throw new IllegalArgumentException( " the LHS and/or RHS cannot be of lenght less than 1. " );
+
+ this .lhs = lhs;
+ this .rhs = rhs;
+ }
+
+
+
+
+
+
+ public String getRhs ()
+ {
+ return rhs ;
+ }
+
+
+
+
+ rhs
+
+ public void setRhs (String rhs)
+ {
+ this .rhs = rhs;
+ }
+
+
+
+
+
+
+ public String getLhs ()
+ {
+ return lhs ;
+ }
+
+
+
+
+ lhs
+
+ public void setLhs (String lhs)
+ {
+ this .lhs = lhs;
+ }
+
+ @Override
+ public String toString ()
+ {
+ return lhs + " -> " + rhs ;
+ }
+
+
+
+
+
+
+
+ public FD[] decomposeRightHandSide ()
+ {
+ FD[] fdDecomosition = new FD[this .rhs .length()];
+
+ for (int i = 0 ; i < this .rhs .length(); ++i)
+ {
+ fdDecomosition[i] = new FD(t his .lhs , Character.toString (r hs .charAt(i)));
+ }
+ return fdDecomosition;
+ }
+}
+
+
diff --git a/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/GeometricObject.html b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/GeometricObject.html
new file mode 100644
index 0000000..f1a9e9b
--- /dev/null
+++ b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/GeometricObject.html
@@ -0,0 +1,122 @@
+
+
+
+GeometricObject.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/GeometricObject.java
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package com.calebfontenot.mp5_calebfontenot;
+
+
+
+
+
+public abstract class GeometricObject implements Comparable {
+
+ private String color = " white " ;
+ private boolean filled ;
+ private java.util.Date dateCreated ;
+
+
+
+
+ protected GeometricObject() {
+ dateCreated = new java.util.Date();
+ }
+
+
+
+
+ protected GeometricObject(String color, boolean filled) {
+ dateCreated = new java.util.Date();
+ this .color = color;
+ this .filled = filled;
+ }
+
+
+
+
+ public String getColor () {
+ return color ;
+ }
+
+
+
+
+ public void setColor (String color) {
+ this .color = color;
+ }
+
+
+
+
+ public boolean isFilled () {
+ return filled ;
+ }
+
+
+
+
+ public void setFilled (boolean filled) {
+ this .filled = filled;
+ }
+
+
+
+
+ public java.util.Date getDateCreated () {
+ return dateCreated ;
+ }
+
+ @Override
+ public String toString () {
+ return " created on " + dateCreated + " \n color: " + color
+ + " and filled: " + filled ;
+ }
+
+
+
+
+ public abstract double getArea ();
+
+
+
+
+ public abstract double getPerimeter ();
+
+
+ public abstract int compareTo (GeometricObject t);
+
+ public static GeometricObject max (GeometricObject o1, GeometricObject o2) {
+ if (o1.getArea() >= o2.getArea()) {
+ return o1;
+ } else {
+ return o2;
+ }
+ }
+}
+
+
+
+
diff --git a/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/Large.html b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/Large.html
new file mode 100644
index 0000000..0971b4a
--- /dev/null
+++ b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/Large.html
@@ -0,0 +1,72 @@
+
+
+
+Large.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/Large.java
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package com.calebfontenot.mp5_calebfontenot;
+
+import java.io.File;
+
+import java.util.ArrayList;
+import java.util.Scanner;
+
+
+
+
+
+public class Large {
+ public static void main (String[] args) {
+
+
+ ArrayList firstNameArr = new ArrayList();
+ ArrayList lastNameArr = new ArrayList();
+ ArrayList jobTitleArr = new ArrayList();
+ ArrayList salaryArr = new ArrayList();
+
+ File file = new File(" Salary.txt " );
+ try (Scanner fileScanner = new Scanner(file)) {
+ while (fileScanner.hasNext()) {
+ firstNameArr.add(fileScanner.next());
+ lastNameArr.add(fileScanner.next());
+ jobTitleArr.add(fileScanner.next());
+ salaryArr.add(fileScanner.next());
+ fileScanner.nextLine();
+ }
+ } catch (Exception ex) {
+ System.out .println(" Unable to read file " );
+ }
+ for (int i = 0 ; i < firstNameArr.size(); ++i) {
+ System.out .println(" first name : " + firstNameArr.get(i));
+ System.out .println(" last name: " + lastNameArr.get(i));
+ System.out .println(" job title: " + jobTitleArr.get(i));
+ System.out .println(" salary: " + salaryArr.get(i));
+ System.out .println(" -------------------------------------- " );
+ }
+ }
+}
+
+
+
diff --git a/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/MP5_CalebFontenot.html b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/MP5_CalebFontenot.html
new file mode 100644
index 0000000..7f93c24
--- /dev/null
+++ b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/MP5_CalebFontenot.html
@@ -0,0 +1,39 @@
+
+
+
+MP5_CalebFontenot.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/MP5_CalebFontenot.java
+
+
+
+
+
+package com.calebfontenot.mp5_calebfontenot;
+
+
+
+
+
+public class MP5_CalebFontenot {
+
+ public static void main(String[] args) {
+ System.out.println(" Hello World! " );
+ }
+}
+
+
+
diff --git a/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/MyStack.html b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/MyStack.html
new file mode 100644
index 0000000..04cffe5
--- /dev/null
+++ b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/MyStack.html
@@ -0,0 +1,91 @@
+
+
+
+MyStack.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/MyStack.java
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package com.calebfontenot.mp5_calebfontenot;
+
+
+
+
+
+import java.util.ArrayList;
+
+public class MyStack implements Cloneable {
+ private ArrayList<Object> list = new ArrayList<>();
+
+ public boolean isEmpty () {
+ return list .isEmpty();
+ }
+
+ public int getSize () {
+ return list .size();
+ }
+
+ public Object peek () {
+ return list .get(getSize() - 1 );
+ }
+
+ public Object pop () {
+ Object o = list .get(getSize() - 1 );
+ list .remove(getSize() - 1 );
+ return o;
+ }
+
+ public void push (Object o) {
+ list .add(o);
+ }
+
+ @Override
+ public String toString () {
+ return " stack: " + list .toString();
+ }
+
+ @Override
+ public Object clone () throws CloneNotSupportedException {
+ MyStack clonedStack = (MyStack) super .clone();
+ ArrayList<Object> newList = new ArrayList<>(l ist );
+ clonedStack.list = newList;
+ return clonedStack;
+ }
+
+ public static void main (String[] args) throws CloneNotSupportedException {
+ MyStack stack = new MyStack();
+ final int STACK_SIZE = 50 ;
+ for (int i = 0 ; i < STACK_SIZE; ++i) {
+ stack.push(i + 1 );
+
+ }
+ System.out .println(stack.peek());
+ MyStack clonedStack = (MyStack) stack.clone();
+ System.out .println(clonedStack.peek());
+ }
+}
+
+
+
diff --git a/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/NormalizeDatabase.html b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/NormalizeDatabase.html
new file mode 100644
index 0000000..64bf29b
--- /dev/null
+++ b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/NormalizeDatabase.html
@@ -0,0 +1,203 @@
+
+
+
+NormalizeDatabase.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/NormalizeDatabase.java
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package com.calebfontenot.mp5_calebfontenot;
+
+
+
+
+
+
+
+
+
+
+import java.util.ArrayList;
+
+
+
+
+
+public class NormalizeDatabase
+{
+
+
+ attributes
+ fds
+
+
+ public static String closure (String attributes, ArrayList<FD> fds )
+ {
+ attributes = attributes.toUpperCase();
+ for (int j = 0 ; j < fds.size(); ++j)
+ {
+ FD capitalsFD = new FD(fds.get(j).getLhs().toUpperCase(),
+ fds.get(j).getRhs().toUpperCase());
+ fds.set(j, capitalsFD);
+ }
+
+ String closure = attributes;
+ String closurePreveious = attributes;
+
+
+
+
+
+ while (true )
+ {
+
+ for (int i = 0 ; i < fds.size(); ++i)
+ {
+ if (closure.contains(fds.get(i).getRhs()))
+ continue ;
+
+
+ if (closure.contains(fds.get(i).getLhs()))
+ closure += fds.get(i).getRhs();
+ }
+ if (closurePreveious.equals(closure))
+ break ;
+ else
+ closurePreveious = closure;
+ }
+
+
+
+ return closure;
+
+ }
+
+
+
+
+ fds
+
+
+ public static ArrayList<FD> eliminateRedundantAttributes (ArrayList<FD> fds)
+ {
+ for (int j = 0 ; j < fds.size(); ++j)
+ {
+ int s = fds.get(j).getLhs().length();
+ if (s < 2 )
+ {
+ continue ;
+ }
+ else
+ {
+ String fl = fds.get(j).getLhs().substring(0 , 1 );
+ ArrayList<FD> = new ArrayList<FD>();
+ String s1 = " " ;
+ if (fds.get(j).getLhs().length() == 2 )
+ {
+ s1 = fds.get(j).getLhs().substring(1 );
+ if (closure (s1,fds).contains(fl))
+ {
+
+ fds.add(new FD (fds.get(j).getLhs().substring(1 , 2 ), fds.get(j).getRhs()));
+ fds.remove(j);
+
+ }
+ }
+ else if (fds.get(j).getLhs().charAt(1 ) == 3 )
+ {
+ s1 = fds.get(j).getLhs().substring(1 );
+ if (closure (s1,fds).contains(fl))
+ {
+ fds.add(new FD (fds.get(j).getLhs().substring(1 , 2 ), fds.get(j).getRhs()));
+ fds.add(new FD (fds.get(j).getLhs().substring(2 , 3 ), fds.get(j).getRhs()));
+ fds.remove(j);
+ }
+ }
+ else if (fds.get(j).getLhs().charAt(1 ) == 4 )
+ {
+ s1 = fds.get(j).getLhs().substring(1 );
+ if (closure (s1,fds).contains(fl))
+ {
+ fds.add(new FD (fds.get(j).getLhs().substring(1 , 2 ), fds.get(j).getRhs()));
+ fds.add(new FD (fds.get(j).getLhs().substring(2 , 3 ), fds.get(j).getRhs()));
+ fds.add(new FD (fds.get(j).getLhs().substring(3 , 4 ), fds.get(j).getRhs()));
+ fds.remove(j);
+ }
+ }
+
+ else
+ {
+ return fds;
+ }
+ }
+
+ }
+
+ return fds;
+ }
+ public static void main (String[] args)
+ {
+ ArrayList<FD> fds = new ArrayList<FD>();
+ FD fd = new FD(" a " , " BC " );
+ FD[] fdDecomposed = fd.decomposeRightHandSide();
+ for (int i = 0 ; i < fdDecomposed.length ; ++i)
+ {
+ fds.add( new FD(fdDecomposed[i].getLhs(), fdDecomposed[i].getRhs()));
+ }
+
+ fds.add(new FD(" B " , " C " ));
+ fds.add(new FD(" AB " , " B " ));
+ fds.add(new FD(" C " , " A " ));
+ System.out .println(fds);
+ System.out .println(c losure (" b " , fds));
+ System.out .println(e liminateRedundantAttributes (fds));
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ }
+}
+
+
+
diff --git a/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/PrintCalendar.html b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/PrintCalendar.html
new file mode 100644
index 0000000..d87051d
--- /dev/null
+++ b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/PrintCalendar.html
@@ -0,0 +1,188 @@
+
+
+
+PrintCalendar.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/PrintCalendar.java
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package com.calebfontenot.mp5_calebfontenot;
+
+
+
+
+
+import java.util.Calendar;
+import java.util.Scanner;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+public class PrintCalendar {
+
+ public static void main (String[] args) {
+ Scanner input = new Scanner(System.in );
+ int year, month;
+ String userInput;
+
+ do {
+ System.out .println(" What would you like to do? " );
+ System.out .println(" 1. Print today's date. " );
+ System.out .println(" 2. Print a specified date. " );
+ System.out .println(" Q/q. Quit. " );
+ System.out .print(" Respond with 1, 2 or Q/q: " );
+ userInput = input.next();
+ if (userInput.toLowerCase().charAt(0 ) == ' q ' ) {
+ System.exit (0 );
+ }
+ if (Integer.parseInt (userInput) < 0 || Integer.parseInt (userInput) > 2 ) {
+ System.out .println(" Invalid input! " );
+ } else {
+ if (Integer.parseInt (userInput) == 1 ) {
+ Date date = new Date();
+ printMonth ((date.getYear() + 1900 ), date.getMonth());
+ } else if (Integer.parseInt (userInput) == 2 ) {
+ System.out .print(" Enter a month (1-12): " );
+ month = (input.nextInt() + 1 );
+ System.out .print(" Enter a year: " );
+ year = (input.nextInt());
+ GregorianCalendar date = new GregorianCalendar(year, month, 0 , 0 , 0 );
+ printMonth (date.get(Calendar.YEAR ), date.get(Calendar.MONTH ));
+ }
+ }
+ } while (true );
+
+ }
+
+
+ public static void printMonth (int year, int month) {
+
+ printMonthTitle (year, month);
+
+
+ printMonthBody (year, month);
+ }
+
+
+ public static void printMonthTitle (int year, int month) {
+ System.out .println(" " + getMonthName (month)
+ + " " + year);
+ System.out .println(" ----------------------------- " );
+ System.out .println(" Sun Mon Tue Wed Thu Fri Sat " );
+ }
+
+
+ public static String getMonthName (int month) {
+ String monthName = "" ;
+ switch (month) {
+ case 1 : monthName = " January " ; break ;
+ case 2 : monthName = " February " ; break ;
+ case 3 : monthName = " March " ; break ;
+ case 4 : monthName = " April " ; break ;
+ case 5 : monthName = " May " ; break ;
+ case 6 : monthName = " June " ; break ;
+ case 7 : monthName = " July " ; break ;
+ case 8 : monthName = " August " ; break ;
+ case 9 : monthName = " September " ; break ;
+ case 10 : monthName = " October " ; break ;
+ case 11 : monthName = " November " ; break ;
+ case 12 : monthName = " December " ;
+ }
+
+ return monthName;
+ }
+
+
+ public static void printMonthBody (int year, int month) {
+
+ int startDay = getStartDay (year, month);
+
+
+ int numberOfDaysInMonth = getNumberOfDaysInMonth (year, month);
+
+
+ int i = 0 ;
+ for (i = 0 ; i < startDay; i++)
+ System.out .print(" " );
+
+ for (i = 1 ; i <= numberOfDaysInMonth; i++) {
+ System.out .printf(" %4d " , i);
+
+ if ((i + startDay) % 7 == 0 )
+ System.out .println();
+ }
+
+ System.out .println();
+ }
+
+
+ public static int getStartDay (int year, int month) {
+ final int START_DAY_FOR_JAN_1_1800 = 3 ;
+
+ int totalNumberOfDays = getTotalNumberOfDays (year, month);
+
+
+ return (totalNumberOfDays + START_DAY_FOR_JAN_1_1800) % 7 ;
+ }
+
+
+ public static int getTotalNumberOfDays (int year, int month) {
+ int total = 0 ;
+
+
+ for (int i = 1800 ; i < year; i++)
+ if (isLeapYear (i))
+ total = total + 366 ;
+ else
+ total = total + 365 ;
+
+
+ for (int i = 1 ; i < month; i++)
+ total = total + getNumberOfDaysInMonth (year, i);
+
+ return total;
+ }
+
+
+ public static int getNumberOfDaysInMonth (int year, int month) {
+ if (month == 1 || month == 3 || month == 5 || month == 7 ||
+ month == 8 || month == 10 || month == 12 )
+ return 31 ;
+
+ if (month == 4 || month == 6 || month == 9 || month == 11 )
+ return 30 ;
+
+ if (month == 2 ) return isLeapYear (year) ? 29 : 28 ;
+
+ return 0 ;
+ }
+
+
+ public static boolean isLeapYear (int year) {
+ return year % 400 == 0 || (year % 4 == 0 && year % 100 != 0 );
+ }
+}
+
+
+
+
diff --git a/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/Rectangle.html b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/Rectangle.html
new file mode 100644
index 0000000..632df03
--- /dev/null
+++ b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/Rectangle.html
@@ -0,0 +1,95 @@
+
+
+
+Rectangle.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/Rectangle.java
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package com.calebfontenot.mp5_calebfontenot;
+
+
+
+
+
+public class Rectangle extends GeometricObject{
+ private double width ;
+ private double height ;
+
+ public Rectangle() {
+
+ }
+
+ public Rectangle(double width, double height) {
+ this .width = width;
+ this .height = height;
+ }
+
+ public double getWidth () {
+ return width ;
+ }
+
+ public void setWidth (double width) {
+ this .width = width;
+ }
+
+ public double getHeight () {
+ return height ;
+ }
+
+ public void setHeight (double height) {
+ this .height = height;
+ }
+
+ @Override
+ public double getArea () {
+ return width * height ;
+ }
+
+ @Override
+ public double getPerimeter () {
+ return 2 * (width + height );
+ }
+
+ @Override
+ public int compareTo (GeometricObject t) {
+ System.out .println(this .getArea() + " , " + (t).getArea());
+ if (this .getArea() < (t).getArea()) {
+ return -1 ;
+ } else if (this .getArea() > (t).getArea()) {
+ return 1 ;
+ } else {
+ return 0 ;
+ }
+ }
+
+ @Override
+ public int compareTo (Object t) {
+ throw new UnsupportedOperationException(" Not supported yet. " ); nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
+ }
+
+}
+
+
+
diff --git a/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/ShuffleArrayList.html b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/ShuffleArrayList.html
new file mode 100644
index 0000000..8086d82
--- /dev/null
+++ b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/ShuffleArrayList.html
@@ -0,0 +1,101 @@
+
+
+
+ShuffleArrayList.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/ShuffleArrayList.java
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package com.calebfontenot.mp5_calebfontenot;
+
+import java.util.*;
+
+
+
+
+
+public class ShuffleArrayList {
+
+public static void shuffle (ArrayList<Number> list) {
+
+ Random rng = new Random();
+
+ ArrayList<Integer> selectedIndices = new ArrayList<Integer>();
+
+
+ for (int i = 0 ; i < list.size(); ++i) {
+
+ int randomIndex;
+ do {
+ randomIndex = rng.nextInt(list.size());
+ } while (selectedIndices.contains(randomIndex));
+ selectedIndices.add(randomIndex);
+
+
+
+ Number temp = list.get(randomIndex);
+ list.set(randomIndex, list.get(i));
+ list.set(i, temp);
+ }
+}
+
+
+ public static String checkForDuplicates (ArrayList<Number> list) {
+
+ boolean repeatNumber = false ;
+ for (int i = 0 ; i < list.size(); ++i) {
+ for (int j = 0 ; j < list.size(); ++j) {
+ if (i != j) {
+
+ if (list.get(i) == list.get(j)) {
+ repeatNumber = true ;
+ }
+ }
+ }
+ }
+ if (repeatNumber) {
+ return " Numbers repeat in ArrayList. " ;
+ } else {
+ return " Numbers do not repeat in ArrayList. " ;
+ }
+ }
+
+ public static void main (String[] args) {
+ final int ARRAY_SIZE = 50 ;
+ ArrayList<Number> list = new ArrayList<>();
+ for (int i = 0 ; i < ARRAY_SIZE; ++i) {
+ list.add(i + 1 );
+ }
+
+ System.out .println(list);
+ System.out .println(c heckForDuplicates (list));
+ shuffle (list);
+ System.out .println(list);
+ System.out .println(c heckForDuplicates (list));
+ }
+
+}
+
+
+
diff --git a/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/SortArrayList.html b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/SortArrayList.html
new file mode 100644
index 0000000..a95db29
--- /dev/null
+++ b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/SortArrayList.html
@@ -0,0 +1,74 @@
+
+
+
+SortArrayList.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/SortArrayList.java
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package com.calebfontenot.mp5_calebfontenot;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+
+
+
+
+
+public class SortArrayList {
+
+ public static void sort (ArrayList<Number> list) {
+
+ for (int i = 0 ; i < list.size(); ++i) {
+ for (int j = i + 1 ; j < list.size(); ++j) {
+
+ Number numI = list.get(i);
+ Number numJ = list.get(j);
+ BigDecimal bigNumI = new BigDecimal(list.get(i).toString());
+ BigDecimal bigNumJ = new BigDecimal(list.get(j).toString());
+ if (bigNumI.compareTo(bigNumJ) == 1 ) {
+ Number tmp = numI;
+ list.set(i, numJ);
+ list.set(j, tmp);
+ }
+ }
+ }
+ }
+
+ public static void main (String[] args) {
+ final int ARRAY_SIZE = 50 ;
+ ArrayList<Number> list = new ArrayList<>();
+ for (int i = 0 ; i < ARRAY_SIZE; ++i) {
+ list.add((i) + Math.random ());
+ }
+ System.out .println(list);
+ ShuffleArrayList.shuffle (list);
+ System.out .println(list);
+ sort (list);
+ System.out .println(list);
+
+ }
+}
+
+
+
diff --git a/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/TestCircle.html b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/TestCircle.html
new file mode 100644
index 0000000..90ded48
--- /dev/null
+++ b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/TestCircle.html
@@ -0,0 +1,43 @@
+
+
+
+TestCircle.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/TestCircle.java
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package com.calebfontenot.mp5_calebfontenot;
+
+
+
+
+
+public class TestCircle {
+ public static void main (String[] args) {
+ Circle circle1 = new Circle(5 );
+ Circle circle2 = new Circle(1 0 );
+ System.out .println(circle1.compareTo(circle2));
+ }
+}
+
+
+
diff --git a/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/TestGeometricObject.html b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/TestGeometricObject.html
new file mode 100644
index 0000000..63225fa
--- /dev/null
+++ b/Semester 2/Assignments/MP5_CalebFontenot/Printed HTMLs/TestGeometricObject.html
@@ -0,0 +1,60 @@
+
+
+
+TestGeometricObject.java
+
+
+
+
+/home/caleb/ASDV-Java/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/TestGeometricObject.java
+
+
+nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
+nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
+
+package com.calebfontenot.mp5_calebfontenot;
+
+
+
+
+
+public class TestGeometricObject {
+public static void main (String[] args) {
+
+ Circle circle1 = new Circle(5 );
+ Circle circle2 = new Circle(4 );
+
+
+ Circle circle = (Circle) GeometricObject.max (circle1, circle2);
+ System.out .println(" The max Circle's radius is " + circle.getRadius());
+ System.out .println(circle);
+
+
+ Rectangle r1 = new Rectangle(5 , 4 );
+ Rectangle r2 = new Rectangle(4 , 5 );
+
+ System.out .println(r1.compareTo(r2));
+ System.out .println(" The max rectangle is " + (Rectangle) Rectangle.max (r1, r2));
+
+ System.out .println(" The max geometric object is " + GeometricObject.max (circle1, r2));
+ }
+}
+
+
+
+
diff --git a/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/Circle.java b/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/Circle.java
new file mode 100644
index 0000000..4a70fd6
--- /dev/null
+++ b/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/Circle.java
@@ -0,0 +1,55 @@
+/*
+ * 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.mp5_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+public class Circle extends GeometricObject {
+ private double diameter;
+
+ public Circle(double diameter) {
+ this.diameter = diameter;
+ System.out.println("Circle Diameter: " + diameter);
+ }
+
+ public double getRadius() {
+ return diameter / 2;
+ }
+
+ @Override
+ public double getArea() {
+ double radius = diameter / 2;
+ return Math.PI * Math.pow(radius, 2);
+ }
+
+ @Override
+ public double getPerimeter() {
+ return Math.PI * diameter;
+ }
+
+ @Override
+ public String toString() {
+ return "Circle{" + "diameter=" + diameter + '}';
+ }
+
+ @Override
+ public int compareTo(GeometricObject t) {
+ System.out.println(this.getArea() + ", " + (t).getArea());
+ if (this.getArea() < (t).getArea()) {
+ return -1;
+ } else if (this.getArea() > (t).getArea()) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+
+ @Override
+ public int compareTo(Object t) {
+ throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
+ }
+}
diff --git a/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/GeometricObject.java b/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/GeometricObject.java
new file mode 100644
index 0000000..e2eecc7
--- /dev/null
+++ b/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/GeometricObject.java
@@ -0,0 +1,95 @@
+/*
+ * 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.mp5_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+public abstract class GeometricObject implements Comparable {
+
+ private String color = "white";
+ private boolean filled;
+ private java.util.Date dateCreated;
+
+ /**
+ * Construct a default geometric object
+ */
+ protected GeometricObject() {
+ dateCreated = new java.util.Date();
+ }
+
+ /**
+ * Construct a geometric object with color and filled value
+ */
+ protected GeometricObject(String color, boolean filled) {
+ dateCreated = new java.util.Date();
+ this.color = color;
+ this.filled = filled;
+ }
+
+ /**
+ * Return color
+ */
+ public String getColor() {
+ return color;
+ }
+
+ /**
+ * Set a new color
+ */
+ public void setColor(String color) {
+ this.color = color;
+ }
+
+ /**
+ * Return filled. Since filled is boolean, the get method is named isFilled
+ */
+ public boolean isFilled() {
+ return filled;
+ }
+
+ /**
+ * Set a new filled
+ */
+ public void setFilled(boolean filled) {
+ this.filled = filled;
+ }
+
+ /**
+ * Get dateCreated
+ */
+ public java.util.Date getDateCreated() {
+ return dateCreated;
+ }
+
+ @Override
+ public String toString() {
+ return "created on " + dateCreated + "\ncolor: " + color
+ + " and filled: " + filled;
+ }
+
+ /**
+ * Abstract method getArea
+ */
+ public abstract double getArea();
+
+ /**
+ * Abstract method getPerimeter
+ */
+ public abstract double getPerimeter();
+
+ // Additional code below
+ public abstract int compareTo(GeometricObject t);
+
+ public static GeometricObject max(GeometricObject o1, GeometricObject o2) {
+ if (o1.getArea() >= o2.getArea()) {
+ return o1;
+ } else {
+ return o2;
+ }
+ }
+}
+
diff --git a/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/MyStack.java b/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/MyStack.java
new file mode 100644
index 0000000..60396ea
--- /dev/null
+++ b/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/MyStack.java
@@ -0,0 +1,62 @@
+/*
+ * 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.mp5_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+import java.util.ArrayList;
+
+public class MyStack implements Cloneable {
+ private ArrayList list = new ArrayList<>();
+
+ public boolean isEmpty() {
+ return list.isEmpty();
+ }
+
+ public int getSize() {
+ return list.size();
+ }
+
+ public Object peek() {
+ return list.get(getSize() - 1);
+ }
+
+ public Object pop() {
+ Object o = list.get(getSize() - 1);
+ list.remove(getSize() - 1);
+ return o;
+ }
+
+ public void push(Object o) {
+ list.add(o);
+ }
+
+ @Override /** Override the toString in the Object class */
+ public String toString() {
+ return "stack: " + list.toString();
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ MyStack clonedStack = (MyStack) super.clone();
+ ArrayList newList = new ArrayList<>(list);
+ clonedStack.list = newList;
+ return clonedStack;
+ }
+
+ public static void main(String[] args) throws CloneNotSupportedException {
+ MyStack stack = new MyStack();
+ final int STACK_SIZE = 50;
+ for (int i = 0; i < STACK_SIZE; ++i) {
+ stack.push(i + 1); // Fill Stack with sequential numbers.
+ //System.out.println(stack.peek());
+ }
+ System.out.println(stack.peek());
+ MyStack clonedStack = (MyStack) stack.clone();
+ System.out.println(clonedStack.peek());
+ }
+}
diff --git a/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/NormalizeDatabase.java b/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/NormalizeDatabase.java
index c1c4981..c81cc89 100644
--- a/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/NormalizeDatabase.java
+++ b/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/NormalizeDatabase.java
@@ -14,7 +14,6 @@ package com.calebfontenot.mp5_calebfontenot;
* and open the template in the editor.
*/
import java.util.ArrayList;
-import java.util.Set;
/**
*
@@ -86,40 +85,51 @@ public class NormalizeDatabase
}
else
{
- String fl = fds.get(j).getLhs().substring(0);
+ String fl = fds.get(j).getLhs().substring(0, 1);
ArrayList fFD = new ArrayList();
String s1 = " ";
if (fds.get(j).getLhs().length() == 2)
- {
-
+ {
s1 = fds.get(j).getLhs().substring(1);
- fFD.add(new FD (fds.get(j).getLhs().substring(1), fds.get(j).getLhs()));
- System.out.println("closure " + closure(s1, fds));
- System.out.println("Attribute " + s1);
- System.out.println("final (removed " + fFD);
+ if (closure(s1,fds).contains(fl))
+ {
+
+ fds.add(new FD (fds.get(j).getLhs().substring(1, 2), fds.get(j).getRhs()));
+ fds.remove(j);
+
+ }
}
-// else if (fds.get(j).getLhs().charAt(1) == 3)
-// {
-// lFD.add(fds.get(j).getLhs().charAt(1));
-// lFD.add(fds.get(j).getLhs().charAt(2));
-// }
-// else if (fds.get(j).getLhs().charAt(1) == 4)
-// {
-// lFD.add(fds.get(j).getLhs().charAt(1));
-// lFD.add(fds.get(j).getLhs().charAt(2));
-// lFD.add(fds.get(j).getLhs().charAt(3));
-// }
- if (closure(s1, fds).contains(fl))
+ else if (fds.get(j).getLhs().charAt(1) == 3)
{
- return fFD;
+ s1 = fds.get(j).getLhs().substring(1);
+ if (closure(s1,fds).contains(fl))
+ {
+ fds.add(new FD (fds.get(j).getLhs().substring(1, 2), fds.get(j).getRhs()));
+ fds.add(new FD (fds.get(j).getLhs().substring(2, 3), fds.get(j).getRhs()));
+ fds.remove(j);
+ }
}
+ else if (fds.get(j).getLhs().charAt(1) == 4)
+ {
+ s1 = fds.get(j).getLhs().substring(1);
+ if (closure(s1,fds).contains(fl))
+ {
+ fds.add(new FD (fds.get(j).getLhs().substring(1, 2), fds.get(j).getRhs()));
+ fds.add(new FD (fds.get(j).getLhs().substring(2, 3), fds.get(j).getRhs()));
+ fds.add(new FD (fds.get(j).getLhs().substring(3, 4), fds.get(j).getRhs()));
+ fds.remove(j);
+ }
+ }
+
else
{
return fds;
}
}
+
}
- return null;
+
+ return fds;
}
public static void main(String[] args)
{
diff --git a/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/PrintCalendar.java b/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/PrintCalendar.java
new file mode 100644
index 0000000..626089a
--- /dev/null
+++ b/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/PrintCalendar.java
@@ -0,0 +1,160 @@
+/*
+ * 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.mp5_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+import java.util.Calendar;
+import java.util.Scanner;
+import java.util.Date;
+import java.util.GregorianCalendar;
+
+public class PrintCalendar {
+ /** Main method */
+ public static void main(String[] args) {
+ Scanner input = new Scanner(System.in);
+ int year, month;
+ String userInput;
+
+ do {
+ System.out.println("What would you like to do?");
+ System.out.println("1. Print today's date.");
+ System.out.println("2. Print a specified date.");
+ System.out.println("Q/q. Quit.");
+ System.out.print("Respond with 1, 2 or Q/q: ");
+ userInput = input.next();
+ if (userInput.toLowerCase().charAt(0) == 'q') {
+ System.exit(0);
+ }
+ if (Integer.parseInt(userInput) < 0 || Integer.parseInt(userInput) > 2) {
+ System.out.println("Invalid input!");
+ } else {
+ if (Integer.parseInt(userInput) == 1) {
+ Date date = new Date();
+ printMonth((date.getYear() + 1900), date.getMonth());
+ } else if (Integer.parseInt(userInput) == 2) {
+ System.out.print("Enter a month (1-12): ");
+ month = (input.nextInt() + 1);
+ System.out.print("Enter a year: ");
+ year = (input.nextInt());
+ GregorianCalendar date = new GregorianCalendar(year, month, 0, 0, 0);
+ printMonth(date.get(Calendar.YEAR), date.get(Calendar.MONTH));
+ }
+ }
+ } while (true);
+
+ }
+
+ /** Print the calendar for a month in a year */
+ public static void printMonth(int year, int month) {
+ // Print the headings of the calendar
+ printMonthTitle(year, month);
+
+ // Print the body of the calendar
+ printMonthBody(year, month);
+ }
+
+ /** Print the month title, e.g., May, 1999 */
+ public static void printMonthTitle(int year, int month) {
+ System.out.println(" " + getMonthName(month)
+ + " " + year);
+ System.out.println("-----------------------------");
+ System.out.println(" Sun Mon Tue Wed Thu Fri Sat");
+ }
+
+ /** Get the English name for the month */
+ public static String getMonthName(int month) {
+ String monthName = "";
+ switch (month) {
+ case 1: monthName = "January"; break;
+ case 2: monthName = "February"; break;
+ case 3: monthName = "March"; break;
+ case 4: monthName = "April"; break;
+ case 5: monthName = "May"; break;
+ case 6: monthName = "June"; break;
+ case 7: monthName = "July"; break;
+ case 8: monthName = "August"; break;
+ case 9: monthName = "September"; break;
+ case 10: monthName = "October"; break;
+ case 11: monthName = "November"; break;
+ case 12: monthName = "December";
+ }
+
+ return monthName;
+ }
+
+ /** Print month body */
+ public static void printMonthBody(int year, int month) {
+ // Get start day of the week for the first date in the month
+ int startDay = getStartDay(year, month);
+
+ // Get number of days in the month
+ int numberOfDaysInMonth = getNumberOfDaysInMonth(year, month);
+
+ // Pad space before the first day of the month
+ int i = 0;
+ for (i = 0; i < startDay; i++)
+ System.out.print(" ");
+
+ for (i = 1; i <= numberOfDaysInMonth; i++) {
+ System.out.printf("%4d", i);
+
+ if ((i + startDay) % 7 == 0)
+ System.out.println();
+ }
+
+ System.out.println();
+ }
+
+ /** Get the start day of month/1/year */
+ public static int getStartDay(int year, int month) {
+ final int START_DAY_FOR_JAN_1_1800 = 3;
+ // Get total number of days from 1/1/1800 to month/1/year
+ int totalNumberOfDays = getTotalNumberOfDays(year, month);
+
+ // Return the start day for month/1/year
+ return (totalNumberOfDays + START_DAY_FOR_JAN_1_1800) % 7;
+ }
+
+ /** Get the total number of days since January 1, 1800 */
+ public static int getTotalNumberOfDays(int year, int month) {
+ int total = 0;
+
+ // Get the total days from 1800 to 1/1/year
+ for (int i = 1800; i < year; i++)
+ if (isLeapYear(i))
+ total = total + 366;
+ else
+ total = total + 365;
+
+ // Add days from Jan to the month prior to the calendar month
+ for (int i = 1; i < month; i++)
+ total = total + getNumberOfDaysInMonth(year, i);
+
+ return total;
+ }
+
+ /** Get the number of days in a month */
+ public static int getNumberOfDaysInMonth(int year, int month) {
+ if (month == 1 || month == 3 || month == 5 || month == 7 ||
+ month == 8 || month == 10 || month == 12)
+ return 31;
+
+ if (month == 4 || month == 6 || month == 9 || month == 11)
+ return 30;
+
+ if (month == 2) return isLeapYear(year) ? 29 : 28;
+
+ return 0; // If month is incorrect
+ }
+
+ /** Determine if it is a leap year */
+ public static boolean isLeapYear(int year) {
+ return year % 400 == 0 || (year % 4 == 0 && year % 100 != 0);
+ }
+}
+
diff --git a/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/Rectangle.java b/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/Rectangle.java
new file mode 100644
index 0000000..587a801
--- /dev/null
+++ b/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/Rectangle.java
@@ -0,0 +1,67 @@
+/*
+ * 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.mp5_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+public class Rectangle extends GeometricObject{
+ private double width;
+ private double height;
+
+ public Rectangle() {
+
+ }
+
+ public Rectangle(double width, double height) {
+ this.width = width;
+ this.height = height;
+ }
+
+ public double getWidth() {
+ return width;
+ }
+
+ public void setWidth(double width) {
+ this.width = width;
+ }
+
+ public double getHeight() {
+ return height;
+ }
+
+ public void setHeight(double height) {
+ this.height = height;
+ }
+
+ @Override
+ public double getArea() {
+ return width * height;
+ }
+
+ @Override
+ public double getPerimeter() {
+ return 2 * (width + height);
+ }
+
+ @Override
+ public int compareTo(GeometricObject t) {
+ System.out.println(this.getArea() + ", " + (t).getArea());
+ if (this.getArea() < (t).getArea()) {
+ return -1;
+ } else if (this.getArea() > (t).getArea()) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+
+ @Override
+ public int compareTo(Object t) {
+ throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
+ }
+
+}
diff --git a/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/TestGeometricObject.java b/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/TestGeometricObject.java
new file mode 100644
index 0000000..6421def
--- /dev/null
+++ b/Semester 2/Assignments/MP5_CalebFontenot/src/main/java/com/calebfontenot/mp5_calebfontenot/TestGeometricObject.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 com.calebfontenot.mp5_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+public class TestGeometricObject {
+public static void main(String[] args) {
+ // Create two comparable Circles
+ Circle circle1 = new Circle(5);
+ Circle circle2 = new Circle(4);
+
+ // Display the max Circle
+ Circle circle = (Circle) GeometricObject.max(circle1, circle2);
+ System.out.println("The max Circle's radius is " + circle.getRadius());
+ System.out.println(circle);
+
+ // Create two comparable rectangles
+ Rectangle r1 = new Rectangle(5, 4);
+ Rectangle r2 = new Rectangle(4, 5);
+
+ System.out.println(r1.compareTo(r2));
+ System.out.println("The max rectangle is " + (Rectangle) Rectangle.max(r1, r2));
+
+ System.out.println("The max geometric object is " + GeometricObject.max(circle1, r2));
+ }
+}
+
diff --git a/Semester 2/ZIPs/MP5_CalebFontenot.zip b/Semester 2/ZIPs/MP5_CalebFontenot.zip
new file mode 100644
index 0000000..81d6197
Binary files /dev/null and b/Semester 2/ZIPs/MP5_CalebFontenot.zip differ