diff --git a/.gitignore b/.gitignore index 2fca960..6d164ba 100644 --- a/.gitignore +++ b/.gitignore @@ -181,3 +181,4 @@ /Semester 3/Assignments/DBConnectionTest/target/ /Semester 3/Assignments/mavenproject1/target/ /Semester 3/Assignments/JavaFXBallsWithComparator/target/ +/Semester 3/Assignments/MP4_CalebFontenot/target/ diff --git a/Semester 1/Assignments/lab12_CalebFontenot/dist/lab12_CalebFontenot.jar b/Semester 1/Assignments/lab12_CalebFontenot/dist/lab12_CalebFontenot.jar new file mode 100644 index 0000000..3e8f210 Binary files /dev/null and b/Semester 1/Assignments/lab12_CalebFontenot/dist/lab12_CalebFontenot.jar differ diff --git a/Semester 1/Assignments/lab12_CalebFontenot/src/lab12_calebfontenot/NestedForPyramid.class b/Semester 1/Assignments/lab12_CalebFontenot/src/lab12_calebfontenot/NestedForPyramid.class new file mode 100644 index 0000000..c66a8ef Binary files /dev/null and b/Semester 1/Assignments/lab12_CalebFontenot/src/lab12_calebfontenot/NestedForPyramid.class differ diff --git a/Semester 3/Assignments/MP4_CalebFontenot/Printed HTMLs/ArrayListASDV.html b/Semester 3/Assignments/MP4_CalebFontenot/Printed HTMLs/ArrayListASDV.html new file mode 100644 index 0000000..f88aa6e --- /dev/null +++ b/Semester 3/Assignments/MP4_CalebFontenot/Printed HTMLs/ArrayListASDV.html @@ -0,0 +1,1006 @@ + + + +ArrayListASDV.java + + + + +
/home/caleb/ASDV-Java/Semester 3/Assignments/MP4_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/mp4_calebfontenot/ArrayListASDV.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 edu.slcc.asdv.caleb.mp4_calebfontenot;
+
+/**
+ *
+ * @author caleb
+ */
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.NoSuchElementException;
+import java.util.Objects;
+import java.util.function.Consumer;
+
+/**
+ *
+ * @author ASDV2
+ */
+public class ArrayListASDV<E>
+        implements Serializable, Cloneable, List<E> {
+
+    private E[] list;
+    private int index;//the index to add at ( length of array)
+
+    //private Class<E> type;
+    /**
+     * Constructs an empty list with an initial capacity of three.
+     *
+     */
+    public ArrayListASDV() {
+        list = (E[]) new Object[3];
+        index = 0;
+    }
+
+    /**
+     * Constructs an empty list with the specified initial capacity.
+     *
+     * @param initialCapacity - the initial capacity of the list
+     * @throws IllegalArgumentException - if the specified initial capacity is negative
+     */
+    public ArrayListASDV(int initialCapacity) {
+        if (initialCapacity < 0) {
+            throw new IllegalArgumentException("initialCapacity id negative: " + initialCapacity);
+        }
+        list = (E[]) new Object[initialCapacity];
+        index = 0;
+
+    }
+
+    /**
+     * Double the size of the current list and copies to it the old list
+     *
+     * @return the new array.
+     */
+    private E[] doubleSizeOfList() {
+        list = this.toArray((E[]) new Object[list.length + list.length]);
+        return this.list;
+
+    }
+
+    /**
+     * Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator.
+     *
+     * @param c - the collection whose elements are to be placed into this
+     * @throws NullPointerException - if the specified collection is null
+     *
+     *
+     */
+    public ArrayListASDV(Collection<? extends E> c) {
+        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+    }
+
+    /**
+     * Returns true if this collection changed as a result of the call. false if this collection does not permit duplicates and already contains the specified element.
+     *
+     * @param e - element whose presence in this collection is to be ensured
+     *
+     * @return true if this collection changed as a result of the call
+     * @throws ClassCastException - if the class of the specified element prevents it from being added to this collection
+     * @throws NullPointerException - if the specified element is null and this collection does not permit null elements
+     * @throws IllegalArgumentException - if some property of the element prevents it from being added to this collection
+     */
+    @Override
+    public boolean add(E e) {
+        if (e == null) {
+            throw new NullPointerException("null parameter");
+        }
+
+        list[index++] = e;
+        if (index >= list.length * 0.75) {
+            doubleSizeOfList();
+        }
+        return true;
+    }
+
+    /**
+     * Returns the number of elements in this list.
+     *
+     * @return the number of elements in this list.
+     */
+    @Override
+    public int size() {
+        return index;
+    }
+
+    @Override
+    public String toString() {
+        String s = "ArrayListASDV[";
+
+        for (int i = 0; i < index; ++i) {
+            s += list[i] + " ";
+        }
+        s += "]";
+
+        return s;
+    }
+
+    /**
+     * Returns true if this list contains no elements.
+     *
+     * @return true if this list contains no elements
+     *
+     */
+    @Override
+    public boolean isEmpty() {
+        return this.index == 0;
+    }
+
+    /**
+     * Returns true if this list contains the specified element. More formally, returns true if and only if this list contains at least one element e such that (o==null ? e==null : o.equals(e)).
+     *
+     * @param o - element whose presence in this list is to be tested
+     *
+     * @return true if this list contains the specified element
+     *
+     */
+    public boolean contains(Object o) {
+
+        if (o == null) {
+            return false;
+        }
+        for (int i = 0; i < this.index; i++) {
+            if (o.equals(this.list[i])) {
+                return true;
+            }
+        }
+        return false;
+
+    }
+
+    /**
+     * Returns an array containing all of the elements in this list in proper sequence (from first to last element). The returned array will be "safe" in that no references to it are maintained by this list. (In other words, this method must allocate a new array). The caller is thus free to modify the returned array. This method acts as bridge between array-based and collection-based APIs. Returns: an array containing all of the elements in this list in proper sequence
+     *
+     * @return an array containing all of the elements in this list in proper sequence
+     */
+    @Override
+    public Object[] toArray() {
+        Object[] returnArray = new Object[index];
+        for (int i = 0; i < index; ++i) {
+            Object objCopy = list[i];
+            returnArray[i] = objCopy;
+        }
+        return returnArray;
+    }
+
+    /**
+     * Removes the first occurrence of the specified element from this list, if it is present. If the list does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) (if such an element exists). Returns true if this list contained the specified element (or equivalently, if this list changed as a result of the call).
+     *
+     * @param o - element to be removed from this list, if present
+     * @return true if this list contained the specified element
+     */
+    @Override
+    public boolean remove(Object o) {
+        if (o == null) {
+            return false;
+        }
+        Object[] newArray = new Object[index];
+        int i = 0;
+        for (Object arrayElement : list) {
+            try {
+                if (!arrayElement.equals(o)) {
+                    newArray[i] = arrayElement;
+                }
+                if ((index - 1) > i) {
+                    ++i;
+                }
+            } catch (NullPointerException ex) {
+                continue;
+            }
+            
+        }
+        --index;
+        list = (E[]) newArray;
+        return true;
+    }
+
+    /**
+     * Removes all of the elements from this list. The list will be empty after this call returns. Note: Traverse the array and set all of its elements to null. Set its index to zero.
+     */
+    @Override
+    public void clear() {
+        for (int i = 0; i < list.length; ++i) {
+            list[i] = null;
+        }
+        index = 0;
+    }
+
+    /**
+     * Returns the element at the specified position in this list.
+     *
+     * @param index of the element to return
+     * @return the element at the specified position in this list
+     * @throws IndexOutOfBoundsException - if the index is out of range (index GE 0 || index GE size())
+     */
+    @Override
+    public E get(int index) {
+        return list[index];
+    }
+
+    /**
+     * Replaces the element at the specified position in this list with the specified element.
+     *
+     * @param index - index of the element to replace
+     * @param element - element to be stored at the specified position
+     * @return the element previously at the specified position
+     * @throws IndexOutOfBoundsException - if the index is out of range (index GE 0 || index GE size())
+     */
+    @Override
+    public E set(int index, E element) {
+        return list[index] = element;
+    }
+
+    /**
+     * Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).
+     *
+     * @param index - index at which the specified element is to be inserted element
+     * @param - element to be inserted
+     * @throws NullPointerException - if the specified element is null and this collection does not permit null elements
+     * @throws IndexOutOfBoundsException - if the index is out of range (index GE 0 || index GE size())
+     */
+    public void add(int index, E element) {
+        if (element == null) {
+            throw new NullPointerException("cant add null");
+        }
+        if (index > this.index || index < 0) {
+            throw new IndexOutOfBoundsException("cant add at this index");
+        }
+
+        // Check if the list needs to be resized
+        if (this.index >= list.length) {
+            doubleSizeOfList();
+        }
+
+        // Shift elements to the right to make space for the new element
+        for (int i = this.index; i > index; i--) {
+            list[i] = list[i - 1];
+        }
+
+        // Insert the new element at the specified index
+        list[index] = element;
+        this.index++;
+    }
+
+    /**
+     * Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices).
+     *
+     * @param index - the index of the element to be removed
+     * @return the element that was removed from the list
+     * @throws IndexOutOfBoundsException - if the index is out of range (index GE 0 || index GE size())
+     */
+    public E remove(int index) {
+        Object removedObject = new Object();
+        if (index < 0 || index >= this.index) {
+            throw new IndexOutOfBoundsException("Index " + index + " out of bounds");
+        }
+                Object[] newArray = new Object[index];
+        int j = 0;
+        for (int i = 0; i < index; ++i) {
+            try {
+                if (i != index) {
+                    newArray[j] = list[i];
+                } else {
+                    removedObject = list[i];
+                }
+                if ((index - 1) > j) {
+                    ++j;
+                }
+            } catch (NullPointerException ex) {
+                continue;
+            }
+            
+        }
+        --this.index;
+        list = (E[]) newArray;
+        return (E) removedObject;
+    }
+
+    /**
+     * Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index. Parameters:
+     *
+     * @param o - element to search for
+     * @return the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element
+     */
+    @Override
+    public int indexOf(Object o) {
+        for (int i = 0; i < index - 1; i++) {
+            if (list[i].equals(o)) {
+                return i;
+            }
+        }
+
+        return -1;
+    }
+
+    /**
+     * Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the highest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index. Parameters:
+     *
+     * @param o - element to search for
+     * @return the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element
+     */
+    @Override
+    public int lastIndexOf(Object o) {
+        for (int i = list.length - 1; i >= 0; i--) {
+            if (list[i] != null && list[i].equals(o)) {
+                return i;
+            }
+        }
+        return -1;
+    }
+
+    /**
+     * Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the returned list is empty.) The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. The returned list supports all of the optional list operations. This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by passing a subList view instead of a whole list. For example, the following idiom removes a range of elements from a list: list.subList(from, to).clear();
+     *
+     * Similar idioms may be constructed for ArrayList.indexOf(Object) and ArrayList.lastIndexOf(Object), and all of the algorithms in the Collections class can be applied to a subList. The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.)
+     *
+     * @param fromIndex - low endpoint (inclusive) of the subList
+     * @param toIndex - high endpoint (exclusive) of the subList
+     * @return a view of the specified range within this list
+     * @throws IndexOutOfBoundsException - for an illegal endpoint index value (fromIndex LE 0 || toIndex > size || fromIndex > toIndex)
+     * @throws IllegalArgumentException - if the endpoint indices are out of order (fromIndex > toIndex)
+     */
+    @Override
+    public List<E> subList(int fromIndex, int toIndex) {
+        if (fromIndex < 0 || toIndex > size() || fromIndex > toIndex) {
+            throw new IndexOutOfBoundsException();
+        }
+        List<E> sublist = new ArrayListASDV<>();
+
+        for (int i = fromIndex; i < toIndex; i++) {
+            sublist.add(get(i));
+        }
+        return sublist;
+    }
+
+    /**
+     * Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array. If the list fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this list. If the list fits in the specified array with room to spare (i.e., the array has more elements than the list), the element in the array immediately following the end of the collection is set to null. (This is useful in determining the length of the list only if the caller knows that the list does not contain any null elements.)
+     *
+     * @param a - the array into which the elements of the list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose.
+     * @return an array containing the elements of the list
+     * @throws ArrayStoreException - if the runtime type of the specified array is not a supertype of the runtime type of every element in this list
+     * @throws NullPointerException - if the specified array is null
+     */
+    @Override
+    public <T> T[] toArray(T[] a) {
+        Class<?> clazz = a.getClass();
+        //>length of a is too small
+        if (a.length < index) // Make a new array of a's runtime type
+        {
+            return (T[]) Arrays.copyOf(this.list,
+                    index,
+                    a.getClass());
+        }
+
+        //>length of a is good
+        System.arraycopy(this.list, 0, a, 0, index);
+
+        //>length of a is greater than this list set nulls
+        if (a.length > index) {
+            for (int i = index; i < a.length; ++i) {
+                a[i] = null;
+            }
+        }
+        return a;
+
+    }
+
+    @Override
+    public Iterator<E> iterator() {
+        Iterator<E> it = new Iterator<E>() {
+            int index = 0;
+            //E[] list = (E[]) new Object[3];
+
+            @Override
+            public boolean hasNext() {
+                if (index == list.length) {
+                    return false;
+                }
+                return true;
+            }
+
+            @Override
+            public E next() {
+                return list[index++];
+            }
+
+            @Override
+            public void remove() {
+                if (index < 1) {
+                    Object[] newList = new Object[--index];
+                    for (int i = 0; i < index; i++) {
+                        newList[i] = list[i];
+                    }
+                    list = (E[]) newList;
+                }
+            }
+
+            /**
+             * Performs the given action for each remaining element until all elements have been processed or the action throws an exception- Actions are performed in the order of iteration, if that order is specified- Exceptions thrown by the action are relayed to the caller.
+             *
+             *
+             * @throws NullPointerException - if the specified action is null
+             */
+            @Override
+            public void forEachRemaining(Consumer<? super E> action) {
+                if (action == null) {
+                    throw new NullPointerException("Action is Null");
+                }
+
+                while (hasNext()) {
+                    action.accept(next());
+                }
+            }
+
+        };
+        return (Iterator<E>) it;
+    }
+
+    ;
+
+    /**
+     * Returns a list iterator over the elements in this list (in proper sequence). The returned list iterator is fail-fast.
+     *
+     *
+     * @return a list iterator over the elements in this list (in proper sequence
+     */
+    @Override
+    public ListIterator<E> listIterator() {
+        return listIterator(0);
+
+    }
+
+    @Override
+    public ListIterator<E> listIterator(int index) {
+
+        ListIterator<E> it = new ListIterator<E>() {
+            //E[] list = (E[]) new Object[3];
+            int index;
+
+            /**
+             * Returns true if this list iterator has more elements when traversing the list in the forward direction. (In other words, returns true if ListIterator.next would return an element rather than throwing an exception.)
+             *
+             * @return true if the list iterator has more elements when traversing the list in the forward direction
+             */
+            @Override
+            public boolean hasNext() {
+                return next() != null;
+            }
+
+            /**
+             * Returns the next element in the list and advances the cursor position. This method may be called repeatedly to iterate through the list, or intermixed with calls to ListIterator.previous to go back and forth. (Note that alternating calls to next and previous will return the same element repeatedly.)
+             *
+             * @return the next element in the list
+             * @throws NoSuchElementException - if the iteration has no next element
+             */
+            @Override
+            public E next() throws NoSuchElementException {
+                if (index > list.length) {
+                    throw new NoSuchElementException();
+                }
+                System.out.println("List iterator next() "+ list[index]);
+                return list[index++];
+            }
+
+            @Override
+            public boolean hasPrevious() {
+                return index > 0;
+            }
+
+            @Override
+            public E previous() {
+                return list[--index];
+
+            }
+
+            /**
+             * Returns the index of the element that would be returned by a subsequent call to next(). (Returns list size if the list iterator is at the end of the list.)
+             *
+             * @return the index of the element that would be returned by a subsequent call to next, or list size if the list iterator is at the end of the list
+             */
+            @Override
+            public int nextIndex() {
+                return index + 1;
+            }
+
+            /**
+             * Returns the index of the element that would be returned by a subsequent call to previous(). (Returns -1 if the list iterator is at the beginning of the list.)
+             *
+             * @return the index of the element that would be returned by a subsequent call to previous, or -1 if the list iterator is at the beginning of the list
+             */
+            @Override
+            public int previousIndex() {
+                return index - 1;
+            }
+
+            /**
+             * Performs the given action for each remaining element until all elements have been processed or the action throws an exception- Actions are performed in the order of iteration, if that order is specified- Exceptions thrown by the action are relayed to the caller.
+             *
+             *
+             * @throws NullPointerException - if the specified action is null
+             */
+            @Override
+            public void forEachRemaining(Consumer<? super E> action) {
+                if (action == null) {
+                    throw new NullPointerException("Action is Null");
+                }
+
+                while (hasNext()) {
+                    action.accept(next());
+                }
+            }
+
+            @Override
+            public void remove() {
+                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+            }
+
+            @Override
+            public void set(E e) {
+                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+            }
+
+            @Override
+            public void add(E e) {
+                throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
+            }
+        };
+
+        return it;
+
+    }
+
+    /**
+     *
+     * Returns true if this collection contains all of the elements in the specified collection.
+     *
+     * Parameters: c - collection to be checked for containment in this collection Returns: true if this collection contains all of the elements in the specified collection Throws: ClassCastException - if the types of one or more elements in the specified collection are incompatible with this collection (optional) NullPointerException - if the specified collection contains one or more null elements and this collection does not permit null elements (optional), or if the specified collection is null.
+     *
+     * @param c - collection to be checked for containment in this collection
+     * @return true if this collection contains all of the elements in the specified collection.
+     * @throws ClassCastException - if the types of one or more elements in the specified collection are incompatible with this collection
+     */
+    @Override
+    public boolean containsAll(Collection<?> c) {
+        for (Object e : c) {
+            if (!contains(e)) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    @Override
+    public boolean addAll(Collection<? extends E> c) {
+        boolean changed = false;
+        for (E e : c) {
+            if (add(e)) {
+                changed = true;
+            }
+        }
+
+        return changed;
+    }
+
+    @Override
+    public boolean addAll(int index, Collection<? extends E> c) {
+        boolean changed = false;
+        for (E e : c) {
+            add(index++, e);
+            changed = true;
+        }
+        return changed;
+    }
+
+    /**
+     * Removes all of this collection's elements that are also contained in the specified collection (optional operation). After this call returns, this collection will contain no elements in common with the specified collection.
+     *
+     * Parameters: c - collection containing elements to be removed from this collection Returns: true if this collection changed as a result of the call Throws: UnsupportedOperationException - if the removeAll method is not supported by this collection ClassCastException - if the types of one or more elements in this collection are incompatible with the specified collection (optional) NullPointerException - if this collection contains one or more null elements and the specified collection does not support null elements (optional), or if the specified collection is null
+     *
+     * @param c - collection containing elements to be removed from this collection
+     * @return true if this collection changed as a result of the call
+     * @throws ClassCastException - if the types of one or more elements in this collection are incompatible with the specified collection
+     */
+    @Override
+    public boolean removeAll(Collection<?> c) {
+        Objects.requireNonNull(c);
+
+        List<E> elToKeep = new ArrayList<>(this);
+        elToKeep.removeAll(c);
+        elToKeep.removeIf(Objects::isNull);
+
+        clear();
+        addAll(elToKeep);
+
+        return !elToKeep.isEmpty();
+    }
+
+    /**
+     * Retains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection.
+     *
+     *
+     * @param c - collection containing elements to be retained in this collection
+     * @return true if this collection changed as a result of the call
+     * @throws ClassCastException - if the types of one or more elements in this collection are incompatible with the specified collection (optional)
+     */
+    @Override
+    public boolean retainAll(Collection<?> c) {
+        Objects.requireNonNull(c);
+
+        List<E> elToKeep = new ArrayList<>();
+        for (E element : this) {
+            if (c.contains(element)) {
+                elToKeep.add(element);
+            }
+        }
+        elToKeep.removeIf(Objects::isNull);
+
+        clear();
+        addAll(elToKeep);
+
+        return size() != elToKeep.size();
+    }
+
+    public static void main(String[] args)
+            throws ClassNotFoundException, InterruptedException {
+        ArrayListASDV<Integer> aaa = new ArrayListASDV();
+        aaa.add(1);
+        aaa.add(2);
+        aaa.add(3);
+        aaa.add(4);
+
+        ArrayListASDV<Integer> list1 = new ArrayListASDV();
+        ArrayListASDV<String> list2 = new ArrayListASDV(4);
+        ArrayListASDV<A1> list3 = new ArrayListASDV(4);
+
+        System.out.println("------------------------------ ");
+        System.out.println("test add");
+        list1.add(10);
+        list1.add(20);
+        list3.add(new A1(-1));
+        list3.add(new A1(-2));
+        Integer[] b
+                = {
+                    2, 3
+                };
+        list1.toArray(b);
+
+        list2.add("a");
+        try {
+            list2.add(null);
+        } catch (NullPointerException e) {
+            System.err.println(e);
+        };
+
+        list2.add("b");
+        list2.add("c");
+        list2.add("d");
+        System.out.println("------------------------------ ");
+        System.out.println("test toString");
+        System.out.println(list1);
+        System.out.println(list2);
+        System.out.println(list3);
+
+        System.out.println("------------------------------ ");
+        System.out.println("test contains");
+        System.out.println("contains E");
+        System.out.println("contains c: " + list2.contains("c"));
+        System.out.println("contains null: " + list2.contains(null));
+        System.out.println("contains k: " + list2.contains('k'));
+        System.out.println(list2);
+        System.out.println("contains A(-1): " + list3.contains(new A1(-1)));
+        System.out.println("contains A(-3): " + list3.contains(new A1(-3)));
+
+        System.out.println("------------------------------ ");
+        System.out.print("test toArray(): ");
+        Object[] ar = list2.toArray();
+        System.out.print("[ ");
+        for (int i = 0; i < ar.length; ++i) {
+            System.out.print(ar[i] + " ");
+        }
+        System.out.println(" ] ");
+
+        System.out.println("\n---------------------------------------");
+        System.out.println("test clear()");
+        list2.clear();
+        System.out.println(list2);
+
+        System.out.println("\n---------------------------------------");
+        System.out.println("test size");
+        System.out.println(list2.size());
+
+        System.out.println("\n---------------------------------------");
+        System.out.println("test add(index, element)");
+        for (char a = 'Z'; a >= 'A'; --a) {
+            System.out.println("array size: " + list2.size());
+            list2.add(0, "" + a);
+        }
+        System.out.println(list2);
+
+        list2.add(26, "z");
+        System.out.println(list2);
+
+        list2.add(list2.size() - 2, "y");
+        System.out.println(list2);
+
+        System.out.println("\n---------------------------------------");
+        System.out.println("test remove(index)");
+        Object o = list2.remove(27);
+        System.out.println(o);
+        System.out.println(list2);
+
+        try {
+            list2.remove(30);
+        } catch (IndexOutOfBoundsException e) {
+            System.err.println(e);
+        }
+
+        System.out.println("\n---------------------------------------");
+        System.out.println("test remove(Object)");
+        list2.remove("y");
+        System.out.println(list2);
+        System.out.println(list2.remove("not in there"));
+
+        System.out.println("\n---------------------------------------");
+        System.out.println("test set(index, Object)");
+        list2.set(0, "0");
+        list2.set(25, "25");
+        System.out.println(list2);
+
+        System.out.println("\n---------------------------------------");
+        System.out.println("test indexOf()");
+        System.out.println(list2.indexOf("0"));
+        System.out.println(list2.indexOf("B"));
+        System.out.println(list2.indexOf("25"));
+        System.out.println(list2.indexOf("Y"));
+        System.out.println(list2.indexOf("not there"));
+
+        System.out.println("\n---------------------------------------");
+        System.out.println("test lastIndexOf()");
+        list2.add(10, "0");
+        System.out.println(list2.indexOf("0"));
+        System.out.println(list2.lastIndexOf("0"));
+        System.out.println(list2.indexOf("not there"));
+        System.out.println(list2);
+
+        System.out.println("\n---------------------------------------");
+        System.out.println("test sublist(from, to)");
+        List<String> l1 = list2.subList(1, 10);
+        ArrayListASDV<String> l2 = (ArrayListASDV<String>) list2.subList(11, 26);
+
+        System.out.println(l1);
+        System.out.println(l2);
+        List<String> l3 = l2.subList(11, 11);
+        System.out.println(l3);
+        try {
+            l2.subList(12, 11);
+        } catch (Exception e) {
+            System.err.println(e);
+        }
+
+        System.out.println("\n---------------------------------------");
+        System.out.println("test toArray()");
+        Object[] ar1 = l2.toArray();
+        for (Object obj : ar1) {
+            System.out.print(obj + " ");
+        }
+
+        System.out.println("\n---------------------------------------");
+        System.out.println("test toArray(T[] a) small size a");
+        ArrayListASDV<Integer> listX = new ArrayListASDV();
+        listX.add(10);
+        listX.add(20);
+        Integer[] a1
+                = {
+                    1
+                };
+        ar = listX.toArray(ar);
+        for (int i = 0; i < ar.length; ++i) {
+            System.out.println(ar[i]);
+        }
+        System.out.println("\n---------------------------------------");
+        System.out.println("test toArray(T[] a) Big size a");
+        ArrayListASDV<A1> listA1 = new ArrayListASDV();
+        listA1.add(new A1(100));
+
+        A1[] a11
+                = {
+                    new A1(-1), new A1(-2), new A1(3)
+                };
+        listA1.toArray(a11);
+        for (int i = 0; i < a11.length; ++i) {
+            System.out.println(a11[i]);
+        }
+
+        System.out.println("");
+        System.out.println("\n---------------------------------------");
+        System.out.println("test Iterator()");
+
+        System.out.println(list2);
+
+        Iterator<String> it = list2.iterator();
+
+        while (it.hasNext()) {
+            System.out.print(it.next() + " ");
+        }
+        System.out.println("");
+
+        System.out.println("\n---------------------------------------");
+        System.out.println("test ListIterator1()");
+        ArrayListASDV<Integer> li3 = new ArrayListASDV();
+        li3.add(10);
+        li3.add(20);
+        li3.add(30);
+        li3.add(40);
+        System.out.println(li3);
+        ListIterator<Integer> li = li3.listIterator(2);
+        while (li.hasNext()) {
+            System.out.print("\tnext index: " + li.nextIndex());
+            System.out.print("\tprevious index: " + li.previousIndex());
+            System.out.print("\t" + li.next());
+        }
+        System.out.println("");
+        while (li.hasPrevious()) {
+            System.out.print("\tnext index: " + li.nextIndex());
+            System.out.print("\tprevious index: " + li.previousIndex());
+            System.out.print("\t" + li.previous());
+        }
+        System.out.println("");
+        System.out.println("next index: " + li.nextIndex());
+        System.out.println("previous index: " + li.previousIndex());
+
+        System.out.println("\n--------------------------removeAll-------------");
+        System.out.println("test forEachRemaining()");
+        //System.out.println(li.next());
+        li.forEachRemaining(new Consumer<Integer>() {
+            @Override
+            public void accept(Integer t) {
+                System.out.print(t + 1 + " ");
+            }
+        });
+
+        System.out.println("\n---------------------------------------");
+        System.out.println("test containsAll(Collection)");
+
+        List<Integer> ar33 = Arrays.asList(new Integer[]{
+            10, 20
+        });
+        System.out.println(li3.containsAll(ar33));
+        ar33 = Arrays.asList(new Integer[]{
+            10, -1
+        });
+        System.out.println(li3.containsAll(ar33));
+
+        System.out.println("\n---------------------------------------");
+        System.out.println("test removeAll(Collection)");
+
+        li3.add(10);
+        li3.add(11);
+        li3.add(10);
+        System.out.println(li3);
+        ar33 = Arrays.asList(new Integer[]{
+            10
+        });
+        System.out.println(li3.removeAll(ar33));
+        System.out.println(li3);
+        List<Object> oar = Arrays.asList(new Object[]{
+            3.3, 40, "abc"
+        });
+        try {
+            li3.removeAll(oar);
+        } catch (ClassCastException e) {
+            Thread.sleep(100);
+            System.err.println(e);
+        }
+        System.out.println(li3);
+        List<A1> sar = Arrays.asList(new A1[]{
+            new A1(999)
+        });
+        try {
+            li3.removeAll(sar);
+        } catch (ClassCastException e) {
+            Thread.sleep(100);
+            System.err.println(e);
+        }
+        System.out.println(li3);
+
+        System.out.println("\n---------------------------------------");
+        System.out.println("test retainAll(Collection)");
+        ar33 = Arrays.asList(new Integer[]{
+            30
+        });
+        li3.retainAll(ar33);
+        System.out.println(li3);
+        System.out.println("\n---------------------------------------");
+        System.out.println("test addAll(Collection)");
+        ar33 = Arrays.asList(new Integer[]{
+            1, 2, 3, 4
+        });
+        li3.addAll(ar33);
+        System.out.println(li3);
+        System.out.println("\n---------------------------------------");
+        System.out.println("test addAll(index, Collection)");
+        ar33 = Arrays.asList(new Integer[]{
+            100, 200, 300
+        });
+        li3.addAll(2, ar33);
+        System.out.println(li3);
+    }
+
+}
+
+class A1 implements Consumer<A1> {
+
+    int x;
+
+    public A1(int x) {
+        this.x = x;
+    }
+
+    @Override
+    public String toString() {
+        return "A1{" + "x=" + x + '}';
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        final A1 other = (A1) obj;
+        if (this.x != other.x) {
+            return false;
+        }
+        return true;
+    }
+
+    @Override
+    public void accept(A1 t) {
+        System.out.println(t.x * t.x);
+
+    }
+
+}
+
+
+ diff --git a/Semester 3/Assignments/MP4_CalebFontenot/pom.xml b/Semester 3/Assignments/MP4_CalebFontenot/pom.xml new file mode 100644 index 0000000..ab4f852 --- /dev/null +++ b/Semester 3/Assignments/MP4_CalebFontenot/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + edu.slcc.asdv.caleb + MP4_CalebFontenot + 1.0-SNAPSHOT + jar + + UTF-8 + 17 + 17 + edu.slcc.asdv.caleb.mp4_calebfontenot.MP4_CalebFontenot + + \ No newline at end of file diff --git a/Semester 3/Assignments/MP4_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/mp4_calebfontenot/ArrayListASDV.java b/Semester 3/Assignments/MP4_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/mp4_calebfontenot/ArrayListASDV.java new file mode 100644 index 0000000..a93244e --- /dev/null +++ b/Semester 3/Assignments/MP4_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/mp4_calebfontenot/ArrayListASDV.java @@ -0,0 +1,975 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package edu.slcc.asdv.caleb.mp4_calebfontenot; + +/** + * + * @author caleb + */ +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.NoSuchElementException; +import java.util.Objects; +import java.util.function.Consumer; + +/** + * + * @author ASDV2 + */ +public class ArrayListASDV + implements Serializable, Cloneable, List { + + private E[] list; + private int index;//the index to add at ( length of array) + + //private Class type; + /** + * Constructs an empty list with an initial capacity of three. + * + */ + public ArrayListASDV() { + list = (E[]) new Object[3]; + index = 0; + } + + /** + * Constructs an empty list with the specified initial capacity. + * + * @param initialCapacity - the initial capacity of the list + * @throws IllegalArgumentException - if the specified initial capacity is negative + */ + public ArrayListASDV(int initialCapacity) { + if (initialCapacity < 0) { + throw new IllegalArgumentException("initialCapacity id negative: " + initialCapacity); + } + list = (E[]) new Object[initialCapacity]; + index = 0; + + } + + /** + * Double the size of the current list and copies to it the old list + * + * @return the new array. + */ + private E[] doubleSizeOfList() { + list = this.toArray((E[]) new Object[list.length + list.length]); + return this.list; + + } + + /** + * Constructs a list containing the elements of the specified collection, in the order they are returned by the collection's iterator. + * + * @param c - the collection whose elements are to be placed into this + * @throws NullPointerException - if the specified collection is null + * + * + */ + public ArrayListASDV(Collection c) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + /** + * Returns true if this collection changed as a result of the call. false if this collection does not permit duplicates and already contains the specified element. + * + * @param e - element whose presence in this collection is to be ensured + * + * @return true if this collection changed as a result of the call + * @throws ClassCastException - if the class of the specified element prevents it from being added to this collection + * @throws NullPointerException - if the specified element is null and this collection does not permit null elements + * @throws IllegalArgumentException - if some property of the element prevents it from being added to this collection + */ + @Override + public boolean add(E e) { + if (e == null) { + throw new NullPointerException("null parameter"); + } + + list[index++] = e; + if (index >= list.length * 0.75) { + doubleSizeOfList(); + } + return true; + } + + /** + * Returns the number of elements in this list. + * + * @return the number of elements in this list. + */ + @Override + public int size() { + return index; + } + + @Override + public String toString() { + String s = "ArrayListASDV["; + + for (int i = 0; i < index; ++i) { + s += list[i] + " "; + } + s += "]"; + + return s; + } + + /** + * Returns true if this list contains no elements. + * + * @return true if this list contains no elements + * + */ + @Override + public boolean isEmpty() { + return this.index == 0; + } + + /** + * Returns true if this list contains the specified element. More formally, returns true if and only if this list contains at least one element e such that (o==null ? e==null : o.equals(e)). + * + * @param o - element whose presence in this list is to be tested + * + * @return true if this list contains the specified element + * + */ + public boolean contains(Object o) { + + if (o == null) { + return false; + } + for (int i = 0; i < this.index; i++) { + if (o.equals(this.list[i])) { + return true; + } + } + return false; + + } + + /** + * Returns an array containing all of the elements in this list in proper sequence (from first to last element). The returned array will be "safe" in that no references to it are maintained by this list. (In other words, this method must allocate a new array). The caller is thus free to modify the returned array. This method acts as bridge between array-based and collection-based APIs. Returns: an array containing all of the elements in this list in proper sequence + * + * @return an array containing all of the elements in this list in proper sequence + */ + @Override + public Object[] toArray() { + Object[] returnArray = new Object[index]; + for (int i = 0; i < index; ++i) { + Object objCopy = list[i]; + returnArray[i] = objCopy; + } + return returnArray; + } + + /** + * Removes the first occurrence of the specified element from this list, if it is present. If the list does not contain the element, it is unchanged. More formally, removes the element with the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))) (if such an element exists). Returns true if this list contained the specified element (or equivalently, if this list changed as a result of the call). + * + * @param o - element to be removed from this list, if present + * @return true if this list contained the specified element + */ + @Override + public boolean remove(Object o) { + if (o == null) { + return false; + } + Object[] newArray = new Object[index]; + int i = 0; + for (Object arrayElement : list) { + try { + if (!arrayElement.equals(o)) { + newArray[i] = arrayElement; + } + if ((index - 1) > i) { + ++i; + } + } catch (NullPointerException ex) { + continue; + } + + } + --index; + list = (E[]) newArray; + return true; + } + + /** + * Removes all of the elements from this list. The list will be empty after this call returns. Note: Traverse the array and set all of its elements to null. Set its index to zero. + */ + @Override + public void clear() { + for (int i = 0; i < list.length; ++i) { + list[i] = null; + } + index = 0; + } + + /** + * Returns the element at the specified position in this list. + * + * @param index of the element to return + * @return the element at the specified position in this list + * @throws IndexOutOfBoundsException - if the index is out of range (index GE 0 || index GE size()) + */ + @Override + public E get(int index) { + return list[index]; + } + + /** + * Replaces the element at the specified position in this list with the specified element. + * + * @param index - index of the element to replace + * @param element - element to be stored at the specified position + * @return the element previously at the specified position + * @throws IndexOutOfBoundsException - if the index is out of range (index GE 0 || index GE size()) + */ + @Override + public E set(int index, E element) { + return list[index] = element; + } + + /** + * Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices). + * + * @param index - index at which the specified element is to be inserted element + * @param - element to be inserted + * @throws NullPointerException - if the specified element is null and this collection does not permit null elements + * @throws IndexOutOfBoundsException - if the index is out of range (index GE 0 || index GE size()) + */ + public void add(int index, E element) { + if (element == null) { + throw new NullPointerException("cant add null"); + } + if (index > this.index || index < 0) { + throw new IndexOutOfBoundsException("cant add at this index"); + } + + // Check if the list needs to be resized + if (this.index >= list.length) { + doubleSizeOfList(); + } + + // Shift elements to the right to make space for the new element + for (int i = this.index; i > index; i--) { + list[i] = list[i - 1]; + } + + // Insert the new element at the specified index + list[index] = element; + this.index++; + } + + /** + * Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices). + * + * @param index - the index of the element to be removed + * @return the element that was removed from the list + * @throws IndexOutOfBoundsException - if the index is out of range (index GE 0 || index GE size()) + */ + public E remove(int index) { + Object removedObject = new Object(); + if (index < 0 || index >= this.index) { + throw new IndexOutOfBoundsException("Index " + index + " out of bounds"); + } + Object[] newArray = new Object[index]; + int j = 0; + for (int i = 0; i < index; ++i) { + try { + if (i != index) { + newArray[j] = list[i]; + } else { + removedObject = list[i]; + } + if ((index - 1) > j) { + ++j; + } + } catch (NullPointerException ex) { + continue; + } + + } + --this.index; + list = (E[]) newArray; + return (E) removedObject; + } + + /** + * Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the lowest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index. Parameters: + * + * @param o - element to search for + * @return the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element + */ + @Override + public int indexOf(Object o) { + for (int i = 0; i < index - 1; i++) { + if (list[i].equals(o)) { + return i; + } + } + + return -1; + } + + /** + * Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the highest index i such that (o==null ? get(i)==null : o.equals(get(i))), or -1 if there is no such index. Parameters: + * + * @param o - element to search for + * @return the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element + */ + @Override + public int lastIndexOf(Object o) { + for (int i = list.length - 1; i >= 0; i--) { + if (list[i] != null && list[i].equals(o)) { + return i; + } + } + return -1; + } + + /** + * Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the returned list is empty.) The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. The returned list supports all of the optional list operations. This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by passing a subList view instead of a whole list. For example, the following idiom removes a range of elements from a list: list.subList(from, to).clear(); + * + * Similar idioms may be constructed for ArrayList.indexOf(Object) and ArrayList.lastIndexOf(Object), and all of the algorithms in the Collections class can be applied to a subList. The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.) + * + * @param fromIndex - low endpoint (inclusive) of the subList + * @param toIndex - high endpoint (exclusive) of the subList + * @return a view of the specified range within this list + * @throws IndexOutOfBoundsException - for an illegal endpoint index value (fromIndex LE 0 || toIndex > size || fromIndex > toIndex) + * @throws IllegalArgumentException - if the endpoint indices are out of order (fromIndex > toIndex) + */ + @Override + public List subList(int fromIndex, int toIndex) { + if (fromIndex < 0 || toIndex > size() || fromIndex > toIndex) { + throw new IndexOutOfBoundsException(); + } + List sublist = new ArrayListASDV<>(); + + for (int i = fromIndex; i < toIndex; i++) { + sublist.add(get(i)); + } + return sublist; + } + + /** + * Returns an array containing all of the elements in this list in proper sequence (from first to last element); the runtime type of the returned array is that of the specified array. If the list fits in the specified array, it is returned therein. Otherwise, a new array is allocated with the runtime type of the specified array and the size of this list. If the list fits in the specified array with room to spare (i.e., the array has more elements than the list), the element in the array immediately following the end of the collection is set to null. (This is useful in determining the length of the list only if the caller knows that the list does not contain any null elements.) + * + * @param a - the array into which the elements of the list are to be stored, if it is big enough; otherwise, a new array of the same runtime type is allocated for this purpose. + * @return an array containing the elements of the list + * @throws ArrayStoreException - if the runtime type of the specified array is not a supertype of the runtime type of every element in this list + * @throws NullPointerException - if the specified array is null + */ + @Override + public T[] toArray(T[] a) { + Class clazz = a.getClass(); + //>length of a is too small + if (a.length < index) // Make a new array of a's runtime type + { + return (T[]) Arrays.copyOf(this.list, + index, + a.getClass()); + } + + //>length of a is good + System.arraycopy(this.list, 0, a, 0, index); + + //>length of a is greater than this list set nulls + if (a.length > index) { + for (int i = index; i < a.length; ++i) { + a[i] = null; + } + } + return a; + + } + + @Override + public Iterator iterator() { + Iterator it = new Iterator() { + int index = 0; + //E[] list = (E[]) new Object[3]; + + @Override + public boolean hasNext() { + if (index == list.length) { + return false; + } + return true; + } + + @Override + public E next() { + return list[index++]; + } + + @Override + public void remove() { + if (index < 1) { + Object[] newList = new Object[--index]; + for (int i = 0; i < index; i++) { + newList[i] = list[i]; + } + list = (E[]) newList; + } + } + + /** + * Performs the given action for each remaining element until all elements have been processed or the action throws an exception- Actions are performed in the order of iteration, if that order is specified- Exceptions thrown by the action are relayed to the caller. + * + * + * @throws NullPointerException - if the specified action is null + */ + @Override + public void forEachRemaining(Consumer action) { + if (action == null) { + throw new NullPointerException("Action is Null"); + } + + while (hasNext()) { + action.accept(next()); + } + } + + }; + return (Iterator) it; + } + + ; + + /** + * Returns a list iterator over the elements in this list (in proper sequence). The returned list iterator is fail-fast. + * + * + * @return a list iterator over the elements in this list (in proper sequence + */ + @Override + public ListIterator listIterator() { + return listIterator(0); + + } + + @Override + public ListIterator listIterator(int index) { + + ListIterator it = new ListIterator() { + //E[] list = (E[]) new Object[3]; + int index; + + /** + * Returns true if this list iterator has more elements when traversing the list in the forward direction. (In other words, returns true if ListIterator.next would return an element rather than throwing an exception.) + * + * @return true if the list iterator has more elements when traversing the list in the forward direction + */ + @Override + public boolean hasNext() { + return next() != null; + } + + /** + * Returns the next element in the list and advances the cursor position. This method may be called repeatedly to iterate through the list, or intermixed with calls to ListIterator.previous to go back and forth. (Note that alternating calls to next and previous will return the same element repeatedly.) + * + * @return the next element in the list + * @throws NoSuchElementException - if the iteration has no next element + */ + @Override + public E next() throws NoSuchElementException { + if (index > list.length) { + throw new NoSuchElementException(); + } + System.out.println("List iterator next() "+ list[index]); + return list[index++]; + } + + @Override + public boolean hasPrevious() { + return index > 0; + } + + @Override + public E previous() { + return list[--index]; + + } + + /** + * Returns the index of the element that would be returned by a subsequent call to next(). (Returns list size if the list iterator is at the end of the list.) + * + * @return the index of the element that would be returned by a subsequent call to next, or list size if the list iterator is at the end of the list + */ + @Override + public int nextIndex() { + return index + 1; + } + + /** + * Returns the index of the element that would be returned by a subsequent call to previous(). (Returns -1 if the list iterator is at the beginning of the list.) + * + * @return the index of the element that would be returned by a subsequent call to previous, or -1 if the list iterator is at the beginning of the list + */ + @Override + public int previousIndex() { + return index - 1; + } + + /** + * Performs the given action for each remaining element until all elements have been processed or the action throws an exception- Actions are performed in the order of iteration, if that order is specified- Exceptions thrown by the action are relayed to the caller. + * + * + * @throws NullPointerException - if the specified action is null + */ + @Override + public void forEachRemaining(Consumer action) { + if (action == null) { + throw new NullPointerException("Action is Null"); + } + + while (hasNext()) { + action.accept(next()); + } + } + + @Override + public void remove() { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void set(E e) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + public void add(E e) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + }; + + return it; + + } + + /** + * + * Returns true if this collection contains all of the elements in the specified collection. + * + * Parameters: c - collection to be checked for containment in this collection Returns: true if this collection contains all of the elements in the specified collection Throws: ClassCastException - if the types of one or more elements in the specified collection are incompatible with this collection (optional) NullPointerException - if the specified collection contains one or more null elements and this collection does not permit null elements (optional), or if the specified collection is null. + * + * @param c - collection to be checked for containment in this collection + * @return true if this collection contains all of the elements in the specified collection. + * @throws ClassCastException - if the types of one or more elements in the specified collection are incompatible with this collection + */ + @Override + public boolean containsAll(Collection c) { + for (Object e : c) { + if (!contains(e)) { + return false; + } + } + return true; + } + + @Override + public boolean addAll(Collection c) { + boolean changed = false; + for (E e : c) { + if (add(e)) { + changed = true; + } + } + + return changed; + } + + @Override + public boolean addAll(int index, Collection c) { + boolean changed = false; + for (E e : c) { + add(index++, e); + changed = true; + } + return changed; + } + + /** + * Removes all of this collection's elements that are also contained in the specified collection (optional operation). After this call returns, this collection will contain no elements in common with the specified collection. + * + * Parameters: c - collection containing elements to be removed from this collection Returns: true if this collection changed as a result of the call Throws: UnsupportedOperationException - if the removeAll method is not supported by this collection ClassCastException - if the types of one or more elements in this collection are incompatible with the specified collection (optional) NullPointerException - if this collection contains one or more null elements and the specified collection does not support null elements (optional), or if the specified collection is null + * + * @param c - collection containing elements to be removed from this collection + * @return true if this collection changed as a result of the call + * @throws ClassCastException - if the types of one or more elements in this collection are incompatible with the specified collection + */ + @Override + public boolean removeAll(Collection c) { + Objects.requireNonNull(c); + + List elToKeep = new ArrayList<>(this); + elToKeep.removeAll(c); + elToKeep.removeIf(Objects::isNull); + + clear(); + addAll(elToKeep); + + return !elToKeep.isEmpty(); + } + + /** + * Retains only the elements in this collection that are contained in the specified collection (optional operation). In other words, removes from this collection all of its elements that are not contained in the specified collection. + * + * + * @param c - collection containing elements to be retained in this collection + * @return true if this collection changed as a result of the call + * @throws ClassCastException - if the types of one or more elements in this collection are incompatible with the specified collection (optional) + */ + @Override + public boolean retainAll(Collection c) { + Objects.requireNonNull(c); + + List elToKeep = new ArrayList<>(); + for (E element : this) { + if (c.contains(element)) { + elToKeep.add(element); + } + } + elToKeep.removeIf(Objects::isNull); + + clear(); + addAll(elToKeep); + + return size() != elToKeep.size(); + } + + public static void main(String[] args) + throws ClassNotFoundException, InterruptedException { + ArrayListASDV aaa = new ArrayListASDV(); + aaa.add(1); + aaa.add(2); + aaa.add(3); + aaa.add(4); + + ArrayListASDV list1 = new ArrayListASDV(); + ArrayListASDV list2 = new ArrayListASDV(4); + ArrayListASDV list3 = new ArrayListASDV(4); + + System.out.println("------------------------------ "); + System.out.println("test add"); + list1.add(10); + list1.add(20); + list3.add(new A1(-1)); + list3.add(new A1(-2)); + Integer[] b + = { + 2, 3 + }; + list1.toArray(b); + + list2.add("a"); + try { + list2.add(null); + } catch (NullPointerException e) { + System.err.println(e); + }; + + list2.add("b"); + list2.add("c"); + list2.add("d"); + System.out.println("------------------------------ "); + System.out.println("test toString"); + System.out.println(list1); + System.out.println(list2); + System.out.println(list3); + + System.out.println("------------------------------ "); + System.out.println("test contains"); + System.out.println("contains E"); + System.out.println("contains c: " + list2.contains("c")); + System.out.println("contains null: " + list2.contains(null)); + System.out.println("contains k: " + list2.contains('k')); + System.out.println(list2); + System.out.println("contains A(-1): " + list3.contains(new A1(-1))); + System.out.println("contains A(-3): " + list3.contains(new A1(-3))); + + System.out.println("------------------------------ "); + System.out.print("test toArray(): "); + Object[] ar = list2.toArray(); + System.out.print("[ "); + for (int i = 0; i < ar.length; ++i) { + System.out.print(ar[i] + " "); + } + System.out.println(" ] "); + + System.out.println("\n---------------------------------------"); + System.out.println("test clear()"); + list2.clear(); + System.out.println(list2); + + System.out.println("\n---------------------------------------"); + System.out.println("test size"); + System.out.println(list2.size()); + + System.out.println("\n---------------------------------------"); + System.out.println("test add(index, element)"); + for (char a = 'Z'; a >= 'A'; --a) { + System.out.println("array size: " + list2.size()); + list2.add(0, "" + a); + } + System.out.println(list2); + + list2.add(26, "z"); + System.out.println(list2); + + list2.add(list2.size() - 2, "y"); + System.out.println(list2); + + System.out.println("\n---------------------------------------"); + System.out.println("test remove(index)"); + Object o = list2.remove(27); + System.out.println(o); + System.out.println(list2); + + try { + list2.remove(30); + } catch (IndexOutOfBoundsException e) { + System.err.println(e); + } + + System.out.println("\n---------------------------------------"); + System.out.println("test remove(Object)"); + list2.remove("y"); + System.out.println(list2); + System.out.println(list2.remove("not in there")); + + System.out.println("\n---------------------------------------"); + System.out.println("test set(index, Object)"); + list2.set(0, "0"); + list2.set(25, "25"); + System.out.println(list2); + + System.out.println("\n---------------------------------------"); + System.out.println("test indexOf()"); + System.out.println(list2.indexOf("0")); + System.out.println(list2.indexOf("B")); + System.out.println(list2.indexOf("25")); + System.out.println(list2.indexOf("Y")); + System.out.println(list2.indexOf("not there")); + + System.out.println("\n---------------------------------------"); + System.out.println("test lastIndexOf()"); + list2.add(10, "0"); + System.out.println(list2.indexOf("0")); + System.out.println(list2.lastIndexOf("0")); + System.out.println(list2.indexOf("not there")); + System.out.println(list2); + + System.out.println("\n---------------------------------------"); + System.out.println("test sublist(from, to)"); + List l1 = list2.subList(1, 10); + ArrayListASDV l2 = (ArrayListASDV) list2.subList(11, 26); + + System.out.println(l1); + System.out.println(l2); + List l3 = l2.subList(11, 11); + System.out.println(l3); + try { + l2.subList(12, 11); + } catch (Exception e) { + System.err.println(e); + } + + System.out.println("\n---------------------------------------"); + System.out.println("test toArray()"); + Object[] ar1 = l2.toArray(); + for (Object obj : ar1) { + System.out.print(obj + " "); + } + + System.out.println("\n---------------------------------------"); + System.out.println("test toArray(T[] a) small size a"); + ArrayListASDV listX = new ArrayListASDV(); + listX.add(10); + listX.add(20); + Integer[] a1 + = { + 1 + }; + ar = listX.toArray(ar); + for (int i = 0; i < ar.length; ++i) { + System.out.println(ar[i]); + } + System.out.println("\n---------------------------------------"); + System.out.println("test toArray(T[] a) Big size a"); + ArrayListASDV listA1 = new ArrayListASDV(); + listA1.add(new A1(100)); + + A1[] a11 + = { + new A1(-1), new A1(-2), new A1(3) + }; + listA1.toArray(a11); + for (int i = 0; i < a11.length; ++i) { + System.out.println(a11[i]); + } + + System.out.println(""); + System.out.println("\n---------------------------------------"); + System.out.println("test Iterator()"); + + System.out.println(list2); + + Iterator it = list2.iterator(); + + while (it.hasNext()) { + System.out.print(it.next() + " "); + } + System.out.println(""); + + System.out.println("\n---------------------------------------"); + System.out.println("test ListIterator1()"); + ArrayListASDV li3 = new ArrayListASDV(); + li3.add(10); + li3.add(20); + li3.add(30); + li3.add(40); + System.out.println(li3); + ListIterator li = li3.listIterator(2); + while (li.hasNext()) { + System.out.print("\tnext index: " + li.nextIndex()); + System.out.print("\tprevious index: " + li.previousIndex()); + System.out.print("\t" + li.next()); + } + System.out.println(""); + while (li.hasPrevious()) { + System.out.print("\tnext index: " + li.nextIndex()); + System.out.print("\tprevious index: " + li.previousIndex()); + System.out.print("\t" + li.previous()); + } + System.out.println(""); + System.out.println("next index: " + li.nextIndex()); + System.out.println("previous index: " + li.previousIndex()); + + System.out.println("\n--------------------------removeAll-------------"); + System.out.println("test forEachRemaining()"); + System.out.println(li.next()); + li.forEachRemaining(new Consumer() { + @Override + public void accept(Integer t) { + System.out.print(t + 1 + " "); + } + }); + + System.out.println("\n---------------------------------------"); + System.out.println("test containsAll(Collection)"); + + List ar33 = Arrays.asList(new Integer[]{ + 10, 20 + }); + System.out.println(li3.containsAll(ar33)); + ar33 = Arrays.asList(new Integer[]{ + 10, -1 + }); + System.out.println(li3.containsAll(ar33)); + + System.out.println("\n---------------------------------------"); + System.out.println("test removeAll(Collection)"); + + li3.add(10); + li3.add(11); + li3.add(10); + System.out.println(li3); + ar33 = Arrays.asList(new Integer[]{ + 10 + }); + System.out.println(li3.removeAll(ar33)); + System.out.println(li3); + List oar = Arrays.asList(new Object[]{ + 3.3, 40, "abc" + }); + try { + li3.removeAll(oar); + } catch (ClassCastException e) { + Thread.sleep(100); + System.err.println(e); + } + System.out.println(li3); + List sar = Arrays.asList(new A1[]{ + new A1(999) + }); + try { + li3.removeAll(sar); + } catch (ClassCastException e) { + Thread.sleep(100); + System.err.println(e); + } + System.out.println(li3); + + System.out.println("\n---------------------------------------"); + System.out.println("test retainAll(Collection)"); + ar33 = Arrays.asList(new Integer[]{ + 30 + }); + li3.retainAll(ar33); + System.out.println(li3); + System.out.println("\n---------------------------------------"); + System.out.println("test addAll(Collection)"); + ar33 = Arrays.asList(new Integer[]{ + 1, 2, 3, 4 + }); + li3.addAll(ar33); + System.out.println(li3); + System.out.println("\n---------------------------------------"); + System.out.println("test addAll(index, Collection)"); + ar33 = Arrays.asList(new Integer[]{ + 100, 200, 300 + }); + li3.addAll(2, ar33); + System.out.println(li3); + } + +} + +class A1 implements Consumer { + + int x; + + public A1(int x) { + this.x = x; + } + + @Override + public String toString() { + return "A1{" + "x=" + x + '}'; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final A1 other = (A1) obj; + if (this.x != other.x) { + return false; + } + return true; + } + + @Override + public void accept(A1 t) { + System.out.println(t.x * t.x); + + } + +} diff --git a/Semester 3/Assignments/MP4_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/mp4_calebfontenot/MP4_CalebFontenot.java b/Semester 3/Assignments/MP4_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/mp4_calebfontenot/MP4_CalebFontenot.java new file mode 100644 index 0000000..9c7fdfc --- /dev/null +++ b/Semester 3/Assignments/MP4_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/mp4_calebfontenot/MP4_CalebFontenot.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package edu.slcc.asdv.caleb.mp4_calebfontenot; + +/** + * + * @author caleb + */ +public class MP4_CalebFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/A1.html b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/A1.html new file mode 100644 index 0000000..ff02ed8 --- /dev/null +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/A1.html @@ -0,0 +1,72 @@ + + + +A1.java + + + + +
/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A1.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 edu.slcc.asdv.caleb.javafxballswithcomparator;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ *
+ * @author caleb
+ */
+public class A1 implements Comparable<A1> {
+    int x;
+    public A1() {}
+    public A1(int x) {this.x = x;}
+    @Override
+    public int compareTo(A1 o)
+    {
+        return this.x - o.x;
+    }
+
+    @Override
+    public String toString()
+    {
+        return "A1{" + "x=" + x + '}';
+    }
+    public static void main(String[] args)
+    {
+        System.out.println("Sorting in ascending order");
+        List<A1> list1 = Arrays.asList(new A1(3), new A1(), new A1(2));
+        
+        Collections.sort(list1);
+        System.out.println(list1);
+        
+        System.out.println("Sorting in descending order");
+        Collections.sort(list1, Collections.reverseOrder());
+        System.out.println(list1);
+    }
+}
+
+
+ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/A2.html b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/A2.html new file mode 100644 index 0000000..5fe78d0 --- /dev/null +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/A2.html @@ -0,0 +1,90 @@ + + + +A2.java + + + + +
/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A2.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 edu.slcc.asdv.caleb.javafxballswithcomparator;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ *
+ * @author caleb
+ */
+public class A2 {
+
+    int x;
+
+    public A2() {
+    }
+
+    public A2(int x) {
+        this.x = x;
+    }
+
+    @Override
+    public String toString() {
+        return "A2{" + "x=" + x + '}';
+    }
+
+    public static void main(String[] args) {
+        List<A2> list1 = Arrays.asList(new A2(4), new A2(), new A2(2));
+        Comparator<A2> c = new Comparator<A2>() {
+            @Override
+            public int compare(A2 o1, A2 o2) {
+                return o1.x - o2.x;
+            }
+        };
+        Comparator<A2> c2 = new Comparator<A2>() {
+            @Override
+            public int compare(A2 o1, A2 o2) {
+                int returnVal = 0;
+                if(o1.x > o2.x) {
+                    returnVal = -1;
+                } else {
+                    returnVal = 0;
+                }
+                return returnVal;
+            }
+        };
+        System.out.println("Sorting in ascending order");
+        Collections.sort(list1, c);
+        System.out.println(list1);
+        System.out.println("Sorting in desending order");
+        Collections.sort(list1,c2);
+        System.out.println(list1);
+    }
+
+}
+
+
+ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/A3.html b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/A3.html new file mode 100644 index 0000000..d9c1b48 --- /dev/null +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/A3.html @@ -0,0 +1,93 @@ + + + +A3.java + + + + +
/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A3.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 edu.slcc.asdv.caleb.javafxballswithcomparator;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ *
+ * @author caleb
+ */
+public class A3 {
+
+    int x;
+
+    public A3() {
+    }
+
+    public A3(int x) {
+        this.x = x;
+    }
+
+    @Override
+    public String toString() {
+        return "A2{" + "x=" + x + '}';
+    }
+
+    public static Comparator<A3> comparator() {
+        Comparator<A3> c = new Comparator<A3>() {
+            @Override
+            public int compare(A3 o1, A3 o2) {
+                return o1.x - o2.x;
+            }
+        };
+        return c;
+    }
+
+    public static Comparator<A3> comparatorReverse() {
+        Comparator<A3> c = new Comparator<A3>() {
+            @Override
+            public int compare(A3 o1, A3 o2) {
+                return o1.x > o2.x ? -1 : 0;
+            }
+        };
+        return c;
+    }
+
+    public static void main(String[] args) {
+        List<A3> list1 = Arrays.asList(new A3(4), new A3(), new A3(2));
+
+        System.out.println("Sorting in ascending order");
+        Collections.sort(list1, A3.comparator());
+        System.out.println(list1);
+        System.out.println("Sorting in desending order");
+        Collections.sort(list1, A3.comparatorReverse());
+        System.out.println(list1);
+    }
+
+}
+
+
+ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/A4.html b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/A4.html new file mode 100644 index 0000000..4ef57b2 --- /dev/null +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/A4.html @@ -0,0 +1,110 @@ + + + +A4.java + + + + +
/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A4.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 edu.slcc.asdv.caleb.javafxballswithcomparator;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+/**
+ *
+ * @author caleb
+ */
+public class A4<E extends Comparable<E>> {
+
+    E x;
+
+    public A4() {}
+    public A4(E x) {this.x = x;}
+
+    public static Comparator<A4> comparator() {
+        Comparator<A4> c = new Comparator<A4>() {
+            @Override
+            public int compare(A4 o1, A4 o2) {
+                return o1.x.compareTo(o2.x);
+            }
+        };
+        return c;
+    }
+        public static Comparator<A4> comparatorReverse() {
+        Comparator<A4> c = new Comparator<A4>() {
+            @Override
+            public int compare(A4 o1, A4 o2) {
+                switch (o1.x.compareTo(o2.x)) {
+                    case -1:
+                        return 1;
+                    case 0:
+                        return 0;
+                    case 1:
+                        return -1;
+                }
+                return -112315234;
+            }
+        };
+        return c;
+    }
+
+    @Override
+    public String toString() {
+        return "A4{" + "x=" + x + '}';
+    }
+
+    public static void main(String[] args) {
+        System.out.println("Sorting in ascending order");
+        List<A4> list1 = Arrays.asList(
+                new A4(new Integer(4)),
+                new A4(new Integer(1)),
+                new A4(new Integer(2))
+        );
+        Collections.sort(list1, A4.comparator());
+        List<A4> list2 = Arrays.asList(
+                new A4(new String("once")),
+                new A4(new String("upon")),
+                new A4(new String("a")),
+                new A4(new String("time")),
+                new A4(new String("in")),
+                new A4(new String("America"))
+        );
+        Collections.sort(list2, A4.comparator());
+        System.out.println(list1);
+        System.out.println(list2);
+        System.out.println("Now, in descending order:");
+        Collections.sort(list2, A4.comparatorReverse());
+        System.out.println(list2);
+        
+    }
+
+}
+
+
+ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/Circle.html b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/Circle.html new file mode 100644 index 0000000..b731fca --- /dev/null +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/Circle.html @@ -0,0 +1,75 @@ + + + +Circle.java + + + + +
/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/Circle.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 edu.slcc.asdv.caleb.javafxballswithcomparator;
+
+/**
+ *
+ * @author caleb
+ */
+public class Circle extends GeometricObject {
+  private double radius;
+
+  public Circle() {
+  }
+
+  public Circle(double radius) {
+    this.radius = radius;
+  }
+
+  /** Return radius */
+  public double getRadius() {
+    return radius;
+  }
+
+  /** Set a new radius */
+  public void setRadius(double radius) {
+    this.radius = radius;
+  }
+
+  @Override /** Return area */
+  public double getArea() {
+    return radius * radius * Math.PI;
+  }
+
+  /** Return diameter */
+  public double getDiameter() {
+    return 2 * radius;
+  }
+
+  @Override /** Return perimeter */
+  public double getPerimeter() {
+    return 2 * radius * Math.PI;
+  }
+
+  /* Print the circle info */
+  public void printCircle() {
+    System.out.println("The circle is created " + getDateCreated() +
+      " and the radius is " + radius);
+  }
+}
+
+
+ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/GeometricObject.html b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/GeometricObject.html new file mode 100644 index 0000000..fef62e3 --- /dev/null +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/GeometricObject.html @@ -0,0 +1,89 @@ + + + +GeometricObject.java + + + + +
/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/GeometricObject.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 edu.slcc.asdv.caleb.javafxballswithcomparator;
+
+/**
+ *
+ * @author caleb
+ */
+public abstract class GeometricObject {
+  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();
+}
+
+
+
+ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/GeometricObjectComparator.html b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/GeometricObjectComparator.html new file mode 100644 index 0000000..647945e --- /dev/null +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/GeometricObjectComparator.html @@ -0,0 +1,42 @@ + + + +GeometricObjectComparator.java + + + + +
/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/GeometricObjectComparator.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 edu.slcc.asdv.caleb.javafxballswithcomparator;
+
+/**
+ *
+ * @author caleb
+ */
+import java.util.Comparator;
+
+public class GeometricObjectComparator
+    implements Comparator<GeometricObject>, java.io.Serializable {
+  public int compare(GeometricObject o1, GeometricObject o2) {
+    return o1.getArea() > o2.getArea() ? 
+        1 : o1.getArea() == o2.getArea() ? 0 : -1;
+  }
+}
+
+
+ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/MultipleBallsWithComparator.html b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/MultipleBallsWithComparator.html new file mode 100644 index 0000000..50fe89c --- /dev/null +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/MultipleBallsWithComparator.html @@ -0,0 +1,209 @@ + + + +MultipleBallsWithComparator.java + + + + +
/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/MultipleBallsWithComparator.java
+
+package edu.slcc.asdv.caleb.javafxballswithcomparator;
+
+import javafx.animation.KeyFrame;
+import javafx.animation.Timeline;
+import javafx.application.Application;
+import javafx.beans.property.DoubleProperty;
+import javafx.geometry.Pos;
+import javafx.scene.Node;
+import javafx.stage.Stage;
+import javafx.scene.Scene;
+import javafx.scene.control.Button;
+import javafx.scene.control.ScrollBar;
+import javafx.scene.layout.BorderPane;
+import javafx.scene.layout.HBox;
+import javafx.scene.layout.Pane;
+import javafx.scene.paint.Color;
+import javafx.scene.shape.Circle;
+import javafx.util.Duration;
+
+public class MultipleBallsWithComparator extends Application
+{
+
+    @Override // Override the start method in the Application class
+    public void start(Stage primaryStage)
+    {
+        MultipleBallPane ballPane = new MultipleBallPane();
+
+        Button btAdd = new Button("+");
+        Button btSubtract = new Button("-");
+        HBox hBox = new HBox(10);
+        hBox.getChildren().addAll(btAdd, btSubtract);
+        hBox.setAlignment(Pos.CENTER);
+
+        // Add or remove a ball
+        btAdd.setOnAction(e -> ballPane.add());
+        btSubtract.setOnAction(e -> ballPane.subtract());
+
+        // Pause and resume animation
+        ballPane.setOnMousePressed(e -> ballPane.pause());
+        ballPane.setOnMouseReleased(e -> ballPane.play());
+
+        // Use a scroll bar to control animation speed
+        ScrollBar sbSpeed = new ScrollBar();
+        sbSpeed.setMax(20);
+        sbSpeed.setValue(10);
+        ballPane.rateProperty().bind(sbSpeed.valueProperty());
+
+        BorderPane pane = new BorderPane();
+        pane.setCenter(ballPane);
+        pane.setTop(sbSpeed);
+        pane.setBottom(hBox);
+
+        // Create a scene and place the pane in the stage
+        Scene scene = new Scene(pane, 250, 150);
+        primaryStage.setTitle("Multiple Bouncing Balls"); // Set the stage title
+        primaryStage.setScene(scene); // Place the scene in the stage
+        primaryStage.show(); // Display the stage
+    }
+
+    private class MultipleBallPane extends Pane
+    {
+
+        private Timeline animation;
+
+        public MultipleBallPane()
+        {
+            // Create an animation for moving the ball
+            animation = new Timeline(
+                    new KeyFrame(Duration.millis(50), e -> moveBall()));
+            animation.setCycleCount(Timeline.INDEFINITE);
+            animation.play(); // Start animation
+        }
+
+        public void add()
+        {
+            Color color = new Color(Math.random(),
+                    Math.random(), Math.random(), 0.5);
+            getChildren().add(new Ball(30, 30, Math.random() * 16 + 5, color));
+        }
+
+        public void subtract()
+        {
+            if (getChildren().size() > 0)
+              {
+                    //> Locate the ball with the largest radius
+                Ball ball = (Ball) (getChildren().get(0));
+                for (Node node : getChildren())
+                  {
+                    if (((Ball) node).getRadius() > ball.getRadius())
+                      {
+                        ball = (Ball) node;
+                      }
+                  }
+
+                getChildren().remove(ball);
+              }
+        }
+
+        public void play()
+        {
+            animation.play();
+        }
+
+        public void pause()
+        {
+            animation.pause();
+        }
+
+        public void increaseSpeed()
+        {
+            animation.setRate(animation.getRate() + 0.1);
+        }
+
+        public void decreaseSpeed()
+        {
+            animation.setRate(
+                    animation.getRate() > 0 ? animation.getRate() - 0.1 : 0);
+        }
+
+        public DoubleProperty rateProperty()
+        {
+            return animation.rateProperty();
+        }
+
+        protected void moveBall()
+        {
+            for (Node node : this.getChildren())
+              {
+                Ball ball = (Ball) node;
+                // Check boundaries
+                if (ball.getCenterX() < ball.getRadius()
+                        || ball.getCenterX() > getWidth() - ball.getRadius())
+                  {
+                    ball.dx *= -1; // Change ball move direction
+                  }
+                if (ball.getCenterY() < ball.getRadius()
+                        || ball.getCenterY() > getHeight() - ball.getRadius())
+                  {
+                    ball.dy *= -1; // Change ball move direction
+                  }
+
+                // Adjust ball position
+                ball.setCenterX(ball.dx + ball.getCenterX());
+                ball.setCenterY(ball.dy + ball.getCenterY());
+              }
+        }
+    }
+
+    class Ball extends Circle implements Comparable<Ball>
+    {
+
+        private double dx = 1, dy = 1;
+
+        Ball(double x, double y, double radius, Color color)
+        {
+            super(x, y, radius);
+            setFill(color); // Set ball color
+        }
+
+        public int compareTo(Ball b)
+        {
+            if (this.getRadius() - b.getRadius() < 0)
+              {
+                return -1;
+              }
+            else if (this.getRadius() - b.getRadius() == 0)
+              {
+                return 0;
+              }
+            else
+              {
+                return 1;
+              }
+        }
+    }
+
+    /**
+     * The main method is only needed for the IDE with limited JavaFX support.
+     * Not needed for running from the command line.
+     */
+    public static void main(String[] args)
+    {
+        launch(args);
+    }
+}
+
+
+ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/Rectangle.html b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/Rectangle.html new file mode 100644 index 0000000..4717af7 --- /dev/null +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/Rectangle.html @@ -0,0 +1,76 @@ + + + +Rectangle.java + + + + +
/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/Rectangle.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 edu.slcc.asdv.caleb.javafxballswithcomparator;
+
+/**
+ *
+ * @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;
+  }
+
+  /** Return width */
+  public double getWidth() {
+    return width;
+  }
+
+  /** Set a new width */
+  public void setWidth(double width) {
+    this.width = width;
+  }
+
+  /** Return height */
+  public double getHeight() {
+    return height;
+  }
+
+  /** Set a new height */
+  public void setHeight(double height) {
+    this.height = height;
+  }
+
+  @Override /** Return area */
+  public double getArea() {
+    return width * height;
+  }
+
+  @Override /** Return perimeter */
+  public double getPerimeter() {
+    return 2 * (width + height);
+  }
+}
+
+
+
+ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/TestArrayAndLinkedList.html b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/TestArrayAndLinkedList.html new file mode 100644 index 0000000..60afd77 --- /dev/null +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/TestArrayAndLinkedList.html @@ -0,0 +1,68 @@ + + + +TestArrayAndLinkedList.java + + + + +
/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/TestArrayAndLinkedList.java
+
+package edu.slcc.asdv.caleb.javafxballswithcomparator;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+
+public class TestArrayAndLinkedList
+{
+
+    public static void main(String[] args)
+    {
+        List<Integer> arrayList = new ArrayList<>();
+        arrayList.add(1);
+        arrayList.add(2);
+        arrayList.add(3);
+        arrayList.add(1);
+        arrayList.add(4);
+        arrayList.add(0, 10);
+        arrayList.add(3, 30);
+
+        System.out.println("A list of integers in the array list:");
+        System.out.println(arrayList);
+
+        LinkedList<Object> linkedList = new LinkedList<>(arrayList);
+        linkedList.add(1, "red");
+        linkedList.removeLast();
+        linkedList.addFirst("green");
+
+        System.out.println("Display the linked list backward:");
+        ListIterator<Object> listIterator = linkedList.listIterator();
+        while (listIterator.hasNext())
+          {
+            System.out.print(listIterator.next() + " ");
+          }
+        System.out.println();
+
+        System.out.println("Display the linked list backward:");
+        listIterator = linkedList.listIterator(linkedList.size());
+        while (listIterator.hasPrevious())
+          {
+            System.out.print(listIterator.previous() + " ");
+          }
+    }
+}
+
+
+ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/TestComparator.html b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/TestComparator.html new file mode 100644 index 0000000..bf03d4c --- /dev/null +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/TestComparator.html @@ -0,0 +1,53 @@ + + + +TestComparator.java + + + + +
/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/TestComparator.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 edu.slcc.asdv.caleb.javafxballswithcomparator;
+
+/**
+ *
+ * @author caleb
+ */
+import java.util.Comparator;
+
+public class TestComparator {
+  public static void main(String[] args) {
+    GeometricObject g1 = new Rectangle(5, 5);
+    GeometricObject g2 = new Circle(5);
+
+    GeometricObject g = 
+      max(g1, g2, new GeometricObjectComparator());
+    
+    System.out.println("The area of the larger object is " + 
+      g.getArea());
+  }
+  
+  public static GeometricObject max(GeometricObject g1, 
+      GeometricObject g2, Comparator<GeometricObject> c) {
+        return c.compare(g1, g2) > 0 ? g1 : g2;
+  }
+}
+
+
+ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/TestPriorityQueue.html b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/TestPriorityQueue.html new file mode 100644 index 0000000..d5e9447 --- /dev/null +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/TestPriorityQueue.html @@ -0,0 +1,68 @@ + + + +TestPriorityQueue.java + + + + +
/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/TestPriorityQueue.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 edu.slcc.asdv.caleb.javafxballswithcomparator;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.PriorityQueue;
+
+/**
+ *
+ * @author caleb
+ */
+public class TestPriorityQueue {
+    public static void main(String[] args) {
+        PriorityQueue<String> queue1 = new PriorityQueue<>();
+        queue1.offer("Oklahoma");
+        queue1.offer("Indiana");
+        queue1.offer("Georgia");
+        queue1.offer("Texas");
+        
+        System.out.println("Priority queue using Comparable:");
+        while (queue1.size() > 0) {
+            System.out.print(queue1.remove() + " ");
+        }
+        
+        Comparator<String> c = Collections.reverseOrder();
+        PriorityQueue<String> queue2 = new PriorityQueue<>(4, c);
+        queue2.offer("Oklahoma");
+        queue2.offer("Indiana");
+        queue2.offer("Georgia");
+        queue2.offer("Texas");
+        
+        System.out.println("\n\nPriority queue is using Comparator: ");
+        while (queue2.size() > 0) {
+            System.out.print(queue2.remove() + " ");
+        }
+    }
+}
+
+
+ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/TestTheCollections.html b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/TestTheCollections.html new file mode 100644 index 0000000..316661d --- /dev/null +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/Printed HTMLs/TestTheCollections.html @@ -0,0 +1,128 @@ + + + +TestTheCollections.java + + + + +
/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/TestTheCollections.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 edu.slcc.asdv.caleb.javafxballswithcomparator;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Random;
+
+/**
+ *
+ * @author caleb
+ */
+public class TestTheCollections {
+
+    public static void main(String[] args) {
+        System.out.println("Sorting in ascending order");
+        List<String> list1 = Arrays.asList("red", "green", "blue");
+        Collections.sort(list1);
+        System.out.println(list1);
+
+        System.out.println("Sorting in descending order");
+        List<String> list2 = Arrays.asList("yellow", "red", "green", "blue");
+        Collections.sort(list2);
+        System.out.println(list2);
+
+        System.out.println("\nBinary Search");
+        List<Integer> list3
+                = Arrays.asList(2, 4, 7, 10, 11, 45, 50, 59, 60, 66);
+        System.out.println(list3 + " 7 is at index: " + Collections.binarySearch(list3, 7));
+        System.out.println(list3 + " 9 is at index: " + Collections.binarySearch(list3, 9));
+        System.out.println(list3 + " 100 is at index: " + Collections.binarySearch(list3, 100));
+
+        List<String> list4 = new ArrayList<>();
+        list4.addAll(list1);
+        System.out.println(list4 + " red is at index: " + Collections.binarySearch(list4, "red"));
+        System.out.println(list4 + " amber is at index: " + Collections.binarySearch(list4, "amber"));
+        System.out.println(list4 + " brown is at index: " + Collections.binarySearch(list4, "brown"));
+
+        System.out.println("\nReverse the list");
+        List<String> list5 = new ArrayList<>();
+        list5.addAll(list2);
+        System.out.println("Original list: " + list5);
+        Collections.reverse(list5);
+        System.out.println("Reversed list: " + list5);
+
+        System.out.println("\nShuffle lists");
+        List<String> list6 = new ArrayList<>();
+        List<String> list7 = new ArrayList<>();
+        list6.addAll(list2);
+        list7.addAll(list2);
+
+        System.out.println("Original list: " + list6);
+        Collections.shuffle(list6, new Random(20));
+        System.out.println("Shuffled list: " + list6);
+
+        System.out.println("Original list: " + list7);
+        Collections.shuffle(list7, new Random(20));
+        System.out.println("Shuffled list: " + list7);
+        
+        List<String> list8 = new ArrayList<>();
+        list8.addAll(list2);
+        List<String> list9 = Arrays.asList("white", "black");
+        System.out.println("\nCopy into " + list8 + " the list " + list9);
+        Collections.copy(list8, list9);
+        System.out.println(list8);
+        System.out.println("The output for list 8 is [white, black, green, blue].\n"
+                         + "The copy method performs a \n"
+                         + "shallow copy: only the references of the elements fromt he source list are copied."
+        );
+        
+        List<String> list10 = new ArrayList<>();
+        list10.addAll(list1);
+        System.out.println("\nFill the list " + list10 + " with \'black\'.");
+        Collections.fill(list10, "black");
+        System.out.println(list10);
+        
+        
+        /*
+        The disjoint(collection1, collection2) method returns true if the two collections
+        have no elements in common. For example, in the following code, the disjoint(collection1,
+        collectio2) returns false, but the disjoint(collection1, collection3) returns true.
+        */
+        System.out.println("\nCollections.disjoints()");
+        Collection<String> collection1 = Arrays.asList("red", "cyan");
+        Collection<String> collection2 = Arrays.asList("red", "blue");
+        Collection<String> collection3 = Arrays.asList("pink", "tan");
+        System.out.println(Collections.disjoint(collection1, collection2));
+        System.out.println(Collections.disjoint(collection1, collection3));
+        
+        System.out.println("\nFrequency");
+        Collection<String> collection = Arrays.asList("red", "cyan", "red");
+        System.out.println(collection + " red occurs " + Collections.frequency(collection, "red") + " times.");
+
+    }
+}
+
+
+ diff --git a/Semester 3/Assignments/JavaFXBallsWithComparator/labChapter20.pdf b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/labChapter20.pdf similarity index 100% rename from Semester 3/Assignments/JavaFXBallsWithComparator/labChapter20.pdf rename to Semester 3/Assignments/lab7-chapter20_CalebFontenot/labChapter20.pdf diff --git a/Semester 3/Assignments/JavaFXBallsWithComparator/nb-configuration.xml b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/nb-configuration.xml similarity index 99% rename from Semester 3/Assignments/JavaFXBallsWithComparator/nb-configuration.xml rename to Semester 3/Assignments/lab7-chapter20_CalebFontenot/nb-configuration.xml index ab59f8c..4a9c8d7 100644 --- a/Semester 3/Assignments/JavaFXBallsWithComparator/nb-configuration.xml +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/nb-configuration.xml @@ -14,7 +14,7 @@ That way multiple projects can share the same settings (useful for formatting ru Any value defined here will override the pom.xml file value but is only applicable to the current project. --> [{"repository":"php","rule":"S3335"},{"repository":"php","rule":"S3336"},{"repository":"php","rule":"S2002"},{"repository":"php","rule":"S2005"},{"repository":"php","rule":"S3333"},{"repository":"php","rule":"S3334"},{"repository":"Web","rule":"ImgWithoutWidthOrHeightCheck"},{"repository":"php","rule":"S1151"},{"repository":"php","rule":"S3332"},{"repository":"php","rule":"S2001"},{"repository":"php","rule":"S2000"},{"repository":"typescript","rule":"S4798"},{"repository":"javascript","rule":"S3801"},{"repository":"typescript","rule":"S2138"},{"repository":"typescript","rule":"S2376"},{"repository":"java","rule":"S4288"},{"repository":"php","rule":"S5867"},{"repository":"java","rule":"S6211"},{"repository":"java","rule":"S2096"},{"repository":"java","rule":"S6212"},{"repository":"php","rule":"S2011"},{"repository":"typescript","rule":"S4328"},{"repository":"typescript","rule":"S4204"},{"repository":"typescript","rule":"S4324"},{"repository":"Web","rule":"PageWithoutFaviconCheck"},{"repository":"typescript","rule":"S4327"},{"repository":"typescript","rule":"S4326"},{"repository":"typescript","rule":"S3353"},{"repository":"typescript","rule":"S1172"},{"repository":"typescript","rule":"S2260"},{"repository":"java","rule":"S5128"},{"repository":"php","rule":"S2007"},{"repository":"php","rule":"S3337"},{"repository":"php","rule":"S3338"},{"repository":"javascript","rule":"S139"},{"repository":"javascript","rule":"S135"},{"repository":"javascript","rule":"S138"},{"repository":"javascript","rule":"S131"},{"repository":"javascript","rule":"S134"},{"repository":"javascript","rule":"S2817"},{"repository":"typescript","rule":"S3003"},{"repository":"typescript","rule":"S1067"},{"repository":"typescript","rule":"S1066"},{"repository":"Web","rule":"S1829"},{"repository":"java","rule":"S4174"},{"repository":"Web","rule":"IllegalTabCheck"},{"repository":"typescript","rule":"S3499"},{"repository":"typescript","rule":"S3257"},{"repository":"typescript","rule":"S1192"},{"repository":"typescript","rule":"S3498"},{"repository":"php","rule":"S5856"},{"repository":"java","rule":"S2063"},{"repository":"java","rule":"S3030"},{"repository":"java","rule":"S3032"},{"repository":"Web","rule":"DoubleQuotesCheck"},{"repository":"Web","rule":"MaxLineLengthCheck"},{"repository":"java","rule":"S105"},{"repository":"typescript","rule":"S1488"},{"repository":"Web","rule":"LongJavaScriptCheck"},{"repository":"java","rule":"S103"},{"repository":"Web","rule":"WmodeIsWindowCheck"},{"repository":"java","rule":"S104"},{"repository":"java","rule":"S109"},{"repository":"typescript","rule":"S3786"},{"repository":"javascript","rule":"S1821"},{"repository":"java","rule":"S113"},{"repository":"java","rule":"S4248"},{"repository":"php","rule":"S1105"},{"repository":"php","rule":"S1106"},{"repository":"php","rule":"S1121"},{"repository":"typescript","rule":"S3317"},{"repository":"typescript","rule":"S1131"},{"repository":"java","rule":"S2059"},{"repository":"java","rule":"S2057"},{"repository":"java","rule":"S6411"},{"repository":"php","rule":"S1117"},{"repository":"java","rule":"S3052"},{"repository":"typescript","rule":"S881"},{"repository":"php","rule":"S1451"},{"repository":"Web","rule":"NonConsecutiveHeadingCheck"},{"repository":"java","rule":"S126"},{"repository":"typescript","rule":"S5867"},{"repository":"java","rule":"S134"},{"repository":"java","rule":"S4266"},{"repository":"java","rule":"S2196"},{"repository":"java","rule":"S2197"},{"repository":"java","rule":"S118"},{"repository":"typescript","rule":"S1154"},{"repository":"java","rule":"S121"},{"repository":"java","rule":"S122"},{"repository":"php","rule":"S1578"},{"repository":"php","rule":"S5935"},{"repository":"java","rule":"S3047"},{"repository":"php","rule":"S4142"},{"repository":"typescript","rule":"S1441"},{"repository":"java","rule":"S2701"},{"repository":"typescript","rule":"S1440"},{"repository":"php","rule":"S881"},{"repository":"java","rule":"S138"},{"repository":"typescript","rule":"S3514"},{"repository":"java","rule":"S139"},{"repository":"typescript","rule":"S2427"},{"repository":"typescript","rule":"S3512"},{"repository":"typescript","rule":"S2424"},{"repository":"typescript","rule":"S3513"},{"repository":"typescript","rule":"S1451"},{"repository":"Web","rule":"IllegalNamespaceCheck"},{"repository":"xml","rule":"S3419"},{"repository":"typescript","rule":"S3525"},{"repository":"Web","rule":"WhiteSpaceAroundCheck"},{"repository":"typescript","rule":"S3402"},{"repository":"typescript","rule":"S1105"},{"repository":"typescript","rule":"S3524"},{"repository":"java","rule":"S3937"},{"repository":"xml","rule":"S1120"},{"repository":"java","rule":"S1996"},{"repository":"xml","rule":"S3420"},{"repository":"xml","rule":"S3423"},{"repository":"Web","rule":"InternationalizationCheck"},{"repository":"java","rule":"S6073"},{"repository":"css","rule":"S4664"},{"repository":"typescript","rule":"S2208"},{"repository":"typescript","rule":"S4622"},{"repository":"typescript","rule":"S3533"},{"repository":"php","rule":"S2070"},{"repository":"typescript","rule":"S1117"},{"repository":"typescript","rule":"S1116"},{"repository":"java","rule":"S2959"},{"repository":"typescript","rule":"S1110"},{"repository":"Web","rule":"S1436"},{"repository":"xml","rule":"S2321"},{"repository":"php","rule":"S2047"},{"repository":"php","rule":"S2046"},{"repository":"typescript","rule":"S1528"},{"repository":"php","rule":"S2043"},{"repository":"javascript","rule":"S117"},{"repository":"php","rule":"S2042"},{"repository":"php","rule":"S2044"},{"repository":"javascript","rule":"S113"},{"repository":"Web","rule":"MouseEventWithoutKeyboardEquivalentCheck"},{"repository":"javascript","rule":"S4139"},{"repository":"typescript","rule":"S1526"},{"repository":"typescript","rule":"S1525"},{"repository":"php","rule":"NoSonar"},{"repository":"typescript","rule":"S1539"},{"repository":"Web","rule":"IllegalTagLibsCheck"},{"repository":"php","rule":"S2050"},{"repository":"typescript","rule":"S1774"},{"repository":"javascript","rule":"S126"},{"repository":"typescript","rule":"S1530"},{"repository":"javascript","rule":"S121"},{"repository":"typescript","rule":"S1537"},{"repository":"typescript","rule":"S1535"},{"repository":"javascript","rule":"S122"},{"repository":"typescript","rule":"S909"},{"repository":"php","rule":"S5899"},{"repository":"java","rule":"S5194"},{"repository":"typescript","rule":"S3723"},{"repository":"php","rule":"S2260"},{"repository":"typescript","rule":"S1541"},{"repository":"java","rule":"S1711"},{"repository":"javascript","rule":"S1192"},{"repository":"php","rule":"S2278"},{"repository":"php","rule":"S2036"},{"repository":"php","rule":"S2277"},{"repository":"php","rule":"S1067"},{"repository":"php","rule":"S2038"},{"repository":"php","rule":"S2037"},{"repository":"javascript","rule":"S106"},{"repository":"javascript","rule":"S109"},{"repository":"php","rule":"S5783"},{"repository":"javascript","rule":"S3498"},{"repository":"javascript","rule":"S103"},{"repository":"javascript","rule":"S3499"},{"repository":"javascript","rule":"S105"},{"repository":"javascript","rule":"S104"},{"repository":"typescript","rule":"S1438"},{"repository":"java","rule":"S1939"},{"repository":"typescript","rule":"S3973"},{"repository":"javascript","rule":"S100"},{"repository":"java","rule":"S1821"},{"repository":"java","rule":"S1942"},{"repository":"java","rule":"S1943"},{"repository":"java","rule":"S1820"},{"repository":"java","rule":"S1941"},{"repository":"Web","rule":"HeaderCheck"},{"repository":"Web","rule":"UnclosedTagCheck"},{"repository":"typescript","rule":"S2817"},{"repository":"javascript","rule":"S3003"},{"repository":"typescript","rule":"S2933"},{"repository":"java","rule":"S2309"},{"repository":"php","rule":"S126"},{"repository":"css","rule":"S5362"},{"repository":"java","rule":"S4605"},{"repository":"java","rule":"S4604"},{"repository":"java","rule":"S2308"},{"repository":"xml","rule":"S3282"},{"repository":"php","rule":"S2918"},{"repository":"java","rule":"S2301"},{"repository":"java","rule":"S1696"},{"repository":"java","rule":"S1213"},{"repository":"typescript","rule":"S139"},{"repository":"java","rule":"S1698"},{"repository":"java","rule":"S1699"},{"repository":"php","rule":"S1820"},{"repository":"java","rule":"S3750"},{"repository":"javascript","rule":"S1172"},{"repository":"java","rule":"S1451"},{"repository":"php","rule":"S122"},{"repository":"java","rule":"S1694"},{"repository":"java","rule":"S1695"},{"repository":"php","rule":"S1821"},{"repository":"javascript","rule":"S2260"},{"repository":"javascript","rule":"S3353"},{"repository":"javascript","rule":"S4326"},{"repository":"Web","rule":"UnifiedExpressionCheck"},{"repository":"php","rule":"S134"},{"repository":"java","rule":"S1448"},{"repository":"java","rule":"S2658"},{"repository":"java","rule":"S1449"},{"repository":"java","rule":"S3749"},{"repository":"php","rule":"S139"},{"repository":"javascript","rule":"S1067"},{"repository":"javascript","rule":"S1066"},{"repository":"java","rule":"S1200"},{"repository":"Web","rule":"ComplexityCheck"},{"repository":"javascript","rule":"S2376"},{"repository":"typescript","rule":"S3801"},{"repository":"Web","rule":"RequiredAttributeCheck"},{"repository":"javascript","rule":"S2138"},{"repository":"php","rule":"S104"},{"repository":"java","rule":"S3658"},{"repository":"java","rule":"S2208"},{"repository":"java","rule":"S2444"},{"repository":"javascript","rule":"S1154"},{"repository":"java","rule":"S2203"},{"repository":"java","rule":"S2325"},{"repository":"java","rule":"S3414"},{"repository":"typescript","rule":"S2966"},{"repository":"java","rule":"S1106"},{"repository":"java","rule":"S1228"},{"repository":"java","rule":"S1107"},{"repository":"java","rule":"S1108"},{"repository":"java","rule":"S1109"},{"repository":"xml","rule":"S3373"},{"repository":"java","rule":"S1105"},{"repository":"javascript","rule":"S5867"},{"repository":"java","rule":"S4926"},{"repository":"java","rule":"S1774"},{"repository":"javascript","rule":"S1131"},{"repository":"javascript","rule":"S3798"},{"repository":"javascript","rule":"S3317"},{"repository":"Web","rule":"InputWithoutLabelCheck"},{"repository":"javascript","rule":"S881"},{"repository":"xml","rule":"S2260"},{"repository":"java","rule":"S1641"},{"repository":"java","rule":"S2972"},{"repository":"java","rule":"S2973"},{"repository":"java","rule":"S2974"},{"repository":"javascript","rule":"S3786"},{"repository":"javascript","rule":"S1488"},{"repository":"java","rule":"S923"},{"repository":"typescript","rule":"S1821"},{"repository":"javascript","rule":"S1117"},{"repository":"javascript","rule":"S1116"},{"repository":"java","rule":"S1315"},{"repository":"javascript","rule":"S1110"},{"repository":"java","rule":"S1312"},{"repository":"java","rule":"S1314"},{"repository":"java","rule":"S1310"},{"repository":"javascript","rule":"S3533"},{"repository":"javascript","rule":"S2208"},{"repository":"java","rule":"S1309"},{"repository":"java","rule":"S3725"},{"repository":"Web","rule":"DynamicJspIncludeCheck"},{"repository":"Web","rule":"InlineStyleCheck"},{"repository":"java","rule":"S1541"},{"repository":"java","rule":"S2260"},{"repository":"java","rule":"S2141"},{"repository":"php","rule":"S1311"},{"repository":"java","rule":"S2384"},{"repository":"javascript","rule":"S3760"},{"repository":"javascript","rule":"S3523"},{"repository":"javascript","rule":"S3402"},{"repository":"javascript","rule":"S3524"},{"repository":"javascript","rule":"S3525"},{"repository":"xml","rule":"S105"},{"repository":"typescript","rule":"S4157"},{"repository":"xml","rule":"S103"},{"repository":"java","rule":"S2148"},{"repository":"java","rule":"S2143"},{"repository":"java","rule":"S1176"},{"repository":"java","rule":"S1160"},{"repository":"php","rule":"S1200"},{"repository":"java","rule":"S2250"},{"repository":"java","rule":"S818"},{"repository":"java","rule":"S1162"},{"repository":"java","rule":"S4551"},{"repository":"java","rule":"S2131"},{"repository":"javascript","rule":"S1451"},{"repository":"javascript","rule":"S3512"},{"repository":"javascript","rule":"S2424"},{"repository":"javascript","rule":"S3513"},{"repository":"javascript","rule":"S3514"},{"repository":"javascript","rule":"S3757"},{"repository":"javascript","rule":"S3758"},{"repository":"javascript","rule":"S2427"},{"repository":"javascript","rule":"S2428"},{"repository":"javascript","rule":"S1105"},{"repository":"php","rule":"S5915"},{"repository":"php","rule":"S1314"},{"repository":"java","rule":"S1166"},{"repository":"php","rule":"S1799"},{"repository":"java","rule":"S5793"},{"repository":"java","rule":"S1194"},{"repository":"java","rule":"S2162"},{"repository":"java","rule":"S2164"},{"repository":"javascript","rule":"S1440"},{"repository":"javascript","rule":"S1441"},{"repository":"javascript","rule":"S1442"},{"repository":"Web","rule":"MultiplePageDirectivesCheck"},{"repository":"java","rule":"S3254"},{"repository":"java","rule":"S2047"},{"repository":"php","rule":"S1541"},{"repository":"java","rule":"S3242"},{"repository":"javascript","rule":"S3973"},{"repository":"javascript","rule":"S1438"},{"repository":"Web","rule":"LinkToNothingCheck"},{"repository":"java","rule":"S2039"},{"repository":"java","rule":"S1188"},{"repository":"java","rule":"S1067"},{"repository":"java","rule":"S2156"},{"repository":"java","rule":"S3366"},{"repository":"Web","rule":"LinksIdenticalTextsDifferentTargetsCheck"},{"repository":"java","rule":"S5970"},{"repository":"typescript","rule":"S100"},{"repository":"typescript","rule":"S103"},{"repository":"php","rule":"S1990"},{"repository":"typescript","rule":"S105"},{"repository":"typescript","rule":"S104"},{"repository":"javascript","rule":"S1541"},{"repository":"java","rule":"S864"},{"repository":"javascript","rule":"S3723"},{"repository":"java","rule":"S5979"},{"repository":"java","rule":"NoSonar"},{"repository":"java","rule":"S5977"},{"repository":"java","rule":"S5612"},{"repository":"java","rule":"S1258"},{"repository":"java","rule":"S3437"},{"repository":"Web","rule":"FileLengthCheck"},{"repository":"Web","rule":"JspScriptletCheck"},{"repository":"java","rule":"S2221"},{"repository":"java","rule":"S1132"},{"repository":"javascript","rule":"S909"},{"repository":"java","rule":"S3553"},{"repository":"typescript","rule":"S113"},{"repository":"javascript","rule":"S1530"},{"repository":"javascript","rule":"S1774"},{"repository":"javascript","rule":"S1535"},{"repository":"javascript","rule":"S1537"},{"repository":"javascript","rule":"S1539"},{"repository":"java","rule":"S3306"},{"repository":"typescript","rule":"S106"},{"repository":"java","rule":"S2698"},{"repository":"typescript","rule":"S109"},{"repository":"php","rule":"S1996"},{"repository":"php","rule":"S2964"},{"repository":"java","rule":"S2693"},{"repository":"java","rule":"S1120"},{"repository":"java","rule":"S2694"},{"repository":"java","rule":"S2211"},{"repository":"php","rule":"S1997"},{"repository":"java","rule":"S2333"},{"repository":"java","rule":"S1244"},{"repository":"typescript","rule":"S121"},{"repository":"java","rule":"S1151"},{"repository":"typescript","rule":"S122"},{"repository":"Web","rule":"IllegalElementCheck"},{"repository":"typescript","rule":"S126"},{"repository":"typescript","rule":"S4137"},{"repository":"java","rule":"S888"},{"repository":"javascript","rule":"S1525"},{"repository":"javascript","rule":"S1526"},{"repository":"typescript","rule":"S4139"},{"repository":"javascript","rule":"S1528"},{"repository":"javascript","rule":"S3827"},{"repository":"typescript","rule":"S4136"},{"repository":"java","rule":"S3578"},{"repository":"typescript","rule":"S117"},{"repository":"typescript","rule":"S131"},{"repository":"php","rule":"S2830"},{"repository":"typescript","rule":"S134"},{"repository":"typescript","rule":"S135"},{"repository":"typescript","rule":"S138"},{"repository":"typescript","rule":"S4023"},{"repository":"java","rule":"S881"},{"repository":"java","rule":"S5867"},{"repository":"java","rule":"S1147"},{"repository":"java","rule":"S1142"},{"repository":"php","rule":"S2701"}] - JDK_FX_17 + JDK_17 {} true diff --git a/Semester 3/Assignments/JavaFXBallsWithComparator/nbactions.xml b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/nbactions.xml similarity index 100% rename from Semester 3/Assignments/JavaFXBallsWithComparator/nbactions.xml rename to Semester 3/Assignments/lab7-chapter20_CalebFontenot/nbactions.xml diff --git a/Semester 3/Assignments/JavaFXBallsWithComparator/pom.xml b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/pom.xml similarity index 98% rename from Semester 3/Assignments/JavaFXBallsWithComparator/pom.xml rename to Semester 3/Assignments/lab7-chapter20_CalebFontenot/pom.xml index 9308376..18dcdc3 100644 --- a/Semester 3/Assignments/JavaFXBallsWithComparator/pom.xml +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/pom.xml @@ -2,7 +2,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 edu.slcc.asdv.caleb - JavaFXBallsWithComparator + lab7-chapter20_CalebFontenot 1.0-SNAPSHOT UTF-8 diff --git a/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A1.java b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A1.java similarity index 100% rename from Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A1.java rename to Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A1.java diff --git a/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A2.java b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A2.java similarity index 51% rename from Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A2.java rename to Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A2.java index b896474..a0df621 100644 --- a/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A2.java +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A2.java @@ -14,28 +14,47 @@ import java.util.List; * @author caleb */ public class A2 { + int x; - public A2() {} - public A2(int x) {this.x = x;} - + + public A2() { + } + + public A2(int x) { + this.x = x; + } + @Override - public String toString() - { + public String toString() { return "A2{" + "x=" + x + '}'; } - public static void main(String[] args) - { - System.out.println("Sorting in ascending order"); + + public static void main(String[] args) { List list1 = Arrays.asList(new A2(4), new A2(), new A2(2)); Comparator c = new Comparator() { @Override - public int compare(A2 o1, A2 o2) - { - return o1.x - o2.x; + public int compare(A2 o1, A2 o2) { + return o1.x - o2.x; } }; + Comparator c2 = new Comparator() { + @Override + public int compare(A2 o1, A2 o2) { + int returnVal = 0; + if(o1.x > o2.x) { + returnVal = -1; + } else { + returnVal = 0; + } + return returnVal; + } + }; + System.out.println("Sorting in ascending order"); Collections.sort(list1, c); System.out.println(list1); + System.out.println("Sorting in desending order"); + Collections.sort(list1,c2); + System.out.println(list1); } - + } diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A3.java b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A3.java new file mode 100644 index 0000000..0b5a542 --- /dev/null +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A3.java @@ -0,0 +1,63 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package edu.slcc.asdv.caleb.javafxballswithcomparator; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +/** + * + * @author caleb + */ +public class A3 { + + int x; + + public A3() { + } + + public A3(int x) { + this.x = x; + } + + @Override + public String toString() { + return "A2{" + "x=" + x + '}'; + } + + public static Comparator comparator() { + Comparator c = new Comparator() { + @Override + public int compare(A3 o1, A3 o2) { + return o1.x - o2.x; + } + }; + return c; + } + + public static Comparator comparatorReverse() { + Comparator c = new Comparator() { + @Override + public int compare(A3 o1, A3 o2) { + return o1.x > o2.x ? -1 : 0; + } + }; + return c; + } + + public static void main(String[] args) { + List list1 = Arrays.asList(new A3(4), new A3(), new A3(2)); + + System.out.println("Sorting in ascending order"); + Collections.sort(list1, A3.comparator()); + System.out.println(list1); + System.out.println("Sorting in desending order"); + Collections.sort(list1, A3.comparatorReverse()); + System.out.println(list1); + } + +} diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A4.java b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A4.java new file mode 100644 index 0000000..a5dac58 --- /dev/null +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A4.java @@ -0,0 +1,80 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package edu.slcc.asdv.caleb.javafxballswithcomparator; + +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; + +/** + * + * @author caleb + */ +public class A4> { + + E x; + + public A4() {} + public A4(E x) {this.x = x;} + + public static Comparator comparator() { + Comparator c = new Comparator() { + @Override + public int compare(A4 o1, A4 o2) { + return o1.x.compareTo(o2.x); + } + }; + return c; + } + public static Comparator comparatorReverse() { + Comparator c = new Comparator() { + @Override + public int compare(A4 o1, A4 o2) { + switch (o1.x.compareTo(o2.x)) { + case -1: + return 1; + case 0: + return 0; + case 1: + return -1; + } + return -112315234; + } + }; + return c; + } + + @Override + public String toString() { + return "A4{" + "x=" + x + '}'; + } + + public static void main(String[] args) { + System.out.println("Sorting in ascending order"); + List list1 = Arrays.asList( + new A4(new Integer(4)), + new A4(new Integer(1)), + new A4(new Integer(2)) + ); + Collections.sort(list1, A4.comparator()); + List list2 = Arrays.asList( + new A4(new String("once")), + new A4(new String("upon")), + new A4(new String("a")), + new A4(new String("time")), + new A4(new String("in")), + new A4(new String("America")) + ); + Collections.sort(list2, A4.comparator()); + System.out.println(list1); + System.out.println(list2); + System.out.println("Now, in descending order:"); + Collections.sort(list2, A4.comparatorReverse()); + System.out.println(list2); + + } + +} diff --git a/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/App.java b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/App.java similarity index 100% rename from Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/App.java rename to Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/App.java diff --git a/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/Circle.java b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/Circle.java similarity index 100% rename from Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/Circle.java rename to Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/Circle.java diff --git a/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/GeometricObject.java b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/GeometricObject.java similarity index 100% rename from Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/GeometricObject.java rename to Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/GeometricObject.java diff --git a/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/GeometricObjectComparator.java b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/GeometricObjectComparator.java similarity index 100% rename from Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/GeometricObjectComparator.java rename to Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/GeometricObjectComparator.java diff --git a/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/MultipleBallsWithComparator.java b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/MultipleBallsWithComparator.java similarity index 100% rename from Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/MultipleBallsWithComparator.java rename to Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/MultipleBallsWithComparator.java diff --git a/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/Rectangle.java b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/Rectangle.java similarity index 100% rename from Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/Rectangle.java rename to Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/Rectangle.java diff --git a/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/SystemInfo.java b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/SystemInfo.java similarity index 100% rename from Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/SystemInfo.java rename to Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/SystemInfo.java diff --git a/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/TestArrayAndLinkedList.java b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/TestArrayAndLinkedList.java similarity index 100% rename from Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/TestArrayAndLinkedList.java rename to Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/TestArrayAndLinkedList.java diff --git a/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/TestComparator.java b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/TestComparator.java similarity index 100% rename from Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/TestComparator.java rename to Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/TestComparator.java diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/TestPriorityQueue.java b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/TestPriorityQueue.java new file mode 100644 index 0000000..40ae08c --- /dev/null +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/TestPriorityQueue.java @@ -0,0 +1,40 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package edu.slcc.asdv.caleb.javafxballswithcomparator; + +import java.util.Collections; +import java.util.Comparator; +import java.util.PriorityQueue; + +/** + * + * @author caleb + */ +public class TestPriorityQueue { + public static void main(String[] args) { + PriorityQueue queue1 = new PriorityQueue<>(); + queue1.offer("Oklahoma"); + queue1.offer("Indiana"); + queue1.offer("Georgia"); + queue1.offer("Texas"); + + System.out.println("Priority queue using Comparable:"); + while (queue1.size() > 0) { + System.out.print(queue1.remove() + " "); + } + + Comparator c = Collections.reverseOrder(); + PriorityQueue queue2 = new PriorityQueue<>(4, c); + queue2.offer("Oklahoma"); + queue2.offer("Indiana"); + queue2.offer("Georgia"); + queue2.offer("Texas"); + + System.out.println("\n\nPriority queue is using Comparator: "); + while (queue2.size() > 0) { + System.out.print(queue2.remove() + " "); + } + } +} diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/TestTheCollections.java b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/TestTheCollections.java new file mode 100644 index 0000000..237509f --- /dev/null +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/TestTheCollections.java @@ -0,0 +1,100 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package edu.slcc.asdv.caleb.javafxballswithcomparator; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Random; + +/** + * + * @author caleb + */ +public class TestTheCollections { + + public static void main(String[] args) { + System.out.println("Sorting in ascending order"); + List list1 = Arrays.asList("red", "green", "blue"); + Collections.sort(list1); + System.out.println(list1); + + System.out.println("Sorting in descending order"); + List list2 = Arrays.asList("yellow", "red", "green", "blue"); + Collections.sort(list2); + System.out.println(list2); + + System.out.println("\nBinary Search"); + List list3 + = Arrays.asList(2, 4, 7, 10, 11, 45, 50, 59, 60, 66); + System.out.println(list3 + " 7 is at index: " + Collections.binarySearch(list3, 7)); + System.out.println(list3 + " 9 is at index: " + Collections.binarySearch(list3, 9)); + System.out.println(list3 + " 100 is at index: " + Collections.binarySearch(list3, 100)); + + List list4 = new ArrayList<>(); + list4.addAll(list1); + System.out.println(list4 + " red is at index: " + Collections.binarySearch(list4, "red")); + System.out.println(list4 + " amber is at index: " + Collections.binarySearch(list4, "amber")); + System.out.println(list4 + " brown is at index: " + Collections.binarySearch(list4, "brown")); + + System.out.println("\nReverse the list"); + List list5 = new ArrayList<>(); + list5.addAll(list2); + System.out.println("Original list: " + list5); + Collections.reverse(list5); + System.out.println("Reversed list: " + list5); + + System.out.println("\nShuffle lists"); + List list6 = new ArrayList<>(); + List list7 = new ArrayList<>(); + list6.addAll(list2); + list7.addAll(list2); + + System.out.println("Original list: " + list6); + Collections.shuffle(list6, new Random(20)); + System.out.println("Shuffled list: " + list6); + + System.out.println("Original list: " + list7); + Collections.shuffle(list7, new Random(20)); + System.out.println("Shuffled list: " + list7); + + List list8 = new ArrayList<>(); + list8.addAll(list2); + List list9 = Arrays.asList("white", "black"); + System.out.println("\nCopy into " + list8 + " the list " + list9); + Collections.copy(list8, list9); + System.out.println(list8); + System.out.println("The output for list 8 is [white, black, green, blue].\n" + + "The copy method performs a \n" + + "shallow copy: only the references of the elements fromt he source list are copied." + ); + + List list10 = new ArrayList<>(); + list10.addAll(list1); + System.out.println("\nFill the list " + list10 + " with \'black\'."); + Collections.fill(list10, "black"); + System.out.println(list10); + + + /* + The disjoint(collection1, collection2) method returns true if the two collections + have no elements in common. For example, in the following code, the disjoint(collection1, + collectio2) returns false, but the disjoint(collection1, collection3) returns true. + */ + System.out.println("\nCollections.disjoints()"); + Collection collection1 = Arrays.asList("red", "cyan"); + Collection collection2 = Arrays.asList("red", "blue"); + Collection collection3 = Arrays.asList("pink", "tan"); + System.out.println(Collections.disjoint(collection1, collection2)); + System.out.println(Collections.disjoint(collection1, collection3)); + + System.out.println("\nFrequency"); + Collection collection = Arrays.asList("red", "cyan", "red"); + System.out.println(collection + " red occurs " + Collections.frequency(collection, "red") + " times."); + + } +} diff --git a/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/module-info.java b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/module-info.java similarity index 100% rename from Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/module-info.java rename to Semester 3/Assignments/lab7-chapter20_CalebFontenot/src/main/java/module-info.java diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A1.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A1.class new file mode 100644 index 0000000..9ed3bfc Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A1.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A2$1.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A2$1.class new file mode 100644 index 0000000..93fe65a Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A2$1.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A2$2.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A2$2.class new file mode 100644 index 0000000..5825991 Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A2$2.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A2.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A2.class new file mode 100644 index 0000000..b90fe2d Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A2.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A3$1.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A3$1.class new file mode 100644 index 0000000..6152325 Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A3$1.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A3$2.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A3$2.class new file mode 100644 index 0000000..d5a31bc Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A3$2.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A3.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A3.class new file mode 100644 index 0000000..3ce2a7f Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A3.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A4$1.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A4$1.class new file mode 100644 index 0000000..68d6119 Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A4$1.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A4$2.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A4$2.class new file mode 100644 index 0000000..28c2cbf Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A4$2.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A4.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A4.class new file mode 100644 index 0000000..0df3c72 Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/A4.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/App.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/App.class new file mode 100644 index 0000000..a9b0537 Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/App.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/Circle.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/Circle.class new file mode 100644 index 0000000..2b61b2d Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/Circle.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/GeometricObject.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/GeometricObject.class new file mode 100644 index 0000000..d0a0e82 Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/GeometricObject.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/GeometricObjectComparator.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/GeometricObjectComparator.class new file mode 100644 index 0000000..553778e Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/GeometricObjectComparator.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/MultipleBallsWithComparator$Ball.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/MultipleBallsWithComparator$Ball.class new file mode 100644 index 0000000..f1424aa Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/MultipleBallsWithComparator$Ball.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/MultipleBallsWithComparator$MultipleBallPane.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/MultipleBallsWithComparator$MultipleBallPane.class new file mode 100644 index 0000000..3cfb940 Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/MultipleBallsWithComparator$MultipleBallPane.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/MultipleBallsWithComparator.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/MultipleBallsWithComparator.class new file mode 100644 index 0000000..0710da3 Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/MultipleBallsWithComparator.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/Rectangle.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/Rectangle.class new file mode 100644 index 0000000..11aa8a0 Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/Rectangle.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/SystemInfo.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/SystemInfo.class new file mode 100644 index 0000000..130b500 Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/SystemInfo.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/TestArrayAndLinkedList.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/TestArrayAndLinkedList.class new file mode 100644 index 0000000..afd07f1 Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/TestArrayAndLinkedList.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/TestComparator.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/TestComparator.class new file mode 100644 index 0000000..7b10706 Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/TestComparator.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/TestPriorityQueue.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/TestPriorityQueue.class new file mode 100644 index 0000000..018d5db Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/TestPriorityQueue.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/TestTheCollections.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/TestTheCollections.class new file mode 100644 index 0000000..ff9095d Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/edu/slcc/asdv/caleb/javafxballswithcomparator/TestTheCollections.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/module-info.class b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/module-info.class new file mode 100644 index 0000000..5b26773 Binary files /dev/null and b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/classes/module-info.class differ diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..18d21ca --- /dev/null +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,24 @@ +edu/slcc/asdv/caleb/javafxballswithcomparator/A4$1.class +edu/slcc/asdv/caleb/javafxballswithcomparator/GeometricObject.class +edu/slcc/asdv/caleb/javafxballswithcomparator/TestComparator.class +edu/slcc/asdv/caleb/javafxballswithcomparator/A2$2.class +edu/slcc/asdv/caleb/javafxballswithcomparator/MultipleBallsWithComparator$Ball.class +edu/slcc/asdv/caleb/javafxballswithcomparator/A3$1.class +edu/slcc/asdv/caleb/javafxballswithcomparator/A4$2.class +edu/slcc/asdv/caleb/javafxballswithcomparator/GeometricObjectComparator.class +edu/slcc/asdv/caleb/javafxballswithcomparator/TestArrayAndLinkedList.class +edu/slcc/asdv/caleb/javafxballswithcomparator/A2$1.class +edu/slcc/asdv/caleb/javafxballswithcomparator/MultipleBallsWithComparator$MultipleBallPane.class +edu/slcc/asdv/caleb/javafxballswithcomparator/Rectangle.class +edu/slcc/asdv/caleb/javafxballswithcomparator/App.class +edu/slcc/asdv/caleb/javafxballswithcomparator/A2.class +edu/slcc/asdv/caleb/javafxballswithcomparator/MultipleBallsWithComparator.class +module-info.class +edu/slcc/asdv/caleb/javafxballswithcomparator/A1.class +edu/slcc/asdv/caleb/javafxballswithcomparator/TestPriorityQueue.class +edu/slcc/asdv/caleb/javafxballswithcomparator/A3.class +edu/slcc/asdv/caleb/javafxballswithcomparator/Circle.class +edu/slcc/asdv/caleb/javafxballswithcomparator/SystemInfo.class +edu/slcc/asdv/caleb/javafxballswithcomparator/TestTheCollections.class +edu/slcc/asdv/caleb/javafxballswithcomparator/A3$2.class +edu/slcc/asdv/caleb/javafxballswithcomparator/A4.class diff --git a/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..a128d29 --- /dev/null +++ b/Semester 3/Assignments/lab7-chapter20_CalebFontenot/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,12 @@ +/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/Circle.java +/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/Rectangle.java +/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/TestArrayAndLinkedList.java +/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A1.java +/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/module-info.java +/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/GeometricObject.java +/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/GeometricObjectComparator.java +/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/A2.java +/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/SystemInfo.java +/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/App.java +/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/MultipleBallsWithComparator.java +/home/caleb/ASDV-Java/Semester 3/Assignments/JavaFXBallsWithComparator/src/main/java/edu/slcc/asdv/caleb/javafxballswithcomparator/TestComparator.java diff --git a/Semester 3/MP4_Generics_CalebFontenot/nb-configuration.xml b/Semester 3/MP4_Generics_CalebFontenot/nb-configuration.xml index 9c74157..6ecd386 100644 --- a/Semester 3/MP4_Generics_CalebFontenot/nb-configuration.xml +++ b/Semester 3/MP4_Generics_CalebFontenot/nb-configuration.xml @@ -13,6 +13,6 @@ You can copy and paste the single properties, into the pom.xml file and the IDE That way multiple projects can share the same settings (useful for formatting rules for example). Any value defined here will override the pom.xml file value but is only applicable to the current project. --> - JDK_20 + Graal_JDK_20 diff --git a/Semester 3/MP4_Generics_CalebFontenot/pom.xml b/Semester 3/MP4_Generics_CalebFontenot/pom.xml index a121d6e..fb9efb8 100644 --- a/Semester 3/MP4_Generics_CalebFontenot/pom.xml +++ b/Semester 3/MP4_Generics_CalebFontenot/pom.xml @@ -7,8 +7,8 @@ jar UTF-8 - 20 - 20 + 17 + 17 com.calebfontenot.mp4_generics_calebfontenot.MP4_Generics_CalebFontenot \ No newline at end of file diff --git a/Semester 3/MP4_Generics_CalebFontenot/src/main/java/com/calebfontenot/mp4_generics_calebfontenot/ArrayListASDV.java b/Semester 3/MP4_Generics_CalebFontenot/src/main/java/com/calebfontenot/mp4_generics_calebfontenot/ArrayListASDV.java index fcaa8bd..63a820b 100644 --- a/Semester 3/MP4_Generics_CalebFontenot/src/main/java/com/calebfontenot/mp4_generics_calebfontenot/ArrayListASDV.java +++ b/Semester 3/MP4_Generics_CalebFontenot/src/main/java/com/calebfontenot/mp4_generics_calebfontenot/ArrayListASDV.java @@ -75,11 +75,16 @@ public class ArrayListASDV * @throws IllegalArgumentException - if some property of the element prevents it from being added to this collection */ @Override - public boolean add(E e) - { - - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + public boolean add(E e) { + if (e == null) { + throw new NullPointerException(); + } + list[index++] = e; + if (index >= list.length * 0.75) { + doubleSizeOfList(); + } + return true; } /** diff --git a/Semester 3/MP4_Generics_CalebFontenot/src/main/java/com/calebfontenot/mp4_generics_calebfontenot/IteratorASDV.java b/Semester 3/MP4_Generics_CalebFontenot/src/main/java/com/calebfontenot/mp4_generics_calebfontenot/IteratorASDV.java index db94c85..1d52634 100644 --- a/Semester 3/MP4_Generics_CalebFontenot/src/main/java/com/calebfontenot/mp4_generics_calebfontenot/IteratorASDV.java +++ b/Semester 3/MP4_Generics_CalebFontenot/src/main/java/com/calebfontenot/mp4_generics_calebfontenot/IteratorASDV.java @@ -46,7 +46,7 @@ public class IteratorASDV { }; return (IteratorASDV) it; - } + }; public static void main(String[] args) { IteratorASDV ti = new IteratorASDV(); @@ -58,4 +58,5 @@ public class IteratorASDV { System.out.println(it.next()); } } +} diff --git a/Semester 3/ZIPs/MP4_CalebFontenot.zip b/Semester 3/ZIPs/MP4_CalebFontenot.zip new file mode 100644 index 0000000..7cccd1c Binary files /dev/null and b/Semester 3/ZIPs/MP4_CalebFontenot.zip differ diff --git a/Semester 3/ZIPs/lab7-chapter20_CalebFontenot.zip b/Semester 3/ZIPs/lab7-chapter20_CalebFontenot.zip new file mode 100644 index 0000000..c4050d4 Binary files /dev/null and b/Semester 3/ZIPs/lab7-chapter20_CalebFontenot.zip differ diff --git a/test/pom.xml b/test/pom.xml new file mode 100644 index 0000000..63739ed --- /dev/null +++ b/test/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + com.calebfontenot + test + 1.0-SNAPSHOT + jar + + UTF-8 + 20 + 20 + com.calebfontenot.test.Test + + \ No newline at end of file diff --git a/test/src/main/java/com/calebfontenot/test/Test.java b/test/src/main/java/com/calebfontenot/test/Test.java new file mode 100644 index 0000000..60739a6 --- /dev/null +++ b/test/src/main/java/com/calebfontenot/test/Test.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package com.calebfontenot.test; + +/** + * + * @author caleb + */ +public class Test { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +}