From 578c33de70d577ac16bf27307514e3d571493877 Mon Sep 17 00:00:00 2001 From: Chloe Christine Fontenot Date: Sun, 19 Oct 2025 22:02:41 -0500 Subject: [PATCH] =?UTF-8?q?Reset=20author=20name=20to=20chosen=20name=20?= =?UTF-8?q?=E2=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lab1chloefontenot/Lab1CalebFontenot.java | 20 + .../pom.xml | 0 .../src/main/java/ComputeExpression.java | 0 .../src/main/java/ShowLogicErrors.java | 0 .../src/main/java/ShowRuntimeErrors.java | 0 .../src/main/java/ShowSyntaxErrors.java | 0 .../main/java/WelcomeWithThreeMessages.java | 0 .../lab2chloefontenot/Lab2CalebFontenot.java | 17 + .../lab3chloefontenot/Lab3CalebFontenot.java | 17 + .../lab3_1_chloefontenot/Lab3.java | 42 + .../MilesToKilometers.java | 29 + .../lab3_1_chloefontenot/RunwayLength.java | 38 + .../ComputeTax.java | 68 ++ .../LabClass_Sep6_CalebFontenot.java | 17 + .../SimpleIfDemo.java | 29 + .../mp1_chloefontenot/CompoundValue.java | 37 + .../mp1_chloefontenot/Cylinder.java | 32 + .../mp1_chloefontenot/MP1_CalebFontenot.java | 17 + .../mp1_chloefontenot/NumberOfYears.java | 65 ++ .../mp1_chloefontenot/SumOfDigits.java | 34 + .../mp1_chloefontenot/Total.java | 40 + .../mp1_chloefontenot/WindChill.java | 33 + .../mp2_chloefontenot/CheckIBSN_10.java | 56 + .../mp2_chloefontenot/DayOfTheWeek.java | 71 ++ .../mp2_chloefontenot/RandomNumber.java | 43 + .../mp2_chloefontenot/RockPaperScissors.java | 53 + .../mp2_chloefontenot/TrianglePerimeter.java | 30 + .../mp5_chloefontenot/MP5_CalebFontenot.java | 83 ++ .../ArrayCopy1.java | 31 + .../ArrayCopy2.java | 33 + .../ArrayCopy3.java | 29 + .../ArrayCopy4.java | 43 + .../ArrayShift1.java | 31 + .../ArrayShift2.java | 32 + .../ArraysAndMethods.java | 81 ++ .../ArraysAndMethodsGames.java | 62 ++ .../Lab16_arrays2_CalebFontenot.java | 17 + .../Lab17_CalebFontenot.java | 102 ++ .../lab4_chloefontenot/ABCD.java | 17 + .../lab4_chloefontenot/Debug1.java | 18 + .../lab4_chloefontenot/Debug2.java | 19 + .../lab4_chloefontenot/Debug3.java | 16 + .../lab4_chloefontenot/Debug5.java | 16 + .../Lab4_CalebFontenot.java | 34 + .../lab4_chloefontenot/payroll.java | 64 ++ .../Lab5_CalebFontenot.java | 17 + .../lab5_chloefontenot/Operators.java | 48 + .../lab5_chloefontenot/Swap.java | 36 + .../lab5_chloefontenot/WhatsYourName.java | 32 + .../lab5_chloefontenot/WhatsYourSSN.java | 29 + .../chloefontenot/lab6_chloefontenot/If1.java | 28 + .../chloefontenot/lab6_chloefontenot/If2.java | 20 + .../chloefontenot/lab6_chloefontenot/If3.java | 24 + .../lab6_chloefontenot/IfElse1.java | 27 + .../lab6_chloefontenot/IfElse2.java | 32 + .../lab6_chloefontenot/IfElse3.java | 33 + .../lab6_chloefontenot/IfElse4.java | 74 ++ .../Lab6_CalebFontenot.java | 25 + .../lab6_chloefontenot/Triangle.java | 44 + .../lab7_chloefontenot/And1.java | 29 + .../lab7_chloefontenot/And2.java | 37 + .../lab7_chloefontenot/Bonus.java | 57 + .../lab7_chloefontenot/Debug1.java | 20 + .../lab7_chloefontenot/DivisionQuiz.java | 67 ++ .../lab7_chloefontenot/Not1.java | 38 + .../lab7_chloefontenot/Not2.java | 38 + .../chloefontenot/lab7_chloefontenot/Or1.java | 29 + .../chloefontenot/lab7_chloefontenot/Or2.java | 36 + .../lab7_chloefontenot/SubtractionQuiz.java | 45 + .../ConditionalOperator1.java | 26 + .../ConditionalOperator2.java | 19 + .../ConditionalOperator3.java | 19 + .../ConditionalOperator4.java | 26 + .../lab8_chloefontenot/DecimalToHex1.java | 66 ++ .../lab8_chloefontenot/DecimalToHex2.java | 65 ++ .../Lab8_CalebFontenot.java | 17 + .../lab8_chloefontenot/Switch1.java | 36 + .../Switch1ConvertedToIfElse.java | 46 + .../lab8_chloefontenot/Switch2.java | 23 + .../lab8_chloefontenot/Switch3.java | 65 ++ .../Switch3ConvertedToIfElse.java | 59 ++ .../lab8_chloefontenot/Switch4.java | 54 + .../Lab9_CalebFontenot.java | 17 + .../lab9_chloefontenot/MinimumOf3.java | 46 + .../MinimumOf4ConditionalOperator.java | 46 + .../MinimumOf4DeMorgan.java | 39 + .../MinimumOf4NestedIfs.java | 60 ++ .../MinimumOf4WithANDs.java | 39 + .../exam1_chloefontenot/DayOfTheWeek.java | 58 ++ .../Exam1_CalebFontenot.java | 17 + .../exam1_chloefontenot/RandomMonth.java | 43 + .../TrianglePerimeter.java | 34 + .../App.java | 0 .../PrintArrayReversedEven.java | 0 .../AppTest.java | 0 .../Consecutive4Equals.java | 62 ++ .../Exam2_mvn_Practice_CalebFontenot.java | 17 + .../PrintArrayReversedEven.java | 49 + .../SortCharsInString.java | 48 + .../Lab3DArraysSort_CalebFontenot.java | 149 +++ .../mp1_chloefontenot/MP1_CalebFontenot.java | 267 +++++ .../mp1_chloefontenot/MarkouCode.java | 219 ++++ .../mp2_chloefontenot/Circle2D.java | 290 ++++++ .../mp2_chloefontenot/MP2_CalebFontenot.java | 16 + .../mp4_chloefontenot/Bicycle.java | 61 ++ .../mp4_chloefontenot/BikeStores.java | 265 +++++ .../mp4_chloefontenot/ChildBike.java | 60 ++ .../mp4_chloefontenot/Details.java | 57 + .../mp4_chloefontenot/MountainBike.java | 62 ++ .../mp4_chloefontenot/SpeedBike.java | 69 ++ .../mp5_chloefontenot/Circle.java | 55 + .../mp5_chloefontenot/Combinations.java | 145 +++ .../chloefontenot/mp5_chloefontenot/FD.java | 97 ++ .../mp5_chloefontenot/GeometricObject.java | 95 ++ .../mp5_chloefontenot/Large.java | 45 + .../mp5_chloefontenot/MP5_CalebFontenot.java | 16 + .../mp5_chloefontenot/MyStack.java | 62 ++ .../mp5_chloefontenot/NormalizeDatabase.java | 173 ++++ .../mp5_chloefontenot/PrintCalendar.java | 160 +++ .../mp5_chloefontenot/Rectangle.java | 67 ++ .../mp5_chloefontenot/ShuffleArrayList.java | 73 ++ .../mp5_chloefontenot/SortArrayList.java | 47 + .../TestGeometricObject.java | 32 + .../Lab2DArraysSort_CalebFontenot.java | 134 +++ .../Lab2DArrays_CalebFontenot.java | 209 ++++ .../JakartaRestConfiguration.java | 13 + .../resources/JakartaEE91Resource.java | 20 + .../JakartaRestConfiguration.java | 13 + .../resources/JakartaEE91Resource.java | 20 + .../Lab5_CalebFontenot.java | 16 + .../lab5_chloefontenot/QuadraticEquation.java | 92 ++ .../lab5_chloefontenot/TakeQuiz.java | 71 ++ .../lab5_chloefontenot/TrueFalseQuestion.java | 86 ++ .../lab5_chloefontenot/TrueFalseQuiz.java | 99 ++ .../chloefontenot/lab3_chloefontenot/Fan.java | 138 +++ .../lab3_chloefontenot/FanList.java | 79 ++ .../lab3_chloefontenot/Stock.java | 119 +++ .../lab3_chloefontenot/StockList.java | 75 ++ .../lab3_chloefontenot/Account.java | 146 +++ .../lab3_chloefontenot/Employee.java | 53 + .../Lab3_CalebFontenot.java | 16 + .../lab3_chloefontenot/MyInteger.java | 85 ++ .../chloefontenot/lab3_chloefontenot/A.class | Bin 0 -> 308 bytes .../lab3_chloefontenot/Account.class | Bin 0 -> 3029 bytes .../lab3_chloefontenot/Employee.class | Bin 0 -> 1100 bytes .../Lab3_CalebFontenot.class | Bin 0 -> 662 bytes .../lab3_chloefontenot/MyInteger.class | Bin 0 -> 2640 bytes .../chloefontenot/lab5_chloefontenot/A.java | 32 + .../lab5_chloefontenot/Person.java | 198 ++++ .../lab5_CalebFontenot.java | 38 + .../lab4_chloefontenot/Circle.java | 51 + .../lab4_chloefontenot/GeometricObject.java | 65 ++ .../Lab4_CalebFontenot.java | 16 + .../lab4_chloefontenot/Rectangle.java | 52 + .../TestCircleRectangle.java | 48 + .../lab4_chloefontenot/Circle.class | Bin 0 -> 1518 bytes .../lab4_chloefontenot/GeometricObject.class | Bin 0 -> 1649 bytes .../Lab4_CalebFontenot.class | Bin 0 -> 632 bytes .../lab4_chloefontenot/Rectangle.class | Bin 0 -> 1037 bytes .../TestCircleRectangle$Apple.class | Bin 0 -> 693 bytes .../TestCircleRectangle$Fruit.class | Bin 0 -> 1017 bytes .../TestCircleRectangle.class | Bin 0 -> 953 bytes .../chloefontenot/lab5_chloefontenot/A.class | Bin 0 -> 1332 bytes .../chloefontenot/lab5_chloefontenot/B.class | Bin 0 -> 979 bytes .../lab5_chloefontenot/Employee.class | Bin 0 -> 1635 bytes .../lab5_chloefontenot/Faculty.class | Bin 0 -> 1713 bytes .../lab5_chloefontenot/Person.class | Bin 0 -> 4515 bytes .../lab5_chloefontenot/Staff.class | Bin 0 -> 1418 bytes .../lab5_chloefontenot/Status.class | Bin 0 -> 797 bytes .../lab5_chloefontenot/Student.class | Bin 0 -> 1360 bytes .../lab5_CalebFontenot.class | Bin 0 -> 883 bytes .../Lab7_CalebFontenot.java | 16 + .../chloefontenot/lab7_chloefontenot/OOM.java | 26 + .../occurrencesOfEachCharacter.java | 46 + .../removeAllOccurances.java | 61 ++ .../Lab8_2_CalebFontenot.java | 16 + .../lab8_2_chloefontenot/NumberX.java | 42 + .../SortComparableObjects.java | 34 + .../interfacesGrouped/Interface1.java | 13 + .../interfacesGrouped/Interface2.java | 13 + .../interfacesGrouped/InterfaceGrouped1.java | 23 + .../interfacesGrouped/TestInterfaces.java | 39 + .../interfacesGrouped/fun/European.java | 14 + .../interfacesGrouped/fun/French.java | 41 + .../interfacesGrouped/fun/German.java | 43 + .../interfacesGrouped/fun/Italian.java | 43 + .../interfacesGrouped/fun/Language.java | 13 + .../interfacesGrouped/fun/Religion.java | 16 + .../interfacesGrouped/fun/Russian.java | 43 + .../interfacesGrouped/fun/TestEuropeans.java | 73 ++ .../fun/TestEuropeansAgain.java | 31 + .../interfacesGrouped/fun/War.java | 14 + .../lab8_chloefontenot/Animal.java | 13 + .../lab8_chloefontenot/Apple.java | 18 + .../lab8_chloefontenot/Brocoli.java | 16 + .../lab8_chloefontenot/Chicken.java | 20 + .../lab8_chloefontenot/Duck.java | 21 + .../lab8_chloefontenot/Edible.java | 13 + .../lab8_chloefontenot/Fruit.java | 13 + .../lab8_chloefontenot/House.java | 133 +++ .../Lab8_CalebFontenot.java | 16 + .../lab8_chloefontenot/Orange.java | 19 + .../lab8_chloefontenot/Test.java | 36 + .../lab8_chloefontenot/TestEdible.java | 60 ++ .../lab8_chloefontenot/Tiger.java | 19 + .../Exam1_CalebFontenot.java | 17 + .../exam1_chloefontenot/Location.java | 54 + .../exam1_chloefontenot/MyStringBuilder.java | 123 +++ .../exam1_chloefontenot/Question1.java | 53 + .../practice_chloefontenot/Automobile.java | 76 ++ .../CountryOfOrigin.java | 102 ++ .../practice_chloefontenot/Dealership.java | 37 + .../Exam2Practice_CalebFontenot.java | 16 + .../exam2/practice_chloefontenot/Main.java | 1 + .../practice2_chloefontenot/Automobile.java | 94 ++ .../Exam2Practice2_CalebFontenot.java | 16 + .../exam2/practice2_chloefontenot/Main.java | 121 +++ .../practice2_chloefontenot/Vehicle.java | 41 + .../practice2_chloefontenot/Airplane.class | Bin 0 -> 347 bytes .../practice2_chloefontenot/Automobile.class | Bin 0 -> 3786 bytes .../Exam2Practice2_CalebFontenot.class | Bin 0 -> 714 bytes .../practice2_chloefontenot/Vehicle.class | Bin 0 -> 1808 bytes .../CompareSize.java | 30 + .../FindMax.java | 47 + .../FindMaxOrderedSubstring.java | 38 + .../GenericMergeSort.java | 105 ++ .../JudeFindMax.java | 56 + ...ab_CalebFontenot_MaximumOrderedString.java | 16 + .../BallControl.java | 0 .../BouncingBall.java | 0 .../MediaType.java | 0 .../BallControl.java | 0 .../BouncingBall.java | 0 .../MediaType.java | 0 .../AddressBookFX.dat | Bin .../build.xml | 0 .../build/classes/.netbeans_automatic_build | 0 .../build/classes/.netbeans_update_resources | 0 .../AddressBookEntry.class | Bin 0 -> 1901 bytes .../files_chloefontenot/AddressBookFX.class | Bin 0 -> 5835 bytes .../mp5/files_chloefontenot/App.class | Bin 0 -> 1927 bytes .../files_chloefontenot/DataContainer.class | Bin 0 -> 1982 bytes .../files_chloefontenot/Exercise17_01.class | Bin 0 -> 2177 bytes .../files_chloefontenot/Exercise17_03.class | Bin 0 -> 2755 bytes .../files_chloefontenot/Exercise17_05.class | Bin 0 -> 2109 bytes .../mp5/files_chloefontenot/Exercise17_05.rs | 2 + .../mp5/files_chloefontenot/SystemInfo.class | Bin 0 -> 605 bytes .../build/classes/module-info.class | Bin .../manifest.mf | 0 .../nbproject/build-impl.xml | 0 .../nbproject/genfiles.properties | 0 .../nbproject/private/config.properties | 0 .../nbproject/private/private.properties | 0 .../nbproject/private/private.xml | 0 .../nbproject/project.properties | 0 .../nbproject/project.xml | 0 .../files_chloefontenot/AddressBookFX.java | 204 ++++ .../mp5/files_chloefontenot/App.java | 30 + .../files_chloefontenot/Exercise17_01.java | 52 + .../files_chloefontenot/Exercise17_03.java | 70 ++ .../files_chloefontenot/Exercise17_05.java | 79 ++ .../mp5/files_chloefontenot/SystemInfo.java | 13 + .../src/module-info.java | 0 .../mp4_chloefontenot/ArrayListASDV.java | 975 ++++++++++++++++++ .../mp4_chloefontenot/MP4_CalebFontenot.java | 16 + .../files_chloefontenot/AddressBookFX.java | 256 +++++ .../mp5/files_chloefontenot/App.java | 30 + .../files_chloefontenot/CombineFilesFX.java | 130 +++ .../files_chloefontenot/Exercise17_01.java | 52 + .../files_chloefontenot/Exercise17_03.java | 70 ++ .../files_chloefontenot/Exercise17_05.java | 79 ++ .../mp5/files_chloefontenot/HexEditorFX.java | 147 +++ .../mp5/files_chloefontenot/SplitFilesFX.java | 122 +++ .../mp5/files_chloefontenot/SystemInfo.java | 13 + .../chloe/mp6_chloefontenot/CircularList.java | 208 ++++ .../mp6_chloefontenot/DoubleLinkedList.java | 129 +++ .../mp6_chloefontenot/EmptyListException.java | 16 + .../mp6_chloefontenot/MP6_CalebFontenot.java | 16 + .../mp6_chloefontenot/PriorityQueueASDV.java | 912 ++++++++++++++++ .../JakartaRestConfiguration.java | 13 + .../resources/JakartaEE10Resource.java | 20 + .../Lab5Recursion2_CalebFontenot.java | 16 + .../NestedLoopsIndexes.java | 32 + .../OccurancesOfChar.java | 33 + ...OccurencesOfSpecifiedCharacterInArray.java | 36 + .../recursion2_chloefontenot/ReverseInt.java | 30 + .../SelectionSortR.java | 52 + .../recursion2_chloefontenot/SumOfDigits.java | 37 + .../recursion2_chloefontenot/SumSeries1.java | 26 + .../recursion2_chloefontenot/SumSeries2.java | 26 + .../UpperCaseInArray.java | 34 + .../GenericStack.java | 69 ++ .../Lab6_generics_CalebFontenot.java | 16 + .../lab6_generics_chloefontenot/Max.java | 48 + .../NoWildCard.java | 32 + .../lab6_generics_chloefontenot/WildCard.java | 32 + .../WildCard2.java | 25 + .../WildCardWithSuper.java | 28 + .../ProgrammingExam2_CalebFontenot.java | 144 +++ .../ArrayListASDV.java | 879 ++++++++++++++++ .../IteratorASDV.java | 62 ++ .../MP4_Generics_CalebFontenot.java | 16 + .../chloe/hashing_chloefontenot/MapASDV.java | 791 ++++++++++++++ .../ManyToMany.java | 114 ++ .../ManyToManyFactory.java | 233 +++++ .../mp2_chloefontenot/MP2_CalebFontenot.java | 16 + .../mp2_chloefontenot/Matrices.java | 142 +++ .../FlashText.java | 86 ++ .../PrintChar.java | 59 ++ .../RunFlash.java | 15 + .../multithreading_chloefontenot/Threads.java | 29 + .../forkbomb.java | 20 + .../ProjectTrees_CalebFontenot.java | 16 + .../projecttrees_chloefontenot/TreeASDV.java | 374 +++++++ .../Threads_CalebFontenot.java | 16 + .../Threads_CalebFontenot.class | Bin 0 -> 651 bytes 316 files changed, 17381 insertions(+) create mode 100644 Semester 1/Assignments/Lab1ChloeFontenot/src/main/java/com/chloefontenot/lab1chloefontenot/Lab1CalebFontenot.java rename Semester 1/Assignments/Lab2ChloeFontenot/{lab2CalebFontenot => lab2ChloeFontenot}/pom.xml (100%) rename Semester 1/Assignments/Lab2ChloeFontenot/{lab2CalebFontenot => lab2ChloeFontenot}/src/main/java/ComputeExpression.java (100%) rename Semester 1/Assignments/Lab2ChloeFontenot/{lab2CalebFontenot => lab2ChloeFontenot}/src/main/java/ShowLogicErrors.java (100%) rename Semester 1/Assignments/Lab2ChloeFontenot/{lab2CalebFontenot => lab2ChloeFontenot}/src/main/java/ShowRuntimeErrors.java (100%) rename Semester 1/Assignments/Lab2ChloeFontenot/{lab2CalebFontenot => lab2ChloeFontenot}/src/main/java/ShowSyntaxErrors.java (100%) rename Semester 1/Assignments/Lab2ChloeFontenot/{lab2CalebFontenot => lab2ChloeFontenot}/src/main/java/WelcomeWithThreeMessages.java (100%) create mode 100644 Semester 1/Assignments/Lab2ChloeFontenot/lab2ChloeFontenot/src/main/java/com/chloefontenot/lab2chloefontenot/Lab2CalebFontenot.java create mode 100644 Semester 1/Assignments/Lab3ChloeFontenot/src/main/java/com/chloefontenot/lab3chloefontenot/Lab3CalebFontenot.java create mode 100644 Semester 1/Assignments/Lab3_1_ChloeFontenot/src/main/java/com/chloefontenot/lab3_1_chloefontenot/Lab3.java create mode 100644 Semester 1/Assignments/Lab3_1_ChloeFontenot/src/main/java/com/chloefontenot/lab3_1_chloefontenot/MilesToKilometers.java create mode 100644 Semester 1/Assignments/Lab3_1_ChloeFontenot/src/main/java/com/chloefontenot/lab3_1_chloefontenot/RunwayLength.java create mode 100644 Semester 1/Assignments/LabClass_Sep6_ChloeFontenot/src/main/java/com/chloefontenot/labclass_sep6_chloefontenot/ComputeTax.java create mode 100644 Semester 1/Assignments/LabClass_Sep6_ChloeFontenot/src/main/java/com/chloefontenot/labclass_sep6_chloefontenot/LabClass_Sep6_CalebFontenot.java create mode 100644 Semester 1/Assignments/LabClass_Sep6_ChloeFontenot/src/main/java/com/chloefontenot/labclass_sep6_chloefontenot/SimpleIfDemo.java create mode 100644 Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/CompoundValue.java create mode 100644 Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/Cylinder.java create mode 100644 Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/MP1_CalebFontenot.java create mode 100644 Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/NumberOfYears.java create mode 100644 Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/SumOfDigits.java create mode 100644 Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/Total.java create mode 100644 Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/WindChill.java create mode 100644 Semester 1/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/CheckIBSN_10.java create mode 100644 Semester 1/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/DayOfTheWeek.java create mode 100644 Semester 1/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/RandomNumber.java create mode 100644 Semester 1/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/RockPaperScissors.java create mode 100644 Semester 1/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/TrianglePerimeter.java create mode 100644 Semester 1/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/MP5_CalebFontenot.java create mode 100644 Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayCopy1.java create mode 100644 Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayCopy2.java create mode 100644 Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayCopy3.java create mode 100644 Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayCopy4.java create mode 100644 Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayShift1.java create mode 100644 Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayShift2.java create mode 100644 Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArraysAndMethods.java create mode 100644 Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArraysAndMethodsGames.java create mode 100644 Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/Lab16_arrays2_CalebFontenot.java create mode 100644 Semester 1/Assignments/lab17_ChloeFontenot/src/main/java/com/chloefontenot/lab17_chloefontenot/Lab17_CalebFontenot.java create mode 100644 Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/ABCD.java create mode 100644 Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/Debug1.java create mode 100644 Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/Debug2.java create mode 100644 Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/Debug3.java create mode 100644 Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/Debug5.java create mode 100644 Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/Lab4_CalebFontenot.java create mode 100644 Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/payroll.java create mode 100644 Semester 1/Assignments/lab5_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/Lab5_CalebFontenot.java create mode 100644 Semester 1/Assignments/lab5_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/Operators.java create mode 100644 Semester 1/Assignments/lab5_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/Swap.java create mode 100644 Semester 1/Assignments/lab5_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/WhatsYourName.java create mode 100644 Semester 1/Assignments/lab5_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/WhatsYourSSN.java create mode 100644 Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/If1.java create mode 100644 Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/If2.java create mode 100644 Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/If3.java create mode 100644 Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/IfElse1.java create mode 100644 Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/IfElse2.java create mode 100644 Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/IfElse3.java create mode 100644 Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/IfElse4.java create mode 100644 Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/Lab6_CalebFontenot.java create mode 100644 Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/Triangle.java create mode 100644 Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/And1.java create mode 100644 Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/And2.java create mode 100644 Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Bonus.java create mode 100644 Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Debug1.java create mode 100644 Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/DivisionQuiz.java create mode 100644 Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Not1.java create mode 100644 Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Not2.java create mode 100644 Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Or1.java create mode 100644 Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Or2.java create mode 100644 Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/SubtractionQuiz.java create mode 100644 Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/ConditionalOperator1.java create mode 100644 Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/ConditionalOperator2.java create mode 100644 Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/ConditionalOperator3.java create mode 100644 Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/ConditionalOperator4.java create mode 100644 Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/DecimalToHex1.java create mode 100644 Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/DecimalToHex2.java create mode 100644 Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Lab8_CalebFontenot.java create mode 100644 Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch1.java create mode 100644 Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch1ConvertedToIfElse.java create mode 100644 Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch2.java create mode 100644 Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch3.java create mode 100644 Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch3ConvertedToIfElse.java create mode 100644 Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch4.java create mode 100644 Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/Lab9_CalebFontenot.java create mode 100644 Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/MinimumOf3.java create mode 100644 Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/MinimumOf4ConditionalOperator.java create mode 100644 Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/MinimumOf4DeMorgan.java create mode 100644 Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/MinimumOf4NestedIfs.java create mode 100644 Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/MinimumOf4WithANDs.java create mode 100755 Semester 1/Exams/Exam1Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/DayOfTheWeek.java create mode 100755 Semester 1/Exams/Exam1Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/Exam1_CalebFontenot.java create mode 100755 Semester 1/Exams/Exam1Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/RandomMonth.java create mode 100755 Semester 1/Exams/Exam1Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/TrianglePerimeter.java rename Semester 1/Exams/Exam2_Practice_ChloeFontenot/app/src/main/java/{Exam2_Practice_CalebFontenot => Exam2_Practice_ChloeFontenot}/App.java (100%) rename Semester 1/Exams/Exam2_Practice_ChloeFontenot/app/src/main/java/{Exam2_Practice_CalebFontenot => Exam2_Practice_ChloeFontenot}/PrintArrayReversedEven.java (100%) rename Semester 1/Exams/Exam2_Practice_ChloeFontenot/app/src/test/java/{Exam2_Practice_CalebFontenot => Exam2_Practice_ChloeFontenot}/AppTest.java (100%) create mode 100644 Semester 1/Exams/Exam2_mvn_Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam2_mvn_practice_chloefontenot/Consecutive4Equals.java create mode 100644 Semester 1/Exams/Exam2_mvn_Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam2_mvn_practice_chloefontenot/Exam2_mvn_Practice_CalebFontenot.java create mode 100644 Semester 1/Exams/Exam2_mvn_Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam2_mvn_practice_chloefontenot/PrintArrayReversedEven.java create mode 100644 Semester 1/Exams/Exam2_mvn_Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam2_mvn_practice_chloefontenot/SortCharsInString.java create mode 100644 Semester 2/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/Lab3DArraysSort_CalebFontenot.java create mode 100644 Semester 2/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/MP1_CalebFontenot.java create mode 100644 Semester 2/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/MarkouCode.java create mode 100644 Semester 2/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/Circle2D.java create mode 100644 Semester 2/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/MP2_CalebFontenot.java create mode 100644 Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/Bicycle.java create mode 100644 Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/BikeStores.java create mode 100644 Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/ChildBike.java create mode 100644 Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/Details.java create mode 100644 Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/MountainBike.java create mode 100644 Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/SpeedBike.java create mode 100644 Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/Circle.java create mode 100644 Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/Combinations.java create mode 100644 Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/FD.java create mode 100644 Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/GeometricObject.java create mode 100644 Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/Large.java create mode 100644 Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/MP5_CalebFontenot.java create mode 100644 Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/MyStack.java create mode 100644 Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/NormalizeDatabase.java create mode 100644 Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/PrintCalendar.java create mode 100644 Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/Rectangle.java create mode 100644 Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/ShuffleArrayList.java create mode 100644 Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/SortArrayList.java create mode 100644 Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/TestGeometricObject.java create mode 100644 Semester 2/Assignments/lab-2D-arrays-sort_ChloeFontenot/src/main/java/com/chloefontenot/lab/d/arrays/sort_chloefontenot/Lab2DArraysSort_CalebFontenot.java create mode 100644 Semester 2/Assignments/lab-2D-arrays_ChloeFontenot/src/main/java/com/chloefontenot/lab/d/arrays_chloefontenot/Lab2DArrays_CalebFontenot.java create mode 100644 Semester 2/Assignments/lab1-ChloeFontenot/src/main/java/com/chloefontenot/lab1/chloefontenot/JakartaRestConfiguration.java create mode 100644 Semester 2/Assignments/lab1-ChloeFontenot/src/main/java/com/chloefontenot/lab1/chloefontenot/resources/JakartaEE91Resource.java create mode 100644 Semester 2/Assignments/lab1-ChloeFontenot2/src/main/java/edu/slcc/asdv/chloe/lab1/chloefontenot2/JakartaRestConfiguration.java create mode 100644 Semester 2/Assignments/lab1-ChloeFontenot2/src/main/java/edu/slcc/asdv/chloe/lab1/chloefontenot2/resources/JakartaEE91Resource.java create mode 100644 Semester 2/Assignments/lab2_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/Lab5_CalebFontenot.java create mode 100644 Semester 2/Assignments/lab2_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/QuadraticEquation.java create mode 100644 Semester 2/Assignments/lab2_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/TakeQuiz.java create mode 100644 Semester 2/Assignments/lab2_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/TrueFalseQuestion.java create mode 100644 Semester 2/Assignments/lab2_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/TrueFalseQuiz.java create mode 100644 Semester 2/Assignments/lab3_ChloeFontenot/src/main/java/com/chloefontenot/lab3_chloefontenot/Fan.java create mode 100644 Semester 2/Assignments/lab3_ChloeFontenot/src/main/java/com/chloefontenot/lab3_chloefontenot/FanList.java create mode 100644 Semester 2/Assignments/lab3_ChloeFontenot/src/main/java/com/chloefontenot/lab3_chloefontenot/Stock.java create mode 100644 Semester 2/Assignments/lab3_ChloeFontenot/src/main/java/com/chloefontenot/lab3_chloefontenot/StockList.java create mode 100644 Semester 2/Assignments/lab3_ChloeFontenot_old/src/main/java/com/chloefontenot/lab3_chloefontenot/Account.java create mode 100644 Semester 2/Assignments/lab3_ChloeFontenot_old/src/main/java/com/chloefontenot/lab3_chloefontenot/Employee.java create mode 100644 Semester 2/Assignments/lab3_ChloeFontenot_old/src/main/java/com/chloefontenot/lab3_chloefontenot/Lab3_CalebFontenot.java create mode 100644 Semester 2/Assignments/lab3_ChloeFontenot_old/src/main/java/com/chloefontenot/lab3_chloefontenot/MyInteger.java create mode 100644 Semester 2/Assignments/lab3_ChloeFontenot_old/target/classes/com/chloefontenot/lab3_chloefontenot/A.class create mode 100644 Semester 2/Assignments/lab3_ChloeFontenot_old/target/classes/com/chloefontenot/lab3_chloefontenot/Account.class create mode 100644 Semester 2/Assignments/lab3_ChloeFontenot_old/target/classes/com/chloefontenot/lab3_chloefontenot/Employee.class create mode 100644 Semester 2/Assignments/lab3_ChloeFontenot_old/target/classes/com/chloefontenot/lab3_chloefontenot/Lab3_CalebFontenot.class create mode 100644 Semester 2/Assignments/lab3_ChloeFontenot_old/target/classes/com/chloefontenot/lab3_chloefontenot/MyInteger.class create mode 100644 Semester 2/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/A.java create mode 100644 Semester 2/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/Person.java create mode 100644 Semester 2/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/lab5_CalebFontenot.java create mode 100644 Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/src/main/java/com/chloefontenot/lab4_chloefontenot/Circle.java create mode 100644 Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/src/main/java/com/chloefontenot/lab4_chloefontenot/GeometricObject.java create mode 100644 Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/src/main/java/com/chloefontenot/lab4_chloefontenot/Lab4_CalebFontenot.java create mode 100644 Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/src/main/java/com/chloefontenot/lab4_chloefontenot/Rectangle.java create mode 100644 Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/src/main/java/com/chloefontenot/lab4_chloefontenot/TestCircleRectangle.java create mode 100644 Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/target/classes/com/chloefontenot/lab4_chloefontenot/Circle.class create mode 100644 Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/target/classes/com/chloefontenot/lab4_chloefontenot/GeometricObject.class create mode 100644 Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/target/classes/com/chloefontenot/lab4_chloefontenot/Lab4_CalebFontenot.class create mode 100644 Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/target/classes/com/chloefontenot/lab4_chloefontenot/Rectangle.class create mode 100644 Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/target/classes/com/chloefontenot/lab4_chloefontenot/TestCircleRectangle$Apple.class create mode 100644 Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/target/classes/com/chloefontenot/lab4_chloefontenot/TestCircleRectangle$Fruit.class create mode 100644 Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/target/classes/com/chloefontenot/lab4_chloefontenot/TestCircleRectangle.class create mode 100644 Semester 2/Assignments/lab5_ChloeFontenot__/target/classes/com/chloefontenot/lab5_chloefontenot/A.class create mode 100644 Semester 2/Assignments/lab5_ChloeFontenot__/target/classes/com/chloefontenot/lab5_chloefontenot/B.class create mode 100644 Semester 2/Assignments/lab5_ChloeFontenot__/target/classes/com/chloefontenot/lab5_chloefontenot/Employee.class create mode 100644 Semester 2/Assignments/lab5_ChloeFontenot__/target/classes/com/chloefontenot/lab5_chloefontenot/Faculty.class create mode 100644 Semester 2/Assignments/lab5_ChloeFontenot__/target/classes/com/chloefontenot/lab5_chloefontenot/Person.class create mode 100644 Semester 2/Assignments/lab5_ChloeFontenot__/target/classes/com/chloefontenot/lab5_chloefontenot/Staff.class create mode 100644 Semester 2/Assignments/lab5_ChloeFontenot__/target/classes/com/chloefontenot/lab5_chloefontenot/Status.class create mode 100644 Semester 2/Assignments/lab5_ChloeFontenot__/target/classes/com/chloefontenot/lab5_chloefontenot/Student.class create mode 100644 Semester 2/Assignments/lab5_ChloeFontenot__/target/classes/com/chloefontenot/lab5_chloefontenot/lab5_CalebFontenot.class create mode 100644 Semester 2/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Lab7_CalebFontenot.java create mode 100644 Semester 2/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/OOM.java create mode 100644 Semester 2/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/occurrencesOfEachCharacter.java create mode 100644 Semester 2/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/removeAllOccurances.java create mode 100644 Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/Lab8_2_CalebFontenot.java create mode 100644 Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/NumberX.java create mode 100644 Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/SortComparableObjects.java create mode 100644 Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/Interface1.java create mode 100644 Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/Interface2.java create mode 100644 Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/InterfaceGrouped1.java create mode 100644 Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/TestInterfaces.java create mode 100644 Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/European.java create mode 100644 Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/French.java create mode 100644 Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/German.java create mode 100644 Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/Italian.java create mode 100644 Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/Language.java create mode 100644 Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/Religion.java create mode 100644 Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/Russian.java create mode 100644 Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/TestEuropeans.java create mode 100644 Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/TestEuropeansAgain.java create mode 100644 Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/War.java create mode 100644 Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Animal.java create mode 100644 Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Apple.java create mode 100644 Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Brocoli.java create mode 100644 Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Chicken.java create mode 100644 Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Duck.java create mode 100644 Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Edible.java create mode 100644 Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Fruit.java create mode 100644 Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/House.java create mode 100644 Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Lab8_CalebFontenot.java create mode 100644 Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Orange.java create mode 100644 Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Test.java create mode 100644 Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/TestEdible.java create mode 100644 Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Tiger.java create mode 100644 Semester 2/Exams/Exam1_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/Exam1_CalebFontenot.java create mode 100644 Semester 2/Exams/Exam1_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/Location.java create mode 100644 Semester 2/Exams/Exam1_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/MyStringBuilder.java create mode 100644 Semester 2/Exams/Exam1_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/Question1.java create mode 100644 Semester 2/Exams/Exam2-Practice1_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice_chloefontenot/Automobile.java create mode 100644 Semester 2/Exams/Exam2-Practice1_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice_chloefontenot/CountryOfOrigin.java create mode 100644 Semester 2/Exams/Exam2-Practice1_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice_chloefontenot/Dealership.java create mode 100644 Semester 2/Exams/Exam2-Practice1_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice_chloefontenot/Exam2Practice_CalebFontenot.java create mode 100644 Semester 2/Exams/Exam2-Practice1_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice_chloefontenot/Main.java create mode 100644 Semester 2/Exams/Exam2-Practice2_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice2_chloefontenot/Automobile.java create mode 100644 Semester 2/Exams/Exam2-Practice2_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice2_chloefontenot/Exam2Practice2_CalebFontenot.java create mode 100644 Semester 2/Exams/Exam2-Practice2_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice2_chloefontenot/Main.java create mode 100644 Semester 2/Exams/Exam2-Practice2_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice2_chloefontenot/Vehicle.java create mode 100644 Semester 2/Exams/Exam2-Practice2_ChloeFontenot/target/classes/com/chloefontenot/exam2/practice2_chloefontenot/Airplane.class create mode 100644 Semester 2/Exams/Exam2-Practice2_ChloeFontenot/target/classes/com/chloefontenot/exam2/practice2_chloefontenot/Automobile.class create mode 100644 Semester 2/Exams/Exam2-Practice2_ChloeFontenot/target/classes/com/chloefontenot/exam2/practice2_chloefontenot/Exam2Practice2_CalebFontenot.class create mode 100644 Semester 2/Exams/Exam2-Practice2_ChloeFontenot/target/classes/com/chloefontenot/exam2/practice2_chloefontenot/Vehicle.class create mode 100644 Semester 3/Assignments/Lab_ChloeFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/chloe/lab_chloefontenot_maximumorderedstring/CompareSize.java create mode 100644 Semester 3/Assignments/Lab_ChloeFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/chloe/lab_chloefontenot_maximumorderedstring/FindMax.java create mode 100644 Semester 3/Assignments/Lab_ChloeFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/chloe/lab_chloefontenot_maximumorderedstring/FindMaxOrderedSubstring.java create mode 100644 Semester 3/Assignments/Lab_ChloeFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/chloe/lab_chloefontenot_maximumorderedstring/GenericMergeSort.java create mode 100644 Semester 3/Assignments/Lab_ChloeFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/chloe/lab_chloefontenot_maximumorderedstring/JudeFindMax.java create mode 100644 Semester 3/Assignments/Lab_ChloeFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/chloe/lab_chloefontenot_maximumorderedstring/Lab_CalebFontenot_MaximumOrderedString.java rename Semester 3/Assignments/MP2-chapter4_ChloeFontenot/src/{MP2_chapter4_CalebFontenot => MP2_chapter4_ChloeFontenot}/BallControl.java (100%) rename Semester 3/Assignments/MP2-chapter4_ChloeFontenot/src/{MP2_chapter4_CalebFontenot => MP2_chapter4_ChloeFontenot}/BouncingBall.java (100%) rename Semester 3/Assignments/MP2-chapter4_ChloeFontenot/src/{MP2_chapter4_CalebFontenot => MP2_chapter4_ChloeFontenot}/MediaType.java (100%) rename Semester 3/Assignments/MP2-chapter4_Java20_ChloeFontenot/src/{MP2_chapter4_CalebFontenot => MP2_chapter4_ChloeFontenot}/BallControl.java (100%) rename Semester 3/Assignments/MP2-chapter4_Java20_ChloeFontenot/src/{MP2_chapter4_CalebFontenot => MP2_chapter4_ChloeFontenot}/BouncingBall.java (100%) rename Semester 3/Assignments/MP2-chapter4_Java20_ChloeFontenot/src/{MP2_chapter4_CalebFontenot => MP2_chapter4_ChloeFontenot}/MediaType.java (100%) rename Semester 3/Assignments/MP3_Recursion_ChloeFontenot/{MP5-Binary-Files_CalebFontenot => MP5-Binary-Files_ChloeFontenot}/AddressBookFX.dat (100%) rename Semester 3/Assignments/MP3_Recursion_ChloeFontenot/{MP5-Binary-Files_CalebFontenot => MP5-Binary-Files_ChloeFontenot}/build.xml (100%) rename Semester 3/Assignments/MP3_Recursion_ChloeFontenot/{MP5-Binary-Files_CalebFontenot => MP5-Binary-Files_ChloeFontenot}/build/classes/.netbeans_automatic_build (100%) rename Semester 3/Assignments/MP3_Recursion_ChloeFontenot/{MP5-Binary-Files_CalebFontenot => MP5-Binary-Files_ChloeFontenot}/build/classes/.netbeans_update_resources (100%) create mode 100644 Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/com/chloefontenot/mp5/files_chloefontenot/AddressBookEntry.class create mode 100644 Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/com/chloefontenot/mp5/files_chloefontenot/AddressBookFX.class create mode 100644 Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/com/chloefontenot/mp5/files_chloefontenot/App.class create mode 100644 Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/com/chloefontenot/mp5/files_chloefontenot/DataContainer.class create mode 100644 Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/com/chloefontenot/mp5/files_chloefontenot/Exercise17_01.class create mode 100644 Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/com/chloefontenot/mp5/files_chloefontenot/Exercise17_03.class create mode 100644 Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/com/chloefontenot/mp5/files_chloefontenot/Exercise17_05.class create mode 100644 Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/com/chloefontenot/mp5/files_chloefontenot/Exercise17_05.rs create mode 100644 Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/com/chloefontenot/mp5/files_chloefontenot/SystemInfo.class rename Semester 3/Assignments/MP3_Recursion_ChloeFontenot/{MP5-Binary-Files_CalebFontenot => MP5-Binary-Files_ChloeFontenot}/build/classes/module-info.class (100%) rename Semester 3/Assignments/MP3_Recursion_ChloeFontenot/{MP5-Binary-Files_CalebFontenot => MP5-Binary-Files_ChloeFontenot}/manifest.mf (100%) rename Semester 3/Assignments/MP3_Recursion_ChloeFontenot/{MP5-Binary-Files_CalebFontenot => MP5-Binary-Files_ChloeFontenot}/nbproject/build-impl.xml (100%) rename Semester 3/Assignments/MP3_Recursion_ChloeFontenot/{MP5-Binary-Files_CalebFontenot => MP5-Binary-Files_ChloeFontenot}/nbproject/genfiles.properties (100%) rename Semester 3/Assignments/MP3_Recursion_ChloeFontenot/{MP5-Binary-Files_CalebFontenot => MP5-Binary-Files_ChloeFontenot}/nbproject/private/config.properties (100%) rename Semester 3/Assignments/MP3_Recursion_ChloeFontenot/{MP5-Binary-Files_CalebFontenot => MP5-Binary-Files_ChloeFontenot}/nbproject/private/private.properties (100%) rename Semester 3/Assignments/MP3_Recursion_ChloeFontenot/{MP5-Binary-Files_CalebFontenot => MP5-Binary-Files_ChloeFontenot}/nbproject/private/private.xml (100%) rename Semester 3/Assignments/MP3_Recursion_ChloeFontenot/{MP5-Binary-Files_CalebFontenot => MP5-Binary-Files_ChloeFontenot}/nbproject/project.properties (100%) rename Semester 3/Assignments/MP3_Recursion_ChloeFontenot/{MP5-Binary-Files_CalebFontenot => MP5-Binary-Files_ChloeFontenot}/nbproject/project.xml (100%) create mode 100644 Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/AddressBookFX.java create mode 100644 Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/App.java create mode 100644 Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_01.java create mode 100644 Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_03.java create mode 100644 Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_05.java create mode 100644 Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/SystemInfo.java rename Semester 3/Assignments/MP3_Recursion_ChloeFontenot/{MP5-Binary-Files_CalebFontenot => MP5-Binary-Files_ChloeFontenot}/src/module-info.java (100%) create mode 100644 Semester 3/Assignments/MP4_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp4_chloefontenot/ArrayListASDV.java create mode 100644 Semester 3/Assignments/MP4_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp4_chloefontenot/MP4_CalebFontenot.java create mode 100644 Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/AddressBookFX.java create mode 100644 Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/App.java create mode 100644 Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/CombineFilesFX.java create mode 100644 Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_01.java create mode 100644 Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_03.java create mode 100644 Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_05.java create mode 100644 Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/HexEditorFX.java create mode 100644 Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/SplitFilesFX.java create mode 100644 Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/SystemInfo.java create mode 100644 Semester 3/Assignments/MP6_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp6_chloefontenot/CircularList.java create mode 100644 Semester 3/Assignments/MP6_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp6_chloefontenot/DoubleLinkedList.java create mode 100644 Semester 3/Assignments/MP6_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp6_chloefontenot/EmptyListException.java create mode 100644 Semester 3/Assignments/MP6_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp6_chloefontenot/MP6_CalebFontenot.java create mode 100644 Semester 3/Assignments/MP6_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp6_chloefontenot/PriorityQueueASDV.java create mode 100644 Semester 3/Assignments/lab2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab2_chloefontenot/JakartaRestConfiguration.java create mode 100644 Semester 3/Assignments/lab2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab2_chloefontenot/resources/JakartaEE10Resource.java create mode 100644 Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/Lab5Recursion2_CalebFontenot.java create mode 100644 Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/NestedLoopsIndexes.java create mode 100644 Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/OccurancesOfChar.java create mode 100644 Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/OccurencesOfSpecifiedCharacterInArray.java create mode 100644 Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/ReverseInt.java create mode 100644 Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/SelectionSortR.java create mode 100644 Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/SumOfDigits.java create mode 100644 Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/SumSeries1.java create mode 100644 Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/SumSeries2.java create mode 100644 Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/UpperCaseInArray.java create mode 100644 Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/GenericStack.java create mode 100644 Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/Lab6_generics_CalebFontenot.java create mode 100644 Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/Max.java create mode 100644 Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/NoWildCard.java create mode 100644 Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/WildCard.java create mode 100644 Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/WildCard2.java create mode 100644 Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/WildCardWithSuper.java create mode 100644 Semester 3/Exams/ProgrammingExam2_ChloeFontenot/src/main/java/com/chloefontenot/programmingexam2_chloefontenot/ProgrammingExam2_CalebFontenot.java create mode 100644 Semester 3/MP4_Generics_ChloeFontenot/src/main/java/com/chloefontenot/mp4_generics_chloefontenot/ArrayListASDV.java create mode 100644 Semester 3/MP4_Generics_ChloeFontenot/src/main/java/com/chloefontenot/mp4_generics_chloefontenot/IteratorASDV.java create mode 100644 Semester 3/MP4_Generics_ChloeFontenot/src/main/java/com/chloefontenot/mp4_generics_chloefontenot/MP4_Generics_CalebFontenot.java create mode 100644 Semester 4/Assignments/Hashing_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/hashing_chloefontenot/MapASDV.java create mode 100644 Semester 4/Assignments/MP1_ManyToMany_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp1_manytomany_chloefontenot/ManyToMany.java create mode 100644 Semester 4/Assignments/MP1_ManyToMany_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp1_manytomany_chloefontenot/ManyToManyFactory.java create mode 100644 Semester 4/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/MP2_CalebFontenot.java create mode 100644 Semester 4/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/Matrices.java create mode 100644 Semester 4/Assignments/Multithreading_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/multithreading_chloefontenot/FlashText.java create mode 100644 Semester 4/Assignments/Multithreading_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/multithreading_chloefontenot/PrintChar.java create mode 100644 Semester 4/Assignments/Multithreading_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/multithreading_chloefontenot/RunFlash.java create mode 100644 Semester 4/Assignments/Multithreading_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/multithreading_chloefontenot/Threads.java create mode 100644 Semester 4/Assignments/Multithreading_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/multithreading_chloefontenot/forkbomb.java create mode 100644 Semester 4/Assignments/ProjectTrees_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/projecttrees_chloefontenot/ProjectTrees_CalebFontenot.java create mode 100644 Semester 4/Assignments/ProjectTrees_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/projecttrees_chloefontenot/TreeASDV.java create mode 100644 Semester 4/Assignments/Threads_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/threads_chloefontenot/Threads_CalebFontenot.java create mode 100644 Semester 4/Assignments/Threads_ChloeFontenot/target/classes/edu/slcc/asdv/chloe/threads_chloefontenot/Threads_CalebFontenot.class diff --git a/Semester 1/Assignments/Lab1ChloeFontenot/src/main/java/com/chloefontenot/lab1chloefontenot/Lab1CalebFontenot.java b/Semester 1/Assignments/Lab1ChloeFontenot/src/main/java/com/chloefontenot/lab1chloefontenot/Lab1CalebFontenot.java new file mode 100644 index 0000000..4ca3eea --- /dev/null +++ b/Semester 1/Assignments/Lab1ChloeFontenot/src/main/java/com/chloefontenot/lab1chloefontenot/Lab1CalebFontenot.java @@ -0,0 +1,20 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template + */ +package com.chloefontenot.lab1chloefontenot; + +/** + * + * @author chloe + */ +public class Lab1ChloeFontenot { + + public static void main(String[] args) + { + // Create a string named message + String message = "Hello World!"; + // Print our string + System.out.println(message); + } +} diff --git a/Semester 1/Assignments/Lab2ChloeFontenot/lab2CalebFontenot/pom.xml b/Semester 1/Assignments/Lab2ChloeFontenot/lab2ChloeFontenot/pom.xml similarity index 100% rename from Semester 1/Assignments/Lab2ChloeFontenot/lab2CalebFontenot/pom.xml rename to Semester 1/Assignments/Lab2ChloeFontenot/lab2ChloeFontenot/pom.xml diff --git a/Semester 1/Assignments/Lab2ChloeFontenot/lab2CalebFontenot/src/main/java/ComputeExpression.java b/Semester 1/Assignments/Lab2ChloeFontenot/lab2ChloeFontenot/src/main/java/ComputeExpression.java similarity index 100% rename from Semester 1/Assignments/Lab2ChloeFontenot/lab2CalebFontenot/src/main/java/ComputeExpression.java rename to Semester 1/Assignments/Lab2ChloeFontenot/lab2ChloeFontenot/src/main/java/ComputeExpression.java diff --git a/Semester 1/Assignments/Lab2ChloeFontenot/lab2CalebFontenot/src/main/java/ShowLogicErrors.java b/Semester 1/Assignments/Lab2ChloeFontenot/lab2ChloeFontenot/src/main/java/ShowLogicErrors.java similarity index 100% rename from Semester 1/Assignments/Lab2ChloeFontenot/lab2CalebFontenot/src/main/java/ShowLogicErrors.java rename to Semester 1/Assignments/Lab2ChloeFontenot/lab2ChloeFontenot/src/main/java/ShowLogicErrors.java diff --git a/Semester 1/Assignments/Lab2ChloeFontenot/lab2CalebFontenot/src/main/java/ShowRuntimeErrors.java b/Semester 1/Assignments/Lab2ChloeFontenot/lab2ChloeFontenot/src/main/java/ShowRuntimeErrors.java similarity index 100% rename from Semester 1/Assignments/Lab2ChloeFontenot/lab2CalebFontenot/src/main/java/ShowRuntimeErrors.java rename to Semester 1/Assignments/Lab2ChloeFontenot/lab2ChloeFontenot/src/main/java/ShowRuntimeErrors.java diff --git a/Semester 1/Assignments/Lab2ChloeFontenot/lab2CalebFontenot/src/main/java/ShowSyntaxErrors.java b/Semester 1/Assignments/Lab2ChloeFontenot/lab2ChloeFontenot/src/main/java/ShowSyntaxErrors.java similarity index 100% rename from Semester 1/Assignments/Lab2ChloeFontenot/lab2CalebFontenot/src/main/java/ShowSyntaxErrors.java rename to Semester 1/Assignments/Lab2ChloeFontenot/lab2ChloeFontenot/src/main/java/ShowSyntaxErrors.java diff --git a/Semester 1/Assignments/Lab2ChloeFontenot/lab2CalebFontenot/src/main/java/WelcomeWithThreeMessages.java b/Semester 1/Assignments/Lab2ChloeFontenot/lab2ChloeFontenot/src/main/java/WelcomeWithThreeMessages.java similarity index 100% rename from Semester 1/Assignments/Lab2ChloeFontenot/lab2CalebFontenot/src/main/java/WelcomeWithThreeMessages.java rename to Semester 1/Assignments/Lab2ChloeFontenot/lab2ChloeFontenot/src/main/java/WelcomeWithThreeMessages.java diff --git a/Semester 1/Assignments/Lab2ChloeFontenot/lab2ChloeFontenot/src/main/java/com/chloefontenot/lab2chloefontenot/Lab2CalebFontenot.java b/Semester 1/Assignments/Lab2ChloeFontenot/lab2ChloeFontenot/src/main/java/com/chloefontenot/lab2chloefontenot/Lab2CalebFontenot.java new file mode 100644 index 0000000..f4f5302 --- /dev/null +++ b/Semester 1/Assignments/Lab2ChloeFontenot/lab2ChloeFontenot/src/main/java/com/chloefontenot/lab2chloefontenot/Lab2CalebFontenot.java @@ -0,0 +1,17 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template + */ + +package com.chloefontenot.lab2chloefontenot; + +/** + * + * @author chloe + */ +public class Lab2ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 1/Assignments/Lab3ChloeFontenot/src/main/java/com/chloefontenot/lab3chloefontenot/Lab3CalebFontenot.java b/Semester 1/Assignments/Lab3ChloeFontenot/src/main/java/com/chloefontenot/lab3chloefontenot/Lab3CalebFontenot.java new file mode 100644 index 0000000..d68fd19 --- /dev/null +++ b/Semester 1/Assignments/Lab3ChloeFontenot/src/main/java/com/chloefontenot/lab3chloefontenot/Lab3CalebFontenot.java @@ -0,0 +1,17 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template + */ + +package com.chloefontenot.lab3chloefontenot; + +/** + * + * @author chloe + */ +public class Lab3ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 1/Assignments/Lab3_1_ChloeFontenot/src/main/java/com/chloefontenot/lab3_1_chloefontenot/Lab3.java b/Semester 1/Assignments/Lab3_1_ChloeFontenot/src/main/java/com/chloefontenot/lab3_1_chloefontenot/Lab3.java new file mode 100644 index 0000000..2f3a151 --- /dev/null +++ b/Semester 1/Assignments/Lab3_1_ChloeFontenot/src/main/java/com/chloefontenot/lab3_1_chloefontenot/Lab3.java @@ -0,0 +1,42 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab3_1_chloefontenot; +import java.util.Scanner; +/** + * + * @author chloe + */ +public class Lab3 { + public static void main(String[] args) + { + // Create a scanner object + Scanner input = new Scanner(System.in); + + // Prompt for hight in feet + System.out.print("Enter the height (feet): "); + double height; + height = input.nextDouble(); + + // Prompt for width in feet + System.out.print("Enter the width (feet):"); + double width; + width = input.nextDouble(); + + // Calculate the area + double area; + area = height * width; + // Print area calculated + System.out.println("Calculated area is "+area); + //create constants + final double GALLONS_PER_SQUARE_FEET = 150.0; + + // calculate the gallons + double gallons; + gallons = area/GALLONS_PER_SQUARE_FEET; + //calculate the number of gallons needed to paint the wall + System.out.println("The amount of paint is " + gallons +" gallons."); + + } +} diff --git a/Semester 1/Assignments/Lab3_1_ChloeFontenot/src/main/java/com/chloefontenot/lab3_1_chloefontenot/MilesToKilometers.java b/Semester 1/Assignments/Lab3_1_ChloeFontenot/src/main/java/com/chloefontenot/lab3_1_chloefontenot/MilesToKilometers.java new file mode 100644 index 0000000..ef2c6d6 --- /dev/null +++ b/Semester 1/Assignments/Lab3_1_ChloeFontenot/src/main/java/com/chloefontenot/lab3_1_chloefontenot/MilesToKilometers.java @@ -0,0 +1,29 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab3_1_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class MilesToKilometers { + public static void main(String[] args) + { + double miles; + double km; + Scanner scanner = new Scanner(System.in); + + //> 1. Prompt the user to enter the number of miles + System.out.println("Please enter miles to convert into kilometers"); + //> 2. Read the miles and store it into a variable + miles = scanner.nextDouble(); + //> 3. Calculate the KM from the entered miles + km = miles * 1.67; + //> 4. Display the result + System.out.println("You entered "+miles+" miles which is "+km+" kilometers"); + } +} diff --git a/Semester 1/Assignments/Lab3_1_ChloeFontenot/src/main/java/com/chloefontenot/lab3_1_chloefontenot/RunwayLength.java b/Semester 1/Assignments/Lab3_1_ChloeFontenot/src/main/java/com/chloefontenot/lab3_1_chloefontenot/RunwayLength.java new file mode 100644 index 0000000..51b5c65 --- /dev/null +++ b/Semester 1/Assignments/Lab3_1_ChloeFontenot/src/main/java/com/chloefontenot/lab3_1_chloefontenot/RunwayLength.java @@ -0,0 +1,38 @@ +package com.chloefontenot.lab3_1_chloefontenot; + +import java.util.Scanner; + +/* + * 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 + */ + +/** + * + * @author chloe + */ +public class RunwayLength { + public static void main(String[] args) + { + + //Define data objects + double length; + double acceleration; + double velocity; + + //Create scanner + Scanner input = new Scanner(System.in); + + //Prompt for input + System.out.print("Enter velocity: "); + velocity = input.nextDouble(); + System.out.print("Enter acceleration: "); + acceleration = input.nextDouble(); + + //Calculate + length = Math.pow(velocity, 2) / (2 * acceleration); + + //Print calculation + System.out.println("The minimum runway length for this airplane is "+length); + } +} diff --git a/Semester 1/Assignments/LabClass_Sep6_ChloeFontenot/src/main/java/com/chloefontenot/labclass_sep6_chloefontenot/ComputeTax.java b/Semester 1/Assignments/LabClass_Sep6_ChloeFontenot/src/main/java/com/chloefontenot/labclass_sep6_chloefontenot/ComputeTax.java new file mode 100644 index 0000000..8fb1e6f --- /dev/null +++ b/Semester 1/Assignments/LabClass_Sep6_ChloeFontenot/src/main/java/com/chloefontenot/labclass_sep6_chloefontenot/ComputeTax.java @@ -0,0 +1,68 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.labclass_sep6_chloefontenot; + +/** + * + * @author chloe + */ +import java.util.Scanner; + +public class ComputeTax { + + public static void main(String[] args) + { + // Create a Scanner + Scanner input = new Scanner(System.in); + + // Prompt the user to enter filing status + System.out.print("(0-single filer, 1-married jointly or " + + "qualifying widow(er), 2-married separately, 3-head of " + + "household) Enter the filing status: "); + + int status = input.nextInt(); + + // Prompt the user to enter taxable income + System.out.print("Enter the taxable income: "); + double income = input.nextDouble(); + + // Compute tax + double tax = 0; + + if (status == 0) { // Compute tax for single filers + if (income <= 8350) { + tax = income * 0.10; + } else if (income <= 33950) { + tax = 8350 * 0.10 + (income - 8350) * 0.15; + } else if (income <= 82250) { + tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + + (income - 33950) * 0.25; + } else if (income <= 171550) { + tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + + (82250 - 33950) * 0.25 + (income - 82250) * 0.28; + } else if (income <= 372950) { + tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + + (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 + + (income - 171550) * 0.33; + } else { + tax = 8350 * 0.10 + (33950 - 8350) * 0.15 + + (82250 - 33950) * 0.25 + (171550 - 82250) * 0.28 + + (372950 - 171550) * 0.33 + (income - 372950) * 0.35; + } + } else if (status == 1) { // Compute tax for married file jointly + // Left as exercise in Programming Exercise 3.13 + } else if (status == 2) { // Compute tax for married separately + // Left as exercise in Programming Exercise 3.13 + } else if (status == 3) { // Compute tax for head of household + // Left as exercise in Programming Exercise 3.13 + } else { + System.out.println("Error: invalid status"); + System.exit(1); + } + + // Display the result + System.out.println("Tax is " + (int) (tax * 100) / 100.0); + } +} diff --git a/Semester 1/Assignments/LabClass_Sep6_ChloeFontenot/src/main/java/com/chloefontenot/labclass_sep6_chloefontenot/LabClass_Sep6_CalebFontenot.java b/Semester 1/Assignments/LabClass_Sep6_ChloeFontenot/src/main/java/com/chloefontenot/labclass_sep6_chloefontenot/LabClass_Sep6_CalebFontenot.java new file mode 100644 index 0000000..c0868f7 --- /dev/null +++ b/Semester 1/Assignments/LabClass_Sep6_ChloeFontenot/src/main/java/com/chloefontenot/labclass_sep6_chloefontenot/LabClass_Sep6_CalebFontenot.java @@ -0,0 +1,17 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template + */ + +package com.chloefontenot.labclass_sep6_chloefontenot; + +/** + * + * @author chloe + */ +public class LabClass_Sep6_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 1/Assignments/LabClass_Sep6_ChloeFontenot/src/main/java/com/chloefontenot/labclass_sep6_chloefontenot/SimpleIfDemo.java b/Semester 1/Assignments/LabClass_Sep6_ChloeFontenot/src/main/java/com/chloefontenot/labclass_sep6_chloefontenot/SimpleIfDemo.java new file mode 100644 index 0000000..fbd3993 --- /dev/null +++ b/Semester 1/Assignments/LabClass_Sep6_ChloeFontenot/src/main/java/com/chloefontenot/labclass_sep6_chloefontenot/SimpleIfDemo.java @@ -0,0 +1,29 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.labclass_sep6_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class SimpleIfDemo { + + public static void main(String[] args) + { + Scanner input = new Scanner(System.in); + System.out.print("Enter an integer: "); + int number = input.nextInt(); + + if (number % 5 == 0) { + System.out.println("HiFive"); + } + + if (number % 2 == 0) { + System.out.println("HiEven"); + } + } +} diff --git a/Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/CompoundValue.java b/Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/CompoundValue.java new file mode 100644 index 0000000..915f501 --- /dev/null +++ b/Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/CompoundValue.java @@ -0,0 +1,37 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp1_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class CompoundValue { + + public static void main(String[] args) { + // Create Scanner + Scanner input = new Scanner(System.in); + + // Define vars + int counter; + double SavingAmount; + double InterestRate; + + // Prompt for input + System.out.print("Enter monthly saving amount: "); + SavingAmount = input.nextDouble(); + + // Compute and Print result + InterestRate = 0.05 / 12; + SavingAmount = SavingAmount * (1 + InterestRate); + System.out.println("The account is " + SavingAmount + " after month 1"); + for (counter = 2; counter <= 6; counter++) { + SavingAmount = (100 + SavingAmount) * (1 + InterestRate); + System.out.println("The account is " + SavingAmount + " after month " + counter); + } + } +} diff --git a/Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/Cylinder.java b/Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/Cylinder.java new file mode 100644 index 0000000..57feaf5 --- /dev/null +++ b/Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/Cylinder.java @@ -0,0 +1,32 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp1_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class Cylinder { + public static void main(String[] args) + { + Scanner input = new Scanner(System.in); + + // Enter radius of the cylinder + System.out.print("Enter the radius and length of a cylinder: "); + double radius = input.nextDouble(); + double length = input.nextDouble(); + + // Compute area and volume + double area = radius * radius * 3.14159; + double volume = area * length; + + // Display result + System.out.println("The area is " + area); + System.out.println("The volume of the cylinder is " + volume); + + } +} diff --git a/Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/MP1_CalebFontenot.java b/Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/MP1_CalebFontenot.java new file mode 100644 index 0000000..b02ca46 --- /dev/null +++ b/Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/MP1_CalebFontenot.java @@ -0,0 +1,17 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template + */ + +package com.chloefontenot.mp1_chloefontenot; + +/** + * + * @author chloe + */ +public class MP1_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/NumberOfYears.java b/Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/NumberOfYears.java new file mode 100644 index 0000000..26dc8bf --- /dev/null +++ b/Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/NumberOfYears.java @@ -0,0 +1,65 @@ + +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp1_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class NumberOfYears { + + public static void main(String[] args) + { + // Define vars + double NumberOfMinutes; + double NumberOfYears; + double NumberOfDays; + double NumberOfHours; + + // Create Scanner + Scanner input = new Scanner(System.in); + + // Prompt for input + System.out.print("Enter the number of minutes: "); + NumberOfMinutes = input.nextDouble(); + + // Calculate + NumberOfHours = (NumberOfMinutes / 60); + NumberOfDays = (NumberOfHours / 24); + NumberOfYears = (NumberOfDays / 365); + + // Big brain math time + //Subtract 365 from "NumberOfDays" until the number is less than or equal to 365 + while (NumberOfDays >= 365.0) { + //System.out.println("DEBUG: Subtracting 365 from "+ NumberOfDays); + NumberOfDays = NumberOfDays - 365; + } + + // Do the same with hours + while (NumberOfHours >= 24.0) { + //System.out.println("DEBUG: Subtracting 24 from "+ NumberOfHours); + NumberOfHours = NumberOfHours - 24; + } + + // Print output + System.out.println((int) NumberOfMinutes + " minutes is approx. :"); + if ((int)NumberOfYears >= 2) { + System.out.println((int) NumberOfYears + " years,"); + } + if ((int)NumberOfYears == 1) { + System.out.println((int)NumberOfYears+" year."); + } + if ((int) NumberOfDays != 0) { + System.out.println((int) NumberOfDays + " days,"); + } + if ((int) NumberOfHours != 0) { + System.out.println((int) NumberOfHours + " hours."); + } + + } +} diff --git a/Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/SumOfDigits.java b/Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/SumOfDigits.java new file mode 100644 index 0000000..2a6e9f3 --- /dev/null +++ b/Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/SumOfDigits.java @@ -0,0 +1,34 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp1_chloefontenot; + +/** + * + * @author chloe + */ +public class SumOfDigits { + public static void main(String[] args) + { + java.util.Scanner input = new java.util.Scanner(System.in); + //> Read a number + System.out.print("Inter an integer between 0 and 1000: "); + int number = input.nextInt(); + + //> Find all digits in number + int lastDigit = number % 10; + int remainingNumber = number / 10; + int secondLastDigit = remainingNumber % 10; + remainingNumber = remainingNumber / 10; + int thirdLastDigit = remainingNumber % 10; + + //> Obtain the sum of all digits + int sum = lastDigit + secondLastDigit + thirdLastDigit; + + //>Display results + System.out.println("The sum of all digits in "+ number + + " is " + sum); + } + +} diff --git a/Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/Total.java b/Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/Total.java new file mode 100644 index 0000000..fc06987 --- /dev/null +++ b/Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/Total.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 com.chloefontenot.mp1_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class Total { + public static void main(String[] args) + { + // Define variables: + double subtotal; + double gratuity; + double total; + + // Get subtotal and gratuity rate + // Setup Scanner + Scanner input = new Scanner(System.in); + + // Get vars + System.out.print("Enter subtotal and gratuity rate: "); + subtotal = input.nextDouble(); + gratuity = input.nextDouble(); + + // Calculate + // Convert gratuity into a decimal because its a percentage: + gratuity = (gratuity / 10); //* 10; + + total = (subtotal + gratuity); + + // Print result + System.out.println("The gratuity is $"+gratuity+" and the total is $"+total); + + } +} diff --git a/Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/WindChill.java b/Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/WindChill.java new file mode 100644 index 0000000..2dac6b2 --- /dev/null +++ b/Semester 1/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/WindChill.java @@ -0,0 +1,33 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp1_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class WindChill { + public static void main(String[] args) { + Scanner input = new Scanner(System.in); + //> Enter the new temperature in Fahrenheit + System.out.print("Enter the temperature in Fahrenheit between -58∞F and 41∞F: "); + double fahrenheit = input.nextDouble(); + + //> Enter the wind speed miles per hour + System.out.print("Enter the wind speed miles per hour "+ + "(must be greater or equal to 2):"); + double speed = input.nextDouble(); + + //> Compute wind and chill index + double windChillIndex = 35.74 + 0.6215 * fahrenheit - 35.75 + * Math.pow(speed, 0.16) + 0.4275 * fahrenheit + * Math.pow(speed, 0.16); + + //> Display the result + System.out.println("The wind chill index is "+ windChillIndex); + } +} diff --git a/Semester 1/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/CheckIBSN_10.java b/Semester 1/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/CheckIBSN_10.java new file mode 100644 index 0000000..77e99b7 --- /dev/null +++ b/Semester 1/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/CheckIBSN_10.java @@ -0,0 +1,56 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp2_chloefontenot; + +import java.util.*; + +/** + * + * @author chloe + */ +public class CheckIBSN_10 { + public static void main(String[] args) + { + // Create scanner + Scanner input = new Scanner(System.in); + // define vars + int digit1, digit2, digit3, digit4, digit5, digit6, digit7, digit8, digit9, inputISBN, outputISBN; + boolean debug = true; + // Scan individual numbers + System.out.print("Enter the first 9 digits of an ISBN as an integer: "); + inputISBN = input.nextInt(); // Get the first 9 digits of the ISBN + + + // Divide the number up into 9 digits + digit1 = inputISBN / 100000000 % 10; + digit2 = inputISBN / 10000000 % 10; + digit3 = inputISBN / 1000000 % 10; + digit4 = inputISBN / 100000 % 10; + digit5 = inputISBN / 10000 % 10; + digit6 = inputISBN / 1000 % 10; + digit7 = inputISBN / 100 % 10; + digit8 = inputISBN / 10 % 10; + digit9 = inputISBN / 1 % 10; + + //Print digits for debugging + if (debug) + { + System.out.println("inputISBN: " + inputISBN); + System.out.println("ISBN split into 9 digits: " + (digit1) + " " + (digit2) + " " + (digit3) + " " + (digit4) + " " + (digit5) + " " + (digit6) + " " + (digit7) + " " + (digit8) + " " + (digit9)); + } + // Calculate! + outputISBN = ((digit1 * 1) + (digit2 * 2) + (digit3 * 3) + (digit4 * 4) + (digit5 * 5) + (digit6 * 6) + (digit7 * 7) + (digit8 * 8) + (digit9 * 9)) % 11; + + //Output + if (outputISBN == 10) + { + System.out.println("The ISBN-10 number is " + digit1+digit2+digit3+digit4+digit5+digit6+digit7+digit8+digit9 + "X"); + } + else + { + System.out.println("The ISBN-10 number is " + digit1+digit2+digit3+digit4+digit5+digit6+digit7+digit8+digit9 + outputISBN); + } + } +} diff --git a/Semester 1/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/DayOfTheWeek.java b/Semester 1/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/DayOfTheWeek.java new file mode 100644 index 0000000..c22fbd8 --- /dev/null +++ b/Semester 1/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/DayOfTheWeek.java @@ -0,0 +1,71 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp2_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class DayOfTheWeek { + public static void main(String[] args) { + // Create scanner + Scanner input = new Scanner(System.in); + // Define variables + int dayOfTheWeek, + dayOfTheMonth, + century, + yearOfTheCentury, + month, + year; + String weekDay = "nullDay"; + + // Prompt for input + System.out.print("Enter year: (e.g., 2022): "); + year = input.nextInt(); + System.out.print("Enter month: 1-12: "); + month = input.nextInt(); + System.out.print("Enter day of the month: 1-31: "); + dayOfTheMonth = input.nextInt(); + + + // Calculate + century = (year / 100); //We are in the 21st century + yearOfTheCentury = year % 100; + + dayOfTheWeek = ((dayOfTheMonth + ((26 * (month + 1)) / 10) + yearOfTheCentury + (yearOfTheCentury / 4) + (century / 4) + (5 * century)) % 7); + System.out.println(dayOfTheWeek); + + // Switch moment + switch (dayOfTheWeek) { + case 0: + weekDay = "Saturday"; + break; + case 1: + weekDay = "Sunday"; + break; + case 2: + weekDay = "Monday"; + break; + case 3: + weekDay = "Tuesday"; + break; + case 4: + weekDay = "Wednesday"; + break; + case 5: + weekDay = "Thursday"; + break; + case 6: + weekDay = "Friday"; + break; + } + + + // Output + System.out.println("Day of the week is " + weekDay); + } +} diff --git a/Semester 1/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/RandomNumber.java b/Semester 1/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/RandomNumber.java new file mode 100644 index 0000000..cebcd67 --- /dev/null +++ b/Semester 1/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/RandomNumber.java @@ -0,0 +1,43 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp2_chloefontenot; + + +/** + * + * @author chloe + */ +public class RandomNumber { + public static void main(String[] args) + { + // Define vars + int number = (int) (Math.random() * 12) + 1; + System.out.println("Random generated number is " + number); + + //long if else chain + if (number == 1) + System.out.println("Month is January"); + else if (number == 2) + System.out.println("Month is February"); + else if (number == 3) + System.out.println("Month is March"); + else if (number == 4) + System.out.println("Month is April"); + else if (number == 5) + System.out.println("Month is June"); + else if (number == 7) + System.out.println("Month is July"); + else if (number == 8) + System.out.println("Month is August"); + else if (number == 9) + System.out.println("Month is September"); + else if (number == 10) + System.out.println("Month is October"); + else if (number == 11) + System.out.println("Month is November"); + else if (number == 12) + System.out.println("Month is December"); + } +} diff --git a/Semester 1/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/RockPaperScissors.java b/Semester 1/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/RockPaperScissors.java new file mode 100644 index 0000000..d92ce49 --- /dev/null +++ b/Semester 1/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/RockPaperScissors.java @@ -0,0 +1,53 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp2_chloefontenot; + +/** + * + * @author chloe + */ +public class RockPaperScissors { + + public static void main(String[] args) { + java.util.Scanner input = new java.util.Scanner(System.in); + System.out.println("Rock, Paper, Scissors! Pick a number to continue."); + while (true) { + int computerNumber = (int) (Math.random() * 3); + System.out.print("scissors (0), rock (1), paper (2): "); + int userNumber = input.nextInt(); + System.out.println("computer number: " + computerNumber); + switch (computerNumber) { + case 0: + if (userNumber == 0) { + System.out.print("The computer chose scissors. You also picked scissors. It's a draw!"); + } else if (userNumber == 1) { + System.out.print("The computer chose scissors. You picked rock. You won!"); + } else if (userNumber == 3) { + System.out.print("The computer chose scissors. You picked paper. You lost."); + } + break; + case 1: + if (userNumber == 0) { + System.out.print("The computer chose rock. You chose scissors. You lost."); + } else if (userNumber == 1) { + System.out.print("The computer chose rock. You also picked rock. It's a draw!"); + } else if (userNumber == 3) { + System.out.print("The computer chose rock. You picked paper. You won!"); + } + break; + case 2: + if (userNumber == 0) { + System.out.print("The computer chose paper. You picked scissors. You won!"); + } else if (userNumber == 1) { + System.out.print("The computer chose paper. You picked rock. You lost."); + } else if (userNumber == 3) { + System.out.print("The computer chose paper. You also picked paper. It's a draw!"); + } + break; + } + System.out.println(""); + } + } +} diff --git a/Semester 1/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/TrianglePerimeter.java b/Semester 1/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/TrianglePerimeter.java new file mode 100644 index 0000000..e3dbee6 --- /dev/null +++ b/Semester 1/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/TrianglePerimeter.java @@ -0,0 +1,30 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp2_chloefontenot; + +/** + * + * @author chloe + */ +public class TrianglePerimeter { + public static void main(String[] args) { + java.util.Scanner input = new java.util.Scanner(System.in); + + // Enter three edges + System.out.print("Enter three edges (length in double): "); + double edge1 = input.nextDouble(), + edge2 = input.nextDouble(), + edge3 = input.nextDouble(); + + // Display results + boolean isValid = (edge1 + edge2 > edge3) && (edge1 + edge3 > edge2) && (edge2 + edge3 > edge1); + + // Display results + if (isValid) + System.out.println("The perimeter is " + (edge1 + edge2 + edge3)); + else + System.out.println("Input is invalid"); + } +} diff --git a/Semester 1/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/MP5_CalebFontenot.java b/Semester 1/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/MP5_CalebFontenot.java new file mode 100644 index 0000000..03c8442 --- /dev/null +++ b/Semester 1/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/MP5_CalebFontenot.java @@ -0,0 +1,83 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template + */ +package com.chloefontenot.mp5_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class MP5_ChloeFontenot { + // Toggles execution of the printArray method. + static final boolean debug = true; + + public static void printArray(boolean[] array) { + // Color codes + final String ANSI_RED = "\u001B[31m"; + final String ANSI_GREEN = "\u001B[32m"; + final String ANSI_WHITE = "\u001B[37m"; + + // Print the array + for (int i = 0; i <= array.length - 1; i++) { + if (array[i]) { + System.out.print(ANSI_GREEN + array[i] + " "); + } else { + System.out.print(ANSI_RED + array[i] + " "); + } + if (i != 0) { + if ((i + 1) % 10 == 0) { + System.out.println(ANSI_WHITE); + } + } + } + } + + public static void solveAndPrint(boolean[] array, int studentCount) { + for (int student = 1; student <= studentCount; student++) { + if (debug) { + System.out.println("Student " + student + " is interacting with the lockers!"); + } + for (int i = 0; i <= array.length - 1; i++) { + if ((i + 1) % student == 0) { + array[i] = !array[i]; + } + } + if (debug) { + printArray(array); + } + } + for (int i = 0; i < array.length; i++) { + if (array[i]) { + System.out.println("Locker " + (i + 1) + " is open."); + } + } + } + + public static int menu() { + // Create scanner + Scanner input = new Scanner(System.in); + int userInput; + do { + System.out.print("Enter 0 to quit, and 1 to enter the number of students: "); + userInput = input.nextInt(); + if (userInput == 1) { + System.out.print("Enter the number of students: "); + userInput = input.nextInt(); + break; + } + + } while (userInput != 0); + return userInput; + } + + public static void main(String[] args) { + final int N = menu(); + boolean[] lockers = new boolean[N]; + // Execute solve and print + solveAndPrint(lockers, N); + + } +} diff --git a/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayCopy1.java b/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayCopy1.java new file mode 100644 index 0000000..302240c --- /dev/null +++ b/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayCopy1.java @@ -0,0 +1,31 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab16_arrays2_chloefontenot; + +/** + * + * @author chloe + */ +public class ArrayCopy1 { + + public static void main(String[] args) + { + int[] sourceArray = {1, 2, 3, 4, 5}; + int[] targetArray = new int[sourceArray.length]; + // Print the source array + for (int i = 0; i < sourceArray.length; i++) { + System.out.print(sourceArray[i] + " "); + } + System.out.println(); + // Copy the source array to the target array + for (int i = 0; i < sourceArray.length; i++) { + targetArray[i] = sourceArray[i]; + } + // Print the target array + for (int i = 0; i < sourceArray.length; i++) { + System.out.print(targetArray[i] + " "); + } + } +} diff --git a/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayCopy2.java b/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayCopy2.java new file mode 100644 index 0000000..13f6af9 --- /dev/null +++ b/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayCopy2.java @@ -0,0 +1,33 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab16_arrays2_chloefontenot; + +/** + * + * @author chloe + */ +public class ArrayCopy2 { + + public static void main(String[] args) + { + int[] sourceArray = {1, 2, 3, 4, 5}; + int[] targetArray = new int[sourceArray.length]; + // Print the source array + for (int i = 0; i < sourceArray.length; i++) { + System.out.print(sourceArray[i] + " "); + } + System.out.println(); + // Copy the source array to the target array in reversed order + int j = (sourceArray.length - 1); + for (int i = 0; i < sourceArray.length; i++) { + targetArray[i] = sourceArray[j]; + j--; + } + // Print the target array + for (int i = 0; i < sourceArray.length; i++) { + System.out.print(targetArray[i] + " "); + } + } +} diff --git a/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayCopy3.java b/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayCopy3.java new file mode 100644 index 0000000..85d512d --- /dev/null +++ b/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayCopy3.java @@ -0,0 +1,29 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab16_arrays2_chloefontenot; + +/** + * + * @author chloe + */ +public class ArrayCopy3 { + + public static void main(String[] args) + { + int[] sourceArray = {1, 2, 3, 4, 5}; + int[] targetArray = new int[sourceArray.length]; + // Print the source array + for (int i = 0; i < sourceArray.length; i++) { + System.out.print(sourceArray[i] + " "); + } + System.out.println(); + // Copy the source array to the target array + System.arraycopy(sourceArray, 0, targetArray, 0, sourceArray.length); + // Print the target array + for (int i = 0; i < sourceArray.length; i++) { + System.out.print(targetArray[i] + " "); + } + } +} diff --git a/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayCopy4.java b/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayCopy4.java new file mode 100644 index 0000000..6c746cd --- /dev/null +++ b/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayCopy4.java @@ -0,0 +1,43 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab16_arrays2_chloefontenot; + +import java.util.Arrays; + +/** + * + * @author chloe + */ +public class ArrayCopy4 { + + public static void main(String[] args) + { + int[] array = {1, 2, 3, 4, 5}; + int[] array1 = Arrays.copyOfRange(array, 2, 5); + int[] array2 = new int[array.length - 2]; + int[] array3 = new int[array.length]; + System.out.println("array1: (copy with java.util.Arrays.copyOfRange(); )"); + for (int i: array1) { + System.out.print(i + " "); + } + System.out.println(); + // Copy array into array2 with a for loop and print it + System.out.println("array2: (copy with System.arraycopy(); )"); + System.arraycopy(array, 2, array2, 0, 3); + for (int i : array2) { + System.out.print(i + " "); + } + System.out.println(); + // Copy array manually + System.out.println("array3: (manually copy with for loop)"); + for (int i : array3) { + array[i] = array3[i]; + } + for (int i : array1) { + System.out.print(i + " "); + } + System.out.println(); + } +} diff --git a/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayShift1.java b/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayShift1.java new file mode 100644 index 0000000..5f7ebd7 --- /dev/null +++ b/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayShift1.java @@ -0,0 +1,31 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab16_arrays2_chloefontenot; + +/** + * + * @author chloe + */ +public class ArrayShift1 { + + public static void main(String[] args) + { + int[] ar = {1, 2, 3, 4, 5}; + int temp = ar[0]; + for (int value : ar) { + System.out.print(value + " "); + } + System.out.println(); + + for (int i = 1; i < ar.length; ++i) { + ar[i - 1] = ar[i]; + } + ar[ar.length - 1] = temp; + + for (int value : ar) { + System.out.print(value + " "); + } + } +} diff --git a/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayShift2.java b/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayShift2.java new file mode 100644 index 0000000..5df4afd --- /dev/null +++ b/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArrayShift2.java @@ -0,0 +1,32 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab16_arrays2_chloefontenot; + +/** + * + * @author chloe + */ +public class ArrayShift2 { + + public static void main(String[] args) + { + int[] ar = {1, 2, 3, 4, 5}; + int temp = ar[ar.length - 1]; + + for (int value : ar) { + System.out.print(value + " "); + } + System.out.println(); + + for (int i = (ar.length -1); i > 0 ; --i) { + ar[i] = ar[i -1]; + } + ar[0] = temp; + + for (int value : ar) { + System.out.print(value + " "); + } + } +} diff --git a/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArraysAndMethods.java b/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArraysAndMethods.java new file mode 100644 index 0000000..bca473f --- /dev/null +++ b/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArraysAndMethods.java @@ -0,0 +1,81 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab16_arrays2_chloefontenot; + +/** + * + * @author chloe + */ +public class ArraysAndMethods { + + public static void printArray(int[] arrayInput) + { + for (int i : arrayInput) { + System.out.print(i + " "); + } + System.out.println(); + } + + public static void printArray(char[] arrayInput) + { + for (int i : arrayInput) { + System.out.print((char) i + " "); + } + System.out.println(); + } + + public static void printArray(double[] arrayInput) + { + for (double i : arrayInput) { + System.out.print(i + " "); + } + System.out.println(); + } + + public static int[] reverse(int[] arrayToReverse) + { + int arrayResult[] = new int[arrayToReverse.length]; + int j = (arrayToReverse.length - 1); + for (int i = 0; i <= arrayToReverse.length - 1; i++) { + arrayResult[i] = arrayToReverse[j]; + j--; + } + return arrayResult; + } + + public static int linearSearch(int list[], int key) + { + int indexFound = -1; + for (int i = 0; i < list.length; ++i) { + if (list[i] == key) { + indexFound = i; + } + } + return indexFound; + } + + public static void main(String[] args) + { + int[] array = {1, 2, 3, 4, 5}; + printArray(array); + printArray(new int[]{3, 1, 2, 6, 4}); + printArray(reverse(array)); + + System.out.println(linearSearch(array, 5) != 1 + ? "found at index " + Integer.toString(linearSearch(array, 5)) + : "not found at index " + Integer.toString(linearSearch(array, 5)) + ); + double[] doubles = {6.0, 4.4, 1.9, 2.9, 3.4, 3.5}; + // Use the built-in sort method to sort the double. + java.util.Arrays.sort(doubles); + + char[] chars = {'a', 'A', '4', 'F', 'D', 'P',}; + //Sort again + java.util.Arrays.sort(chars); + // Now print the sorted arrays. + printArray(doubles); + printArray(chars); + } +} diff --git a/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArraysAndMethodsGames.java b/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArraysAndMethodsGames.java new file mode 100644 index 0000000..82da8a4 --- /dev/null +++ b/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/ArraysAndMethodsGames.java @@ -0,0 +1,62 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab16_arrays2_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class ArraysAndMethodsGames { + public static double min(double[] array) { + // pull the first number from the array, and compare that with the numbers in the rest of the array. If that number is less than the number in than the first number, set it to our lowest. + double lowest = array[0]; + for (int i = 1; i < (array.length -1); i++) { + lowest = Math.min(lowest, array[i]); + } + return lowest; + } + + public static double[] readArray() { + // Create a double array. + int doublesRemaining = 10; + double[] returnArray = new double[doublesRemaining]; + // Create Scanner + Scanner input = new Scanner(System.in); + // Read characters input and write them to an array. + int i = 0; + do { + System.out.print("Enter 10 doubles (" + doublesRemaining + " left ): "); + returnArray[i] = input.nextDouble(); + i++; + doublesRemaining--; + } while (doublesRemaining != 0); + return returnArray; + } + + /** + * + * @param array + * @return Returns an average of an array. + */ + public static double average(double[] array) { + // Iterate through array and add values together into double, then divide by the amount of items in the array. + double returnDouble = 0.0; + for (double i: array) { + returnDouble += i; + } + returnDouble /= (double) array.length; + return returnDouble; + } + + public static void main(String[] args) + { + double[] doubleArray = new double[10]; + doubleArray = readArray(); + System.out.println("average function returns: " + average(doubleArray)); + System.out.println("lowest function returns: " + min(doubleArray)); + } +} diff --git a/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/Lab16_arrays2_CalebFontenot.java b/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/Lab16_arrays2_CalebFontenot.java new file mode 100644 index 0000000..68438cc --- /dev/null +++ b/Semester 1/Assignments/lab16_arrays2_ChloeFontenot/src/main/java/com/chloefontenot/lab16_arrays2_chloefontenot/Lab16_arrays2_CalebFontenot.java @@ -0,0 +1,17 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template + */ + +package com.chloefontenot.lab16_arrays2_chloefontenot; + +/** + * + * @author chloe + */ +public class Lab16_arrays2_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 1/Assignments/lab17_ChloeFontenot/src/main/java/com/chloefontenot/lab17_chloefontenot/Lab17_CalebFontenot.java b/Semester 1/Assignments/lab17_ChloeFontenot/src/main/java/com/chloefontenot/lab17_chloefontenot/Lab17_CalebFontenot.java new file mode 100644 index 0000000..c4e470c --- /dev/null +++ b/Semester 1/Assignments/lab17_ChloeFontenot/src/main/java/com/chloefontenot/lab17_chloefontenot/Lab17_CalebFontenot.java @@ -0,0 +1,102 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template + */ +package com.chloefontenot.lab17_chloefontenot; + +/** + * + * @author chloe + */ +public class Lab17_ChloeFontenot { + + public static void main(String[] args) + { + final int NUM_TO_SEARCH_FOR = 2; + int[] originalArray = new int[]{420, 41, 7, 2, 26, 2243}; + System.out.print("Original array: "); + printArray(originalArray); + selectionSort(originalArray); + System.out.print("Sorted array: "); + printArray(originalArray); + + System.out.println("Binary Search"); + System.out.println("-----------------------"); + System.out.println("binarySearchWhile() returns: " + binarySearchWhile(originalArray, NUM_TO_SEARCH_FOR)); + isInArray(binarySearchWhile(originalArray, NUM_TO_SEARCH_FOR), NUM_TO_SEARCH_FOR); + + System.out.println("binarySearchFor() returns: " + binarySearchFor(originalArray, NUM_TO_SEARCH_FOR)); + isInArray(binarySearchFor(originalArray, NUM_TO_SEARCH_FOR), NUM_TO_SEARCH_FOR); + + } + + public static void isInArray(int arrayResult, int searchQuery) + { + if (arrayResult == 0) { + System.out.println(searchQuery + " is in the array."); + } else { + System.out.println(searchQuery + " is not in the array."); + } + } + + public static int[] selectionSort(int[] arr) + { + // Sort an array by comparing each and every item in the array and swapping them if they are less than the following number + for (int i = 0; i < arr.length - 1; ++i) { + for (int j = i; j < arr.length; ++j) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + return arr; + } + + public static void printArray(int[] arr) + { + for (int i : arr) { + System.out.print(i + " "); + } + System.out.println(); + } + + //replace fors with whiles + public static int binarySearchWhile(int[] ar, int key) + { + int low = 0; + int high = ar.length - 1; + while (high >= low) { + int mid = (low + high) / 2; + if (key < ar[mid]) { + high = mid - 1; + } else if (key == ar[mid]) { + return mid; + } else { + low = mid + 1; + } + } + return 1; + + } + //replace while with for + + public static int binarySearchFor(int[] ar, int key) + { + int low = 0; + int high = ar.length - 1; + for (low = 0; high >= low;) { + int mid = (low + high) / 2; + if (key < ar[mid]) { + high = mid - 1; + } else if (key == ar[mid]) { + return mid; + } else { + low = mid + 1; + } + } + return 1; + } + +} diff --git a/Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/ABCD.java b/Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/ABCD.java new file mode 100644 index 0000000..3af0a93 --- /dev/null +++ b/Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/ABCD.java @@ -0,0 +1,17 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab4_chloefontenot; + +/** + * + * @author chloe + */ +public class ABCD { + public static void main(String[] args) + { + int ABCD = 1234; + System.out.println(ABCD % 100); + } +} diff --git a/Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/Debug1.java b/Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/Debug1.java new file mode 100644 index 0000000..bba1206 --- /dev/null +++ b/Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/Debug1.java @@ -0,0 +1,18 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab4_chloefontenot; + +/** + * + * @author chloe + */ +public class Debug1 { + public static void main(String[] args) + { + int i = 1; + int j = i * i * i; + System.out.println( j ); + } +} diff --git a/Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/Debug2.java b/Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/Debug2.java new file mode 100644 index 0000000..3342543 --- /dev/null +++ b/Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/Debug2.java @@ -0,0 +1,19 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab4_chloefontenot; + +/** + * + * @author chloe + */ +public class Debug2 { + public static void main(String[] args) + { + + int i = 9; + int j = (int)((5.0 / 6) * (i * 4)); + System.out.println(j); + } +} diff --git a/Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/Debug3.java b/Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/Debug3.java new file mode 100644 index 0000000..fd2e669 --- /dev/null +++ b/Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/Debug3.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab4_chloefontenot; + +/** + * + * @author chloe + */ +public class Debug3 { + public static void main(String[] args) + { + System.out.println((long)2147483647 + 1); + } +} diff --git a/Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/Debug5.java b/Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/Debug5.java new file mode 100644 index 0000000..ad99c88 --- /dev/null +++ b/Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/Debug5.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab4_chloefontenot; + +/** + * + * @author chloe + */ +public class Debug5 { + public static void main(String[] args) + { + System.out.println("1 + 2 is "+ (1 + 2)); + } +} diff --git a/Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/Lab4_CalebFontenot.java b/Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/Lab4_CalebFontenot.java new file mode 100644 index 0000000..df4f049 --- /dev/null +++ b/Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/Lab4_CalebFontenot.java @@ -0,0 +1,34 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template + */ + +package com.chloefontenot.lab4_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class Lab4_ChloeFontenot { + + public static void main(String[] args) { + // Setup Scanner; + Scanner input = new Scanner(System.in); + + System.out.println("Enter i, j, x, and y: "); + int i = input.nextInt(); + int j = input.nextInt(); + double x = input.nextDouble(); + double y = input.nextDouble(); + //int i = 11, + // j = 22; + //double x = 11.11, + // y = 22.22; + + // Changed addition to division + System.out.println("\n" + i + " / " + j + " = " + (i / j)); + System.out.println("\n" + x + " / " + y + " = " + (x / y)); + } +} diff --git a/Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/payroll.java b/Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/payroll.java new file mode 100644 index 0000000..02c4793 --- /dev/null +++ b/Semester 1/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab4_chloefontenot/payroll.java @@ -0,0 +1,64 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab4_chloefontenot; + +import java.text.DecimalFormat; +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class payroll { + + public static void main(String[] args) + { + // Create Scanner + Scanner input = new Scanner(System.in); + + // Define vars + String employeeName; + double hoursWorked; + double hourlyPayRate; + double federalTaxWithholdingRate; + double stateTaxWithholdingRate; + double grossPay; + double federalWithholding; + double stateWithholding; + double totalDeduction; + + // Prompt for input + System.out.print("Enter employee's name: "); + employeeName = input.next(); + System.out.print("Enter the number of hours worked in a week: "); + hoursWorked = input.nextDouble(); + System.out.print("Enter the hourly pay rate: $"); + hourlyPayRate = input.nextDouble(); + System.out.print("Enter the federal tax witholding rate (as a decimal, please!): "); + federalTaxWithholdingRate = input.nextDouble(); + System.out.print("Enter the state tax withholding rate (as a decimal, please!): "); + stateTaxWithholdingRate = input.nextDouble(); + System.out.println(""); //empty space + + // Setup Decimal fomatting + DecimalFormat df = new DecimalFormat("#0.00"); + + // Calculate + grossPay = (hoursWorked * hourlyPayRate); + federalWithholding = (grossPay * federalTaxWithholdingRate); + stateWithholding = (grossPay * stateTaxWithholdingRate); + totalDeduction = (grossPay - (federalWithholding + stateWithholding)); + + // Print output + System.out.println("Employee Name: "+employeeName); + System.out.println("Hours Worked: "+hoursWorked); + System.out.println("Pay Rate: $"+ df.format(hourlyPayRate)); + System.out.println("Gross Pay: $"+df.format(grossPay)); + System.out.println("Deductions:"); + System.out.println("\t"+"Federal Withholding ("+ (federalTaxWithholdingRate * 100.0)+"%):$"+df.format(federalWithholding)); + System.out.println("\t"+"State Withholding ("+ (stateTaxWithholdingRate * 100.0)+"%):$"+df.format(stateWithholding)); + System.out.println("Total Deduction: $"+df.format(totalDeduction)); + } +} diff --git a/Semester 1/Assignments/lab5_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/Lab5_CalebFontenot.java b/Semester 1/Assignments/lab5_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/Lab5_CalebFontenot.java new file mode 100644 index 0000000..3c1fb27 --- /dev/null +++ b/Semester 1/Assignments/lab5_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/Lab5_CalebFontenot.java @@ -0,0 +1,17 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template + */ + +package com.chloefontenot.lab5_chloefontenot; + +/** + * + * @author chloe + */ +public class Lab5_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 1/Assignments/lab5_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/Operators.java b/Semester 1/Assignments/lab5_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/Operators.java new file mode 100644 index 0000000..a1e725c --- /dev/null +++ b/Semester 1/Assignments/lab5_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/Operators.java @@ -0,0 +1,48 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab5_chloefontenot; + +/** + * + * @author chloe + */ +public class Operators { + public static void main(String[] args) + { + int x = 8; int y = 15; double d = 2; + + //1. Increment x by 2; + //add code here + x += 2; + + //2. Increment y by 5 using the += operator + //add code here + y += 5; + + //3. Increment d by 1 using the ++ operator + //add code here + d++; + + //4. Modify the expression below to print z1 = 1.5 and not 0.0 + double z1 = ((double) x /(double) y ) * d++; + System.out.println("z1: " + z1 ); + + //5. Modify the expresion below the print z2 = 2.5 and not 0.0 + double z2 = ((double) x /(double) y ) * ++d; + System.out.println("z2: " + z2 ); + + /* 6. Declare a variable z3 of type double and modify the + right hand side of the expression you built in step 5 for the + expression to evaluate 2.0. + Assign the evaluation to varible z3 + */ + double z3 = ((double) x /(double) y * (d - 1)); + //add code here + System.out.println("z3: "+ z3 ); + + System.out.println("x=" + x + " y=" + y + " d=" + d + + " z1="+ z1 + " z2=" +z2 + " z3=" +z3); + } +} diff --git a/Semester 1/Assignments/lab5_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/Swap.java b/Semester 1/Assignments/lab5_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/Swap.java new file mode 100644 index 0000000..71270c0 --- /dev/null +++ b/Semester 1/Assignments/lab5_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/Swap.java @@ -0,0 +1,36 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab5_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class Swap { + public static void main(String[] args) + { + // Create scanner + Scanner input = new Scanner(System.in); + + // Define vars + double base, + power, + output; + + // Prompt for input + System.out.println("Enter the base to calculate: "); + base = input.nextDouble(); + System.out.println("Enter the power to calculate: "); + power = input.nextDouble(); + + // Calculate + output = Math.pow(base, power); + + // Print result + System.out.println(base+"^"+power+" = "+ output); + } +} diff --git a/Semester 1/Assignments/lab5_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/WhatsYourName.java b/Semester 1/Assignments/lab5_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/WhatsYourName.java new file mode 100644 index 0000000..3b5dae4 --- /dev/null +++ b/Semester 1/Assignments/lab5_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/WhatsYourName.java @@ -0,0 +1,32 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab5_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class WhatsYourName { + public static void main(String[] args) + { + // Create Scanner + Scanner input = new Scanner(System.in); + + // Declare vars + String firstName, + lastName; + + // Prompt for input + System.out.print("What's your name? (Enter first and last) "); + firstName = input.next(); + lastName = input.next(); + + // Print output + System.out.println(firstName + " " + lastName + " is a beautiful name!"); + + } +} diff --git a/Semester 1/Assignments/lab5_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/WhatsYourSSN.java b/Semester 1/Assignments/lab5_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/WhatsYourSSN.java new file mode 100644 index 0000000..5fc432f --- /dev/null +++ b/Semester 1/Assignments/lab5_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/WhatsYourSSN.java @@ -0,0 +1,29 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab5_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class WhatsYourSSN { + public static void main(String[] args) + { + // Create Scanner + Scanner input = new Scanner(System.in); + + // Declare vars + String ssn; + + // Prompt for input + System.out.print("What's your SSN? "); + ssn = input.next(); + + // Print output + System.out.println(ssn + " is your SSN."); + } +} diff --git a/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/If1.java b/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/If1.java new file mode 100644 index 0000000..700ca49 --- /dev/null +++ b/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/If1.java @@ -0,0 +1,28 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab6_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class If1 { + public static void main(String[] args) + { + System.out.println("Please type a positive number: "); + + /* + Observe that the varible scan is eliminated + Explanation: We create a new object by using "new Scanner" and + then the DOT (.) nextInt() uses that new object (new varibale) to read + */ + int number = new Scanner(System.in).nextInt(); + + if ( number >= 0 ) + System.out.println("You typed a positive number! It was number " + number + "!"); + } +} diff --git a/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/If2.java b/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/If2.java new file mode 100644 index 0000000..855a51c --- /dev/null +++ b/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/If2.java @@ -0,0 +1,20 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab6_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class If2 { + public static void main(String[] args) { + System.out.println("Please type a positive number: "); + + if (new Scanner(System.in).nextInt() >= 0 ) + System.out.println("Tou typed a positive number!"); + } +} diff --git a/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/If3.java b/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/If3.java new file mode 100644 index 0000000..a2dde31 --- /dev/null +++ b/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/If3.java @@ -0,0 +1,24 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab6_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class If3 { + public static void main(String[] args) { + int number; + + System.out.println("Please type a positive number: "); + + if ( (number = new Scanner(System.in).nextInt() ) >= 0 ) + System.out.println("Tou typed a positive number. It was number " + number + "!"); + else + System.out.println("You typed a negative number. It was number " + number + "!"); + } +} diff --git a/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/IfElse1.java b/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/IfElse1.java new file mode 100644 index 0000000..6e6f3e2 --- /dev/null +++ b/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/IfElse1.java @@ -0,0 +1,27 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab6_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class IfElse1 { + public static void main(String[] args) { + System.out.println("Please type a positive number: "); + + /* + Observe that the variable scan is eliminated + Explanation: We create a new object by using "new Scanner" and + then the DOT (.) nextInt() uses that new object (new variable) to read. + */ + int number = new Scanner(System.in).nextInt(); + + if ( number >= 0 ) + System.out.println("You typed a positive number! It was number " + number + "!"); + } +} diff --git a/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/IfElse2.java b/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/IfElse2.java new file mode 100644 index 0000000..e210488 --- /dev/null +++ b/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/IfElse2.java @@ -0,0 +1,32 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab6_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class IfElse2 { + public static void main(String[] args) { + // Setup variables + int number; + + // Prompt for input + System.out.print("Please enter a even or odd number: "); + number = new Scanner(System.in).nextInt(); // Creates scanner just to read a value for number, but doesn't keep the scanner in memory. + + // Determine with if statement and Output + if ( number % 2 == 0 ) // An even number when divided by 2 will ALWAYS have a remainder that equals 0 + { + System.out.println("You typed the EVEN number " + number); + } + else + { + System.out.println("You typed the ODD number " + number); + } + } +} diff --git a/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/IfElse3.java b/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/IfElse3.java new file mode 100644 index 0000000..03702ef --- /dev/null +++ b/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/IfElse3.java @@ -0,0 +1,33 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab6_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class IfElse3 { + public static void main(String[] args) { + System.out.print("Please type today's temperature and I will comment on it: "); + Scanner scan = new Scanner(System.in); + double todaysTemperature = scan.nextDouble(); + + if ( todaysTemperature >= 120) + System.out.println("Come on dude! Be serious!"); + else if ( todaysTemperature >= 100) + System.out.println("Very, very hot at " + todaysTemperature + "!"); + else if ( todaysTemperature >= 85) + System.out.println("hot at " + todaysTemperature); + else if ( todaysTemperature >= 70 ) + System.out.println("Pleasant at " + todaysTemperature); + else if ( todaysTemperature >= 40 ) + System.out.println("A bit cold at " + todaysTemperature); + else + System.out.println("bbbrrrrrrr at " + todaysTemperature + "!"); + + } +} diff --git a/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/IfElse4.java b/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/IfElse4.java new file mode 100644 index 0000000..891b8e7 --- /dev/null +++ b/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/IfElse4.java @@ -0,0 +1,74 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab6_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class IfElse4 { + + static double inputPrompt() { + double grade; + System.out.print("Enter your exam grade for it to be letter graded: "); + grade = new Scanner(System.in).nextDouble(); + return grade; + } + static void ifLogic(double grade) { + // Use if else logic and output + if (grade > 100) { + System.out.println("Your grade seems too high, please try again..."); + throw new IllegalArgumentException("Invalid grade entered!"); + } + else if ( grade > 90) + { + System.out.println("Congrats! You got a " + grade + ", which means you got an A!"); + } + else if ( grade > 80) + { + System.out.println("Good job! You got a " + grade + ", which means you got a B!"); + } + else if ( grade > 70) + { + System.out.println("Not bad, you got a " + grade + ", which means you got a C."); + } + else if ( grade > 60) + { + System.out.println("You got a " + grade + ", which means you got a D."); + } + else if (grade < 0) { + System.out.println("Your grade seems too low, please try again..."); + throw new IllegalArgumentException("Invalid grade entered!"); + } + else + { + System.out.println("Sorry, you got a " + grade + ", so you unfortunately got an F."); + } + } + + public static void main(String[] args) { + // Setup variables + double grade; + String letterGrade; + + while (true) { // Unintended behavior: This will only run twice. I intended this try and catch to run indefinately, but it only will catch once before terminating on its own. + // Call ifLogic function + try { + // Prompt for input + grade = inputPrompt(); + ifLogic(grade); + System.exit(0); + } + catch(Exception IllegalArgumentException) { // ifLogic failed, try again... + // Prompt for input + grade = inputPrompt(); + ifLogic(grade); + } + } + } + +} diff --git a/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/Lab6_CalebFontenot.java b/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/Lab6_CalebFontenot.java new file mode 100644 index 0000000..dfd94f9 --- /dev/null +++ b/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/Lab6_CalebFontenot.java @@ -0,0 +1,25 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template + */ +package com.chloefontenot.lab6_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class Lab6_ChloeFontenot { + + public static void main(String[] args) + { + System.out.println("Please type a positive number: "); + Scanner scan = new Scanner(System.in); + int number = scan.nextInt(); + + if (number >= 0) { + System.out.println("You typed a positive number! It was number " + number + "!"); + } + } +} diff --git a/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/Triangle.java b/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/Triangle.java new file mode 100644 index 0000000..7e6bfac --- /dev/null +++ b/Semester 1/Assignments/lab6_ChloeFontenot/src/main/java/com/chloefontenot/lab6_chloefontenot/Triangle.java @@ -0,0 +1,44 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab6_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class Triangle { + public static void main(String[] args) { + // Setup variables + double x1, + y1, + xIntercept; + + // Create scanner + Scanner input = new Scanner(System.in); + + // Prompt for input + System.out.print("Enter a point's x and y coords: "); + x1 = input.nextDouble(); + y1 = input.nextDouble(); + + // Calculate! + + // 2. Calculate x by -.5 and add 100 to that + xIntercept = ((-0.5 * x1) + 100); + System.out.println("x intercept is " + xIntercept); + // Check if y is inside of the triangle + + if (y1 <= xIntercept) + { + System.out.println(x1 +", "+ y1 + " is inside of the triangle!"); + } + else + { + System.out.println(x1 +", "+ y1 + " is outside of the triangle!"); + } + } +} diff --git a/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/And1.java b/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/And1.java new file mode 100644 index 0000000..699c7e3 --- /dev/null +++ b/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/And1.java @@ -0,0 +1,29 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab7_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class And1 { + public static void main(String[] args) + { + System.out.print("please enter a number between 0 and 10: "); + int number = new Scanner(System.in).nextInt(); + + /* + the &&is the AND operator which ANDs 2 operands + The ANDing evaluates to true if both of the operands of the AND are true + UNDERSTAND THIS AND &&, please + */ + if ( number >= 0 && number <= 10 ) + System.out.println("\nthank you for entering number " + number ); + else + System.out.println("\n" + number + " is not between 0 and 10! What's wrong with you man?"); + } +} diff --git a/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/And2.java b/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/And2.java new file mode 100644 index 0000000..a90ccfd --- /dev/null +++ b/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/And2.java @@ -0,0 +1,37 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab7_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class And2 { + public static void main(String[] args) + { + // Create Scanner + Scanner input = new Scanner(System.in); + + // Setup vars + int number; + + // Prompt for input + System.out.print("Please enter a number that is divisable by 10 and greater than 100: "); + number = input.nextInt(); + + // Compute + if ( number % 10 == 0 && number > 100) + { + System.out.println("Thanks for entering number " + number+ "!"); + } + else + { + System.out.println(number + " is not fufilling the request!"); + } + + } +} diff --git a/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Bonus.java b/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Bonus.java new file mode 100644 index 0000000..2e69e20 --- /dev/null +++ b/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Bonus.java @@ -0,0 +1,57 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab7_chloefontenot; + +import java.util.Scanner; +import java.text.NumberFormat; + +/** + * + * @author chloe + */ +public class Bonus { + public static void main(String[] args) + { + //Setup currency formatter + NumberFormat defaultFormat = NumberFormat.getCurrencyInstance(); + // Create scanner + Scanner input = new Scanner(System.in); + + // Setup vars + String lastName, + firstName; + double thisYearsUnits, + lastYearsUnits, + bonus = 0; + + // Prompt for input + System.out.print("Enter last name: "); + lastName = input.nextLine(); + System.out.print("Enter first name: "); + firstName = input.nextLine(); + System.out.print("Enter this year's units: "); + thisYearsUnits = input.nextDouble(); + System.out.print("Enter last year's units: "); + lastYearsUnits = input.nextDouble(); + + // Compute! + if (thisYearsUnits > lastYearsUnits) { + if (1000 > thisYearsUnits) // If thisYearsUnits is less than 1000 + bonus = 25; + else if (thisYearsUnits > 1000 && thisYearsUnits < 3000) // If thisYearsUnits is more than 1000, but less than 3000 + bonus = 50; + else if (thisYearsUnits > 3000 && thisYearsUnits < 6000) // If thisYearsUnits is more than 3000, but less than 6000 + bonus = 100; + else if (thisYearsUnits > 6000) // 6000 and up + bonus = 200; + } + + // Output + System.out.println("Employee Name: "); + System.out.println("\t"+ lastName + ", " + firstName); + System.out.println("Bonus is "+ defaultFormat.format(bonus)); + + } +} diff --git a/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Debug1.java b/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Debug1.java new file mode 100644 index 0000000..c9f070c --- /dev/null +++ b/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Debug1.java @@ -0,0 +1,20 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab7_chloefontenot; + +/** + * + * @author chloe + */ +public class Debug1 { + public static void main(String[] args) + { + int i=1, j=2, k=3; + if (i < j && i < k && j < k) + { + System.out.println("i, j, and k are in increasing order"); + } + } +} diff --git a/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/DivisionQuiz.java b/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/DivisionQuiz.java new file mode 100644 index 0000000..a69428b --- /dev/null +++ b/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/DivisionQuiz.java @@ -0,0 +1,67 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab7_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class DivisionQuiz { + + public static void main(String[] args) + { + // Create scanner + Scanner input = new Scanner(System.in); + // Setup variables + int number1, + number2, + answerQuotient, + answerRemainder; + boolean cheatMode = false; // Used for debugging + + while (true) { + // Get random numbers between 1-100 + number1 = (int) (Math.random() * 100); + number2 = (int) (Math.random() * 100); + + // If number1 < number2, flip them + if (number1 < number2) { + int tmp = number2; + number2 = number1; + number1 = tmp; + } + + //Prompt + if (cheatMode == true) { + System.out.println("CHEAT MODE: the quotient of " + number1 + " / " + number2 + " is " + (number1 / number2)); + } + System.out.print(" What is the quotient of " + number1 + " / " + number2 + "? "); + answerQuotient = input.nextInt(); + if (cheatMode == true) { + System.out.println("CHEAT MODE: the remainder of " + number1 + " % " + number2 + " is " + (number1 % number2)); + } + System.out.print(" What is the remainder of " + number1 + " / " + number2 + "? "); + answerRemainder = input.nextInt(); + + // Check if answers are correct + if ((number1 / number2) == answerQuotient) //Checks the quotient + { + System.out.println("You are correct about the quotient!"); + } else { + System.out.println("You are wrong about the quotient."); + System.out.println("The quotient of " + number1 + " / " + number2 + " is " + (number1 / number2)); + } + if ((number1 % number2) == answerRemainder) //Checks the remainder + { + System.out.println("You are correct about the remainder!"); + } else { + System.out.println("You are wrong about the remainder."); + System.out.println("The remainder of " + number1 + " % " + number2 + " is " + (number1 % number2)); + } + } + } +} diff --git a/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Not1.java b/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Not1.java new file mode 100644 index 0000000..892574e --- /dev/null +++ b/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Not1.java @@ -0,0 +1,38 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab7_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class Not1 { + public static void main(String[] args) + { + System.out.print("Please enter a number between 0 and 10: "); + int number = new Scanner(System.in).nextInt(); + /* + The ! is the NOT operator which reverses a boolean expression. + If the expression is true, the not makes it false and vice-versa. + + the || is the OR operator which ORs 2 operands + This is the equivalent AND1 by using OR and NOT + + 1. The && is replaced by || + 2. The relational operators are reversed + 3. There is a ! (NOT) outside the prenthesis + */ + if ( ! (number < 0 || number > 10) ) + { + System.out.println("\nThank you for entering number " + number + "!"); + } + else { + System.out.println("\n" + number + " is not between 0 and 10! What's wrong with you man?"); + } + } + +} diff --git a/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Not2.java b/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Not2.java new file mode 100644 index 0000000..1feb2a8 --- /dev/null +++ b/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Not2.java @@ -0,0 +1,38 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab7_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class Not2 { + public static void main(String[] args) + { + // Create Scanner + Scanner input = new Scanner(System.in); + + // Setup vars + int number; + + // Prompt for input + System.out.print("Please enter a number that is divisable by 10 and greater than 100: "); + number = input.nextInt(); + + // Compute + //if ( number % 10 == 0 && number > 100) + if ( ! (number % 10 != 0 || number < 100) ) + { + System.out.println("Thanks for entering number " + number+ "!"); + } + else + { + System.out.println(number + " is not fufilling the request!"); + } + + } +} diff --git a/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Or1.java b/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Or1.java new file mode 100644 index 0000000..d8155d5 --- /dev/null +++ b/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Or1.java @@ -0,0 +1,29 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab7_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class Or1 { + public static void main(String[] args) + { + System.out.println("Please enter a number less than 0 or greater than or equal to 1,000"); + int number = new Scanner(System.in).nextInt(); + + /* + The || is the OR operator which ORs 2 operands + The ORing evaluates to true if either of the operands of the OR is true + UNDERSTAND THIS OR || please + */ + if (number < 0 || number >= 1000) + System.out.println("\nThank you for entering number " + number ); + else + System.out.println("\n " + number + " is not fulfilling the request!"); + } +} diff --git a/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Or2.java b/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Or2.java new file mode 100644 index 0000000..1f7ce33 --- /dev/null +++ b/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/Or2.java @@ -0,0 +1,36 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab7_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class Or2 { + public static void main(String[] args) + { + // Create scanner + Scanner input = new Scanner(System.in); + + // Define vars + int number; + + // Prompt for input + System.out.print("Please enter a number less than 0 or divisable by 3 or both: "); + number = input.nextInt(); + + // Compute + if ( number % 3 == 0 || number < 0) + { + System.out.println("Thank you for entering number " + number); + } + else + { + System.out.println(number + " is not fufilling the request!"); + } + } +} diff --git a/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/SubtractionQuiz.java b/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/SubtractionQuiz.java new file mode 100644 index 0000000..86956d3 --- /dev/null +++ b/Semester 1/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/SubtractionQuiz.java @@ -0,0 +1,45 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab7_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class SubtractionQuiz { + public static void main(String[] args) + { + // Create scanner outside of loop so we don't create it over and over again + Scanner input = new Scanner(System.in); + while(true) { + // 1. Generate two random single-digit integers + int number1 = (int)(Math.random() * 10); + int number2 = (int)(Math.random() * 10); + + // 2. If number < number2, swap number1 with number2 + if (number1 < number2) + { + int temp = number1; + number1 = number2; + number2 = temp; + } + + // 3. Prompt the student to answer "what is number1 - number2?" + System.out.print("What is " + number1 + " - " + number2 + "? "); + int answer = input.nextInt(); + + // 4. Grade the answer and display the result + if (number1 - number2 == answer) + System.out.println("You are correct!"); + else + { + System.out.println("Your answer is wrong."); + System.out.println(number1 + " - " + number2 + "should be" + (number1 - number2)); + } + } + } +} diff --git a/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/ConditionalOperator1.java b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/ConditionalOperator1.java new file mode 100644 index 0000000..92bb845 --- /dev/null +++ b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/ConditionalOperator1.java @@ -0,0 +1,26 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class ConditionalOperator1 { + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + + System.out.print("please enter an even number: "); + int number = scan.nextInt(); + if ( number % 2 == 0 ) + System.out.print("\n" + number + " fufills the request!"); + else + System.out.print("\n" + number + " does not fufill the request!"); + + System.out.println(number % 2 == 0 ? " yes sir!" : " no sir!"); + } +} diff --git a/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/ConditionalOperator2.java b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/ConditionalOperator2.java new file mode 100644 index 0000000..28043e8 --- /dev/null +++ b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/ConditionalOperator2.java @@ -0,0 +1,19 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +/** + * + * @author chloe + */ +public class ConditionalOperator2 { + public static void main(String[] args) { + java.util.Scanner input = new java.util.Scanner(System.in); + double x = input.nextDouble(); + double y = input.nextDouble(); + double z = input.nextDouble(); + System.out.println((x < y && y < z) ? "sorted" : "not sorted"); + } +} diff --git a/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/ConditionalOperator3.java b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/ConditionalOperator3.java new file mode 100644 index 0000000..9f195de --- /dev/null +++ b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/ConditionalOperator3.java @@ -0,0 +1,19 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +/** + * + * @author chloe + */ +public class ConditionalOperator3 { + public static void main(String[] args) { + java.util.Scanner input = new java.util.Scanner(System.in); + double x = input.nextDouble(); + double y = input.nextDouble(); + double z = input.nextDouble(); + System.out.println((x < y && y < z) ? 100 : 200); + } +} diff --git a/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/ConditionalOperator4.java b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/ConditionalOperator4.java new file mode 100644 index 0000000..dd794f3 --- /dev/null +++ b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/ConditionalOperator4.java @@ -0,0 +1,26 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class ConditionalOperator4 { + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + + System.out.print("please enter an even number: "); + int number = scan.nextInt(); + System.out.print("\n" + number + ( number % 2 == 0 ? " fufills the request!" : " does not fufill the request!")); + + if (number % 2 == 0) + System.out.println(" yes sir!"); + else + System.out.println(" no sir!"); + } +} diff --git a/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/DecimalToHex1.java b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/DecimalToHex1.java new file mode 100644 index 0000000..34d3b78 --- /dev/null +++ b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/DecimalToHex1.java @@ -0,0 +1,66 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class DecimalToHex1 { + public static void main(String[] args) { + // Define vars + int inputDecimal, + outputHex = 0x0; + + // Create scanner + Scanner input = new Scanner(System.in); + + // Prompt for input + System.out.print("Enter a decimal value (0-15): "); + inputDecimal = input.nextInt(); + + // Switch moment + switch (inputDecimal) { + case 0: + outputHex = 0x0; break; + case 1: + outputHex = 0x1; break; + case 2: + outputHex = 0x2; break; + case 3: + outputHex = 0x3; break; + case 4: + outputHex = 0x4; break; + case 5: + outputHex = 0x5; break; + case 6: + outputHex = 0x6; break; + case 7: + outputHex = 0x7; break; + case 8: + outputHex = 0x8; break; + case 9: + outputHex = 0x9; break; + case 10: + outputHex = 0xA; break; + case 11: + outputHex = 0xB; break; + case 12: + outputHex = 0xC; break; + case 13: + outputHex = 0xD; break; + case 14: + outputHex = 0xE; break; + case 15: + outputHex = 0xF; break; + + } + + // Output + System.out.println("The hex value is " + String.format("%x", outputHex)); + } +} diff --git a/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/DecimalToHex2.java b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/DecimalToHex2.java new file mode 100644 index 0000000..aee5014 --- /dev/null +++ b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/DecimalToHex2.java @@ -0,0 +1,65 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class DecimalToHex2 { + + public static void main(String[] args) { + // Define vars + int inputDecimal, + outputHex = 0x0; + + // Create scanner + Scanner input = new Scanner(System.in); + + // Prompt for input + System.out.print("Enter a decimal value (0-15): "); + inputDecimal = input.nextInt(); + + // Switch moment + if (inputDecimal == 0) { + outputHex = 0x0; + } else if (inputDecimal == 1) { + outputHex = 0x1; + } else if (inputDecimal == 2) { + outputHex = 0x2; + } else if (inputDecimal == 3) { + outputHex = 0x3; + } else if (inputDecimal == 4) { + outputHex = 0x4; + } else if (inputDecimal == 5) { + outputHex = 0x5; + } else if (inputDecimal == 6) { + outputHex = 0x6; + } else if (inputDecimal == 7) { + outputHex = 0x7; + } else if (inputDecimal == 8) { + outputHex = 0x8; + } else if (inputDecimal == 9) { + outputHex = 0x9; + } else if (inputDecimal == 10) { + outputHex = 0xA; + } else if (inputDecimal == 11) { + outputHex = 0xB; + } else if (inputDecimal == 12) { + outputHex = 0xC; + } else if (inputDecimal == 13) { + outputHex = 0xD; + } else if (inputDecimal == 14) { + outputHex = 0xE; + } else if (inputDecimal == 15) { + outputHex = 0xF; + } + + // Output + System.out.println("The hex value is " + String.format("%x", outputHex)); + } +} diff --git a/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Lab8_CalebFontenot.java b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Lab8_CalebFontenot.java new file mode 100644 index 0000000..da9612c --- /dev/null +++ b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Lab8_CalebFontenot.java @@ -0,0 +1,17 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template + */ + +package com.chloefontenot.lab8_chloefontenot; + +/** + * + * @author chloe + */ +public class Lab8_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch1.java b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch1.java new file mode 100644 index 0000000..0e65306 --- /dev/null +++ b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch1.java @@ -0,0 +1,36 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class Switch1 { + public static void main(String[] args) { + // Create scanner + Scanner input = new Scanner(System.in); + + System.out.print("Enter a year to tell you a Chinese joke: "); + int year = input.nextInt(); + + switch (year % 12) { + case 0: System.out.println("monkey"); break; + case 1: System.out.println("rooster"); break; + case 2: System.out.println("dog"); break; + case 3: System.out.println("pig"); break; + case 4: System.out.println("rat"); break; + case 5: System.out.println("ox"); break; + case 6: System.out.println("tiger"); break; + case 7: System.out.println("rabbit"); break; + case 8: System.out.println("dragon"); break; + case 9: System.out.println("snake"); break; + case 10: System.out.println("horse"); break; + case 11: System.out.println("sheep"); break; + } + } +} diff --git a/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch1ConvertedToIfElse.java b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch1ConvertedToIfElse.java new file mode 100644 index 0000000..7b53c55 --- /dev/null +++ b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch1ConvertedToIfElse.java @@ -0,0 +1,46 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class Switch1ConvertedToIfElse { + public static void main(String[] args) { + // Create scanner + Scanner input = new Scanner(System.in); + + System.out.print("Enter a year to tell you a Chinese joke: "); + int year = input.nextInt(); + + if (year == 0) + System.out.println("monkey"); + else if (year == 1) + System.out.println("rooster"); + else if (year == 2) + System.out.println("dog"); + else if (year == 3) + System.out.println("pig"); + else if (year == 4) + System.out.println("rat"); + else if (year == 5) + System.out.println("ox"); + else if (year == 6) + System.out.println("tiger"); + else if (year == 7) + System.out.println("rabbit"); + else if (year == 8) + System.out.println("dragon"); + else if (year == 9) + System.out.println("snake"); + else if (year == 10) + System.out.println("horse"); + else if (year == 11) + System.out.println("sheep"); + } +} diff --git a/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch2.java b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch2.java new file mode 100644 index 0000000..6feed08 --- /dev/null +++ b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch2.java @@ -0,0 +1,23 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +/** + * + * @author chloe + */ +public class Switch2 { + public static void main(String[] args) { + // Define vars + int x = 1, a = 3; + switch (a) { + case 1: x += 5; + case 2: x += 10; + case 3: x += 16; + case 4: x+= 34; + } + System.out.println(x + ", " + a); + } +} diff --git a/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch3.java b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch3.java new file mode 100644 index 0000000..f04e7e4 --- /dev/null +++ b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch3.java @@ -0,0 +1,65 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class Switch3 { + + public static void main(String[] args) { + // Define vars + int dayOfWeekInt; + String dayOfWeekString = "nullday", + ordinal = "0th"; + + // Create scanner + Scanner input = new Scanner(System.in); + + // Prompt for input + System.out.print("Enter a number that signifies a day of the week: "); + dayOfWeekInt = input.nextInt(); + + // Switch moment + switch (dayOfWeekInt) { + case 1: + dayOfWeekString = "Sunday"; + ordinal = "1st"; + break; + case 2: + dayOfWeekString = "Monday"; + ordinal = "2nd"; + break; + case 3: + dayOfWeekString = "Tuesday"; + ordinal = "3rd"; + break; + case 4: + dayOfWeekString = "Wednesday"; + ordinal = "4th"; + break; + case 5: + dayOfWeekString = "Thursday"; + ordinal = "5th"; + break; + case 6: + dayOfWeekString = "Friday"; + ordinal = "6th"; + break; + case 7: + dayOfWeekString = "Saturday"; + ordinal = "7th"; + break; + } + // Print output + if (dayOfWeekInt > 7) + System.out.println("That number is too high."); + else + System.out.println(dayOfWeekString + " is the " + ordinal + " day of the week."); + } +} diff --git a/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch3ConvertedToIfElse.java b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch3ConvertedToIfElse.java new file mode 100644 index 0000000..93e9b35 --- /dev/null +++ b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch3ConvertedToIfElse.java @@ -0,0 +1,59 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class Switch3ConvertedToIfElse { + + public static void main(String[] args) { + // Define vars + int dayOfWeekInt; + String dayOfWeekString = "nullday", + ordinal = "0th"; + + // Create scanner + Scanner input = new Scanner(System.in); + + // Prompt for input + System.out.print("Enter a number that signifies a day of the week: "); + dayOfWeekInt = input.nextInt(); + + // No longer Switch moment + if (dayOfWeekInt == 1) { + dayOfWeekString = "Sunday"; + ordinal = "1st"; + } else if (dayOfWeekInt == 2) { + dayOfWeekString = "Monday"; + ordinal = "2nd"; + } else if (dayOfWeekInt == 3) { + dayOfWeekString = "Tuesday"; + ordinal = "3rd"; + } else if (dayOfWeekInt == 4) { + dayOfWeekString = "Wednesday"; + ordinal = "4th"; + } else if (dayOfWeekInt == 5) { + dayOfWeekString = "Thursday"; + ordinal = "5th"; + } else if (dayOfWeekInt == 6) { + dayOfWeekString = "Friday"; + ordinal = "6th"; + } else if (dayOfWeekInt == 7) { + dayOfWeekString = "Saturday"; + ordinal = "7th"; + } + + // Print output + if (dayOfWeekInt > 7) { + System.out.println("That number is too high."); + } else { + System.out.println(dayOfWeekString + " is the " + ordinal + " day of the week."); + } + } +} diff --git a/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch4.java b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch4.java new file mode 100644 index 0000000..b77dad7 --- /dev/null +++ b/Semester 1/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Switch4.java @@ -0,0 +1,54 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class Switch4 { + + public static void main(String[] args) { + // Define vars + String dayOfWeekString = "Nullday", + ordinal = "0th"; + + // Create scanner + Scanner input = new Scanner(System.in); + + // Prompt for input + System.out.print("Enter a day of the week (Case-Sensitive): "); + dayOfWeekString = input.next(); + + // Switch moment + switch (dayOfWeekString) { + case "Sunday": + ordinal = "1st"; + break; + case "Monday": + ordinal = "2nd"; + break; + case "Tuesday": + ordinal = "3rd"; + break; + case "Wednesday": + ordinal = "4th"; + break; + case "Thursday": + ordinal = "5th"; + break; + case "Friday": + ordinal = "6th"; + break; + case "Saturday": + ordinal = "7th"; + break; + } + // Print output + System.out.println(dayOfWeekString + " is the " + ordinal + " day of the week."); + } +} diff --git a/Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/Lab9_CalebFontenot.java b/Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/Lab9_CalebFontenot.java new file mode 100644 index 0000000..dac8cc0 --- /dev/null +++ b/Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/Lab9_CalebFontenot.java @@ -0,0 +1,17 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template + */ + +package com.chloefontenot.lab9_chloefontenot; + +/** + * + * @author chloe + */ +public class Lab9_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/MinimumOf3.java b/Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/MinimumOf3.java new file mode 100644 index 0000000..eda32d1 --- /dev/null +++ b/Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/MinimumOf3.java @@ -0,0 +1,46 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.chloefontenot.lab9_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author ASDV2 + */ +public class MinimumOf3 { + + public static void main(String[] args) + { + Scanner scan = new Scanner(System.in); + + System.out.println("Please enter 4 numbers to find the minimum of the 4: "); + int x = scan.nextInt(); + int y = scan.nextInt(); + int z = scan.nextInt(); + + /* + if ( x < y ) + if ( x < z ) + System.out.println("minimum= " + x); + else + System.out.println("minimum= " + z); + else if ( y < z ) + System.out.println("minimum= " + y); + else + System.out.println("minimum= " + z); + + */ + System.out.println( + (x < y) + ? (x < z) ? "minimum= " + x + : "minimum= " + z + : (y < z) ? "minimum= " + y : "minimum= " + z + ); + + } + +} diff --git a/Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/MinimumOf4ConditionalOperator.java b/Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/MinimumOf4ConditionalOperator.java new file mode 100644 index 0000000..952739d --- /dev/null +++ b/Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/MinimumOf4ConditionalOperator.java @@ -0,0 +1,46 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.chloefontenot.lab9_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author ASDV2 + */ +public class MinimumOf4ConditionalOperator { + + public static void main(String[] args) + { + Scanner scan = new Scanner(System.in); + while (true) { + System.out.println("Please enter 4 numbers to find the minimum of the 4: "); + int _1 = scan.nextInt(); + int _2 = scan.nextInt(); + int _3 = scan.nextInt(); + int _4 = scan.nextInt(); + + System.out.println("minimum= " + + ((_1 < _4) + ? (_1 < _3) + ? (_1 < _2) + ? _1 + : _2 + : (_3 < _2) + ? _3 + : _2 + : (_4 < _3) + ? (_4 < _2) + ? _4 + : _2 + : (_3 < _2) + ? _3 + : _2) + ); + scan.next(); + } + } +} diff --git a/Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/MinimumOf4DeMorgan.java b/Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/MinimumOf4DeMorgan.java new file mode 100644 index 0000000..c6e7f7b --- /dev/null +++ b/Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/MinimumOf4DeMorgan.java @@ -0,0 +1,39 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.chloefontenot.lab9_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author ASDV2 + */ +public class MinimumOf4DeMorgan { + + public static void main(String[] args) + { + Scanner scan = new Scanner(System.in); + while (true) { + System.out.print("Please enter 4 numbers to find the minimum of the 4: "); + System.out.println(""); + int _1 = scan.nextInt(); + int _2 = scan.nextInt(); + int _3 = scan.nextInt(); + int _4 = scan.nextInt(); + + if (!(_1 > _4 || _1 > _3 || _1 > _2)) { // Is 1 the minimum? + System.out.println("minimum= " + _1); + } else if (!(_2 > _4 || _2 > _3 || _2 > _1)) { // Is 2 the minimum? + System.out.println("minimum= " + _2); + } else if (!(_3 > _4 || _3 > _2 || _3 > _1)) { // Is 3 the minimum? + System.out.println("minimum= " + _3); + } else { // All other conditions failed, _4 must be the minimum + System.out.println("minimum= " + _4); + } + scan.next(); + } + } +} diff --git a/Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/MinimumOf4NestedIfs.java b/Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/MinimumOf4NestedIfs.java new file mode 100644 index 0000000..6b33659 --- /dev/null +++ b/Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/MinimumOf4NestedIfs.java @@ -0,0 +1,60 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.chloefontenot.lab9_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author ASDV2 + */ +public class MinimumOf4NestedIfs { + + public static void main(String[] args) { + Scanner scan = new Scanner(System.in); + while (true) { + System.out.println("Please enter 4 numbers to find the minimum of the 4: "); + int _1 = scan.nextInt(); + int _2 = scan.nextInt(); + int _3 = scan.nextInt(); + int _4 = scan.nextInt(); + + if (_1 < _4) { + if (_1 < _3) { + if (_1 < _2) { + System.out.println("minimum= " + _1); + } else { + System.out.println("minimum= " + _2); + } + } else { + if (_3 < _2) { + System.out.println("minimum= " + _3); + } else { + System.out.println("minimum= " + _2); + } + } + } else { + if (_4 < _3) { + if (_4 < _2) { + System.out.println("minimum= " + _4); + } else { + System.out.println("minimum= " + _2); + } + } else { + if (_3 < _2) { + System.out.println("minumum= " + _3); + } else { + System.out.println("minimum= " + _2); + } + } + } + + scan.next(); + } + + } + +} diff --git a/Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/MinimumOf4WithANDs.java b/Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/MinimumOf4WithANDs.java new file mode 100644 index 0000000..5da1e28 --- /dev/null +++ b/Semester 1/Assignments/lab9_ChloeFontenot/src/main/java/com/chloefontenot/lab9_chloefontenot/MinimumOf4WithANDs.java @@ -0,0 +1,39 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package com.chloefontenot.lab9_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author ASDV2 + */ +public class MinimumOf4WithANDs { + + public static void main(String[] args) + { + Scanner scan = new Scanner(System.in); + while (true) { + System.out.print("Please enter 4 numbers to find the minimum of the 4: "); + int _1 = scan.nextInt(); + int _2 = scan.nextInt(); + int _3 = scan.nextInt(); + int _4 = scan.nextInt(); + System.out.println(""); + + if (_1 <= _4 && _1 <= _3 && _1 <= _2) { // Is 1 the minimum? + System.out.println("minimum= " + _1); + } else if (_2 <= _4 && _2 <= _3 && _2 <= _1) { // Is 2 the minimum? + System.out.println("minimum= " + _2); + } else if (_3 <= _4 && _3 <= _2 && _3 <= _1) { // Is 3 the minimum? + System.out.println("minimum= " + _3); + } else { // All other conditions failed, _4 must be the minimum + System.out.println("minimum= " + _4); + } + scan.next(); + } + } +} diff --git a/Semester 1/Exams/Exam1Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/DayOfTheWeek.java b/Semester 1/Exams/Exam1Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/DayOfTheWeek.java new file mode 100755 index 0000000..d38d412 --- /dev/null +++ b/Semester 1/Exams/Exam1Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/DayOfTheWeek.java @@ -0,0 +1,58 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.exam1_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author ar114 + */ +public class DayOfTheWeek { + public static void main(String[] args) { + Scanner input = new Scanner(System.in); + System.out.print("\n\n Enter year (e.g. 2008): "); + int year = input.nextInt(); + System.out.print("Enter month 1-12: "); + int month = input.nextInt(); + if (month == 1) { + month = 13; + year = year - 1; + } + else if (month == 2) { + month = 14; + year = year - 1; + } + System.out.println("Enter the day of the month: 1-31: "); + int dayOfMonth = input.nextInt(); + + int j = year / 100; + int k = year % 100; + + int dayOfWeek = (dayOfMonth + + 26 * (month + 1) / 10 + k + k / 4 + j / 4 + 5 * j) % 7; + if (dayOfWeek == 0) { + System.out.println("Day of the week is Saturday"); + } + else if (dayOfWeek == 1) { + System.out.println("Day of the week is Sunday"); + } + else if (dayOfWeek == 2) { + System.out.println("Day of the week is Monday"); + } + else if (dayOfWeek == 3) { + System.out.println("Day of the week is Tuesday"); + } + else if (dayOfWeek == 4) { + System.out.println("Day of the week is Wednesday"); + } + else if (dayOfWeek == 5) { + System.out.println("Day of the week is Thursday"); + } + else if (dayOfWeek == 6) { + System.out.println("Day of the week is Friday"); + } + } +} diff --git a/Semester 1/Exams/Exam1Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/Exam1_CalebFontenot.java b/Semester 1/Exams/Exam1Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/Exam1_CalebFontenot.java new file mode 100755 index 0000000..bee7827 --- /dev/null +++ b/Semester 1/Exams/Exam1Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/Exam1_CalebFontenot.java @@ -0,0 +1,17 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template + */ + +package com.chloefontenot.exam1_chloefontenot; + +/** + * + * @author ar114 + */ +public class Exam1_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 1/Exams/Exam1Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/RandomMonth.java b/Semester 1/Exams/Exam1Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/RandomMonth.java new file mode 100755 index 0000000..9e083f9 --- /dev/null +++ b/Semester 1/Exams/Exam1Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/RandomMonth.java @@ -0,0 +1,43 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.exam1_chloefontenot; + +/** + * + * @author ar114 + */ +public class RandomMonth { + + public static void main(String[] args) { + int number = (int) (Math.random() * 12 + 1); + System.out.println("Random generated number is: " + number); + switch (number) { + case 1: + System.out.println("Month is January"); break; + case 2: + System.out.println("Month is February"); break; + case 3: + System.out.println("Month is March"); break; + case 4: + System.out.println("Month is April"); break; + case 5: + System.out.println("Month is May"); break; + case 6: + System.out.println("Month is June"); break; + case 7: + System.out.println("Month is July"); break; + case 8: + System.out.println("Month is August"); break; + case 9: + System.out.println("Month is September"); break; + case 10: + System.out.println("Month is October"); break; + case 11: + System.out.println("Month is November"); break; + case 12: + System.out.println("Month is December"); break; + } + } +} diff --git a/Semester 1/Exams/Exam1Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/TrianglePerimeter.java b/Semester 1/Exams/Exam1Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/TrianglePerimeter.java new file mode 100755 index 0000000..ecfb2ca --- /dev/null +++ b/Semester 1/Exams/Exam1Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/TrianglePerimeter.java @@ -0,0 +1,34 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.exam1_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author ar114 + */ +public class TrianglePerimeter { + public static void main(String[] args) { + // Create scanner + Scanner input = new Scanner(System.in); + + // Define variables + int triEdge1, triEdge2, triEdge3; + + // Prompt for input + System.out.print("Enter 3 edges for a triangle: "); + triEdge1 = input.nextInt(); + triEdge2 = input.nextInt(); + triEdge3 = input.nextInt(); + + // Compute and print output + System.out.println(((triEdge1 + triEdge2) > triEdge3) || + ((triEdge1 + triEdge3) > triEdge2) || + ((triEdge2 + triEdge3) > triEdge1) ? + "Input is valid" : "Invalid Input"); + + } +} diff --git a/Semester 1/Exams/Exam2_Practice_ChloeFontenot/app/src/main/java/Exam2_Practice_CalebFontenot/App.java b/Semester 1/Exams/Exam2_Practice_ChloeFontenot/app/src/main/java/Exam2_Practice_ChloeFontenot/App.java similarity index 100% rename from Semester 1/Exams/Exam2_Practice_ChloeFontenot/app/src/main/java/Exam2_Practice_CalebFontenot/App.java rename to Semester 1/Exams/Exam2_Practice_ChloeFontenot/app/src/main/java/Exam2_Practice_ChloeFontenot/App.java diff --git a/Semester 1/Exams/Exam2_Practice_ChloeFontenot/app/src/main/java/Exam2_Practice_CalebFontenot/PrintArrayReversedEven.java b/Semester 1/Exams/Exam2_Practice_ChloeFontenot/app/src/main/java/Exam2_Practice_ChloeFontenot/PrintArrayReversedEven.java similarity index 100% rename from Semester 1/Exams/Exam2_Practice_ChloeFontenot/app/src/main/java/Exam2_Practice_CalebFontenot/PrintArrayReversedEven.java rename to Semester 1/Exams/Exam2_Practice_ChloeFontenot/app/src/main/java/Exam2_Practice_ChloeFontenot/PrintArrayReversedEven.java diff --git a/Semester 1/Exams/Exam2_Practice_ChloeFontenot/app/src/test/java/Exam2_Practice_CalebFontenot/AppTest.java b/Semester 1/Exams/Exam2_Practice_ChloeFontenot/app/src/test/java/Exam2_Practice_ChloeFontenot/AppTest.java similarity index 100% rename from Semester 1/Exams/Exam2_Practice_ChloeFontenot/app/src/test/java/Exam2_Practice_CalebFontenot/AppTest.java rename to Semester 1/Exams/Exam2_Practice_ChloeFontenot/app/src/test/java/Exam2_Practice_ChloeFontenot/AppTest.java diff --git a/Semester 1/Exams/Exam2_mvn_Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam2_mvn_practice_chloefontenot/Consecutive4Equals.java b/Semester 1/Exams/Exam2_mvn_Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam2_mvn_practice_chloefontenot/Consecutive4Equals.java new file mode 100644 index 0000000..2b82009 --- /dev/null +++ b/Semester 1/Exams/Exam2_mvn_Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam2_mvn_practice_chloefontenot/Consecutive4Equals.java @@ -0,0 +1,62 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.exam2_mvn_practice_chloefontenot; + +/** + * + * @author chloe + */ +public class Consecutive4Equals { + + public static void main(String[] args) + { + java.util.Scanner input = new java.util.Scanner(System.in); + while (true) { + System.out.print("Enter the number of values, -1 to quit: "); + int size = input.nextInt(); + if (size == -1) { + System.out.println("goodbye!"); + break; + } + int[] values = new int[size]; + System.out.print("Enter the values: "); + for (int i = 0; i < values.length; i++) { + values[i] = input.nextInt(); + } + if (isConsecutiveFour(values)) { + System.out.println("The list has consecutive fours."); + } else { + System.out.println("The list has no consecutive fours."); + } + } + } + + public static boolean isConsecutiveFour(int[] values) + { + int numOccurance = 0; + int iterable = 0; + int consecutiveFourDetected = 0; + for (int i = 0; i < values.length - 1; i++) { + if (values[i] == values[iterable]) { + numOccurance++; + if (i != 0) { + iterable++; + } + } else { + numOccurance = 0; + } + if (numOccurance >= 4) { + consecutiveFourDetected++; + } + + } + if (consecutiveFourDetected != 0) { + return true; + } + else { + return false; + } + } +} diff --git a/Semester 1/Exams/Exam2_mvn_Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam2_mvn_practice_chloefontenot/Exam2_mvn_Practice_CalebFontenot.java b/Semester 1/Exams/Exam2_mvn_Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam2_mvn_practice_chloefontenot/Exam2_mvn_Practice_CalebFontenot.java new file mode 100644 index 0000000..68ee569 --- /dev/null +++ b/Semester 1/Exams/Exam2_mvn_Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam2_mvn_practice_chloefontenot/Exam2_mvn_Practice_CalebFontenot.java @@ -0,0 +1,17 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template + */ + +package com.chloefontenot.exam2_mvn_practice_chloefontenot; + +/** + * + * @author chloe + */ +public class Exam2_mvn_Practice_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 1/Exams/Exam2_mvn_Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam2_mvn_practice_chloefontenot/PrintArrayReversedEven.java b/Semester 1/Exams/Exam2_mvn_Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam2_mvn_practice_chloefontenot/PrintArrayReversedEven.java new file mode 100644 index 0000000..fe4b1f9 --- /dev/null +++ b/Semester 1/Exams/Exam2_mvn_Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam2_mvn_practice_chloefontenot/PrintArrayReversedEven.java @@ -0,0 +1,49 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.exam2_mvn_practice_chloefontenot; + +/** + * + * @author chloe + */ +public class PrintArrayReversedEven { + public static void main(String[] args) + { + printRE(new int[] {1, 2, 3}); + printRE(new int[2]); + printRE(new int[] {2, 4, 7, 8}); + } + public static void printRE(int[] array) { + int arrayLength = 0; + for (int i = 0; i <= array.length - 1; i++) { + // determine array length. + if (array[i] % 2 == 0) { + arrayLength++; + } + } + // Now create the return array. + int[] returnArray = new int[arrayLength]; + int arrayI = 0; + for (int i = 0; i <= array.length - 1; i++) { + if (array[i] % 2 == 0) { + // Add even numbers to array. + returnArray[arrayI] = array[i]; + arrayI++; + } + } + // Reverse items in the array. + int[] reversedReturnArray = new int[arrayI]; + int reverseArrayIterable = arrayI - 1; + for (int i = 0; i <= returnArray.length - 1; i++) { + reversedReturnArray[reverseArrayIterable] = returnArray[i]; + reverseArrayIterable--; + } + // Now print the array. + for (int i = 0; i <= reversedReturnArray.length - 1; i++) { + System.out.print(reversedReturnArray[i] + " "); + } + System.out.println(); + } +} diff --git a/Semester 1/Exams/Exam2_mvn_Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam2_mvn_practice_chloefontenot/SortCharsInString.java b/Semester 1/Exams/Exam2_mvn_Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam2_mvn_practice_chloefontenot/SortCharsInString.java new file mode 100644 index 0000000..06eb995 --- /dev/null +++ b/Semester 1/Exams/Exam2_mvn_Practice_ChloeFontenot/src/main/java/com/chloefontenot/exam2_mvn_practice_chloefontenot/SortCharsInString.java @@ -0,0 +1,48 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.exam2_mvn_practice_chloefontenot; + +/** + * + * @author chloe + */ +public class SortCharsInString { + + public static String sort(String s) + { + // Read string chars, and sort them + char array[] = s.toCharArray(); + char temp; + int i = 0; + while (i < array.length) { + int j = i + 1; + while (j < array.length) { + // Compare each char, if one is larger, swap them + if (array[j] < array[i]) { + temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } + j += 1; + } + i += 1; + } + + // Rebuild string + String rebuiltString = ""; + for (char charInArray : array) { + rebuiltString += charInArray; + } + return rebuiltString; + } + + public static void main(String[] args) + { + java.util.Scanner input = new java.util.Scanner(System.in); + System.out.print("Enter a string: "); + String s = input.nextLine(); + System.out.println("Sorted string is " + sort(s)); + } +} diff --git a/Semester 2/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/Lab3DArraysSort_CalebFontenot.java b/Semester 2/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/Lab3DArraysSort_CalebFontenot.java new file mode 100644 index 0000000..3b64e05 --- /dev/null +++ b/Semester 2/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/Lab3DArraysSort_CalebFontenot.java @@ -0,0 +1,149 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ +package com.chloefontenot.mp1_chloefontenot; + +/** + * + * @author chloe + */ +public class Lab3DArraysSort_ChloeFontenot { + + public static int maxNumberOfColumnsInJagged2dArray(char[][] ar) { + int maxNumberOfColumns = 0; + for (int row = 0; row < ar.length; ++row) { + if (ar[row].length > maxNumberOfColumns) { + maxNumberOfColumns = ar[row].length; + } + } + + return maxNumberOfColumns; + } + + public static void printColumnMajorOrder(char[][] ar) { + int row = 0; + int column = 0; + int max = maxNumberOfColumnsInJagged2dArray(ar); + for (column = 0; column < max; ++column) { + for (row = 0; row < ar.length; ++row) { + if (column < ar[row].length) { + System.out.print(ar[row][column] + " "); + } + } + System.out.println(""); + } + } + + /** + * Prints row by row + * + * @param ar + */ + public static void printRowMajorOrder(char[][][] array) { + for (char[][] i: array) { + System.out.println("---------------------------------"); + printRowMajorOrder(i); + } + } + public static void printRowMajorOrder(char[][] ar)//normal + { + for (int x = 0; x < ar.length; ++x) { + for (int y = 0; y < ar[x].length; ++y) { + System.out.print(ar[x][y] + ""); + } + System.out.println(); + } + + } + + public static String returnRowMajorOrder(char[] ar)//normal + { + String returnString = ""; + for (int x = 0; x < ar.length; ++x) { + returnString += ar[x]; + } + return returnString; + } + + /** + * Sorts the methods in ascending order using Selection Sort + * + * @param names the names to be sorted + */ + public static void sortNames(char[][][] names) { + for (int array = 0; array < names.length; ++array) { + System.out.println("times looped: " + array); + for (int i = 0; i < names[array].length - 1; ++i) { + for (int j = i + 1; j < names[array].length; ++j) { + char compChar1 = names[array][i][0], compChar2 = names[array][j][0]; + // Reoder entire row + for (int rowIterate = 1; rowIterate < maxNumberOfColumnsInJagged2dArray(names[array]); ++rowIterate) { + if (Character.toLowerCase(compChar1) == Character.toLowerCase(compChar2)) { + try { + compChar1 = names[array][i][rowIterate]; + compChar2 = names[array][j][rowIterate]; + } catch (Exception ex) { + // If it's failed, the index has gone out of range. + // Check the length of the arrays and swap the larger one with the smaller one. + if (names[array][i].length > names[array][j].length) { + System.out.println(names[array][i].length + " " + names[array][j].length); + System.out.println("Swapping " + returnRowMajorOrder(names[array][i]) + " with " + returnRowMajorOrder(names[array][j])); + char[] temp = names[array][i]; + names[array][i] = names[array][j]; + names[array][j] = temp; + } + break; + } + + } + if (Character.toLowerCase(compChar1) > Character.toLowerCase(compChar2)) { + System.out.println("Swapping " + returnRowMajorOrder(names[array][i]) + " with " + returnRowMajorOrder(names[array][j])); + char[] temp = names[array][i]; + names[array][i] = names[array][j]; + names[array][j] = temp; + } + } + } + } + } + } + + public static void main(String[] args) { + /* +char[][] names = { + {'j', 'o', 'h', 'n'}, + {'a', 'n'}, + {'b', 'y', 'r', 'o', 'n'},}; + */ + ///* + char[][][] names = { + { + {'j', 'o', 'h', 'n'}, + {'a', 'n'}, + {'b', 'y', 'r', 'o', 'n'}, + {'b', 'y', 'r', 'o', 'n', 'i'}, + {'a', 'a', 'o', 'n'}, + {'b', 'b', 'b', 'b'}, + {'b', 'b', 'b', 'c'}, + {'b', 'b', 'b'} + }, + { + {'L', 'i', 's', 's', 'e', 't'}, + {'E', 't', 'h', 'a', 'n'}, + {'C', 'a', 'l', 'e', 'b'}, + {'L', 'u', 'l', 'y'}, + {'C', 'h', 'a', 'n', 'c', 'e'} + } + }; +//*/ + //printColumnMajorOrder(names); + printRowMajorOrder(names); + System.out.println(); + sortNames(names); + System.out.println(); + printRowMajorOrder(names); + //printColumnMajorOrder(names); + + } + +} diff --git a/Semester 2/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/MP1_CalebFontenot.java b/Semester 2/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/MP1_CalebFontenot.java new file mode 100644 index 0000000..205ab50 --- /dev/null +++ b/Semester 2/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/MP1_CalebFontenot.java @@ -0,0 +1,267 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ +package com.chloefontenot.mp1_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class MP1_ChloeFontenot { + + public static int[][] inputArray() { + int m, n, i, j; + // Create scanner + Scanner input = new Scanner(System.in); + System.out.print("Enter the number of rows: "); + //taking row as input + m = input.nextInt(); + System.out.print("Enter the number of columns: "); + //taking column as input + n = input.nextInt(); + // Declaring the two-dimensional matrix + int returnArray[][] = new int[m][n]; + // Read the matrix values + System.out.println("Enter the elements of the array: "); + //loop for row + for (i = 0; i < m; i++) //inner for loop for column + { + for (j = 0; j < n; j++) { + returnArray[i][j] = input.nextInt(); + } + } + //accessing array elements + System.out.println("Elements of the array are: "); + for (i = 0; i < m; i++) { + for (j = 0; j < n; j++) { + return returnArray; + } + } + return null; + } + + public static boolean isConsecutiveFour(int[] values) { + for (int i = 0; i < values.length - 4; ++i) { + if (values[i] == values[i + 1] + && values[i + 1] == values[i + 2] + && values[i + 2] == values[i + 3]) { + return true; + } else { + return false; + } + } + return false; + } + + public static void main(String[] args) { //2965 + int[][] horizontalTestArray = { // Horizontal + {0, 1, 0, 3, 1, 6, 1}, + {0, 1, 6, 8, 6, 0, 1}, + {5, 6, 2, 1, 8, 2, 9}, + {6, 5, 6, 1, 1, 9, 1}, + {1, 3, 6, 1, 4, 0, 7}, + {3, 3, 3, 3, 4, 0, 7} + }; + + int[][] verticalTestArray = { // Vertical + {0, 1, 0, 3, 1, 6, 1}, + {0, 1, 6, 8, 6, 0, 1}, + {5, 5, 2, 1, 8, 2, 9}, + {6, 5, 6, 1, 1, 9, 1}, + {1, 5, 6, 1, 4, 0, 7}, + {3, 5, 3, 3, 4, 0, 7} + }; + int[][] diagonalTestArray1 = { // Diagonal 1 + {0, 1, 0, 3, 1, 6, 1}, + {0, 1, 6, 8, 6, 0, 1}, + {9, 6, 2, 1, 8, 2, 9}, + {6, 9, 6, 1, 1, 9, 1}, + {1, 3, 9, 1, 4, 0, 7}, + {3, 3, 3, 9, 4, 0, 7} + }; + int[][] diagonalTestArray2 = { // Diagonal 2 + {0, 1, 0, 3, 1, 6, 1}, + {0, 1, 6, 8, 6, 0, 1}, + {9, 6, 2, 1, 8, 2, 9}, + {6, 9, 6, 1, 1, 9, 1}, + {1, 3, 9, 1, 4, 0, 7}, + {3, 3, 3, 9, 4, 0, 7} + }; + + // Create scanner + Scanner input = new Scanner(System.in); + int userInput; + do { + System.out.println("Do you want to enter an array, or use a predefined one?"); + System.out.println("1. Use predefined array."); + System.out.println("2. Enter a new array."); + System.out.println("-1. quit and exit program"); + System.out.print("Input: "); + userInput = input.nextInt(); + if (userInput == 1) { + System.out.println("Selected \"Use predefined array\""); + System.out.println("Printing arrays..."); + System.out.println("1. horizontalTestArray"); + printArray(horizontalTestArray); + System.out.println("2. verticalTestArray"); + printArray(verticalTestArray); + System.out.println("3. diagonalTestArray1"); + printArray(diagonalTestArray1); + System.out.println("4. diagonalTestArray2"); + printArray(diagonalTestArray2); + System.out.print("Input: "); + userInput = input.nextInt(); + if (userInput == 1) { + if (isConsecutiveFour(horizontalTestArray)) { + System.out.println("Testing method returns true"); + } else { + System.out.println("Testing method returns false"); + } + } + if (userInput == 2) { + if (isConsecutiveFour(verticalTestArray)) { + System.out.println("Testing method returns true"); + } else { + System.out.println("Testing method returns false"); + } + } + if (userInput == 3) { + if (isConsecutiveFour(diagonalTestArray1)) { + System.out.println("Testing method returns true"); + } else { + System.out.println("Testing method returns false"); + } + } + if (userInput == 4) { + if (isConsecutiveFour(diagonalTestArray2)) { + System.out.println("Testing method returns true"); + } else { + System.out.println("Testing method returns false"); + } + } + userInput = 0; + } + if (userInput == 2) { + System.out.println("Selected \"Enter new array\""); + int[][] newArray = inputArray(); + if (isConsecutiveFour(newArray)) { + System.out.println("Testing method returns true"); + } else { + System.out.println("Testing method returns false"); + } + } + } while (userInput != -1); + System.exit(0); + //printArray(intArray1); + //System.out.println(isConsecutiveFour(intArray1)); + } + + public static void printArray(int[][] array) { + int rowCounter = 0; + for (int x = 0; x < array.length; x++) { + for (int y = 0; y < array[x].length; y++) { + System.out.print(array[x][y] + " "); + rowCounter++; + if (rowCounter % (array.length + 1) == 0) { + System.out.println(); + } + } + } + } + + public static void printArray(int[] array) { + for (int i : array) { + System.out.print(i + " "); + } + } + + public static boolean isConsecutiveFour(int[][] values) { + // Horizontal Checking + System.out.println("Checking for Horizontal matches..."); + boolean horizontalTest = horizontalMatch(values); + // Vertical Checking + System.out.println("Checking for Vertical matches..."); + boolean verticalTest = verticalMatch(values); + System.out.println("Checking for Diagonal matches..."); + boolean diagonalTest = diagonalMatch(values); + if (horizontalTest || verticalTest || diagonalTest) { + System.out.println("Match found!"); + return true; + } + System.out.println("No match found."); + return false; + } + + public static boolean diagonalMatch(int[][] array) { + for (int row = 0; row < array.length - 3; row++) { + for (int col = 0; col < array[row].length - 3; col++) { + // Check for four consecutive numbers diagonally from top-left to bottom-right + if (array[row][col] == array[row + 1][col + 1] && array[row + 1][col + 1] == array[row + 2][col + 2] + && array[row + 2][col + 2] == array[row + 3][col + 3]) { + System.out.println("Found four consecutive numbers diagonally at: " + row + "," + col); + return true; + } + // Check for four consecutive numbers diagonally from top-right to bottom-left + if (array[row][col + 3] == array[row + 1][col + 2] && array[row + 1][col + 2] == array[row + 2][col + 1] + && array[row + 2][col + 1] == array[row + 3][col]) { + System.out.println("Found four consecutive numbers diagonally at: " + row + "," + (col + 3)); + return true; + } + } + } + return false; + } + + public static boolean verticalMatch(int[][] values) { + int intCounter = 0, y = 0; + for (int rowIterate = 0; rowIterate < values.length; ++rowIterate) { + y = 0; + for (int x = 0; x < values.length - 1; ++x) { + ++y; + if (values[x][rowIterate] == values[y][rowIterate]) { + intCounter++; + System.out.println(values[x][rowIterate] + " " + values[y][rowIterate] + ", intCounter: " + intCounter); + } else { + intCounter = 0; + System.out.println(values[x][rowIterate] + " " + values[y][rowIterate] + ", intCounter: " + intCounter); + } + if (intCounter == 3) { + System.out.println("Vertical match!"); + return true; + } + } + System.out.println("Checking next line..."); + } + return false; + } + + public static boolean horizontalMatch(int[][] values) { + int intCounter = 0, y = 0; + // Horizontal checking + // If the same value has been observed 4 times, return true + //System.out.println("values[0].length: " + values[0].length); + //System.out.println("values.length: " + values.length); + + for (int rowIterate = 0; rowIterate < values.length; ++rowIterate) { + y = 0; + for (int x = 0; x < values[0].length - 1; ++x) { + ++y; + if (values[rowIterate][x] == values[rowIterate][y]) { + intCounter++; + System.out.println(values[rowIterate][x] + " " + values[rowIterate][y] + ", intCounter: " + intCounter); + } else { + intCounter = 0; + System.out.println(values[rowIterate][x] + " " + values[rowIterate][y] + ", intCounter: " + intCounter); + } + if (intCounter == 3) { + System.out.println("Horizontal match!"); + return true; + } + } + System.out.println("Checking next line..."); + } + return false; + } +} diff --git a/Semester 2/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/MarkouCode.java b/Semester 2/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/MarkouCode.java new file mode 100644 index 0000000..ad6b58d --- /dev/null +++ b/Semester 2/Assignments/MP1_ChloeFontenot/src/main/java/com/chloefontenot/mp1_chloefontenot/MarkouCode.java @@ -0,0 +1,219 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp1_chloefontenot; + +/** + * + * @author chloe + */ +public class MarkouCode { + + /** + * Traverses the parm array diagonally from top left towards the top and prints the (i,j) indexes of the traversal. + * + * @param ar 2D array + */ + public static boolean topLeftTriangleDiagonalNothwest(int[][] ar) { + System.out.println("diagonal indexes top-triangle of array "); + int rowCount = 0; + for (int columnCounter = 0; columnCounter < ar[0].length; ++columnCounter) { + int i = 0; + int j = columnCounter; + int[] diagonalArray = new int[rowCount + 1]; + for (int diagonalCounter = 0; diagonalCounter <= rowCount; ++diagonalCounter) { + diagonalArray[diagonalCounter] = ar[i][j]; + if (isConsecutiveFour(diagonalArray)) { + return true; + } + System.out.print(i + "," + j + " "); + ++i; + j--; + if (i == ar.length | j == ar[0].length) { + break; + } + } + rowCount++; + + System.out.println(""); + + } + return false; + } + + /*Traverses the parm array diagonally from bottom right towrads the to + //and prints the (i,j) indexes of the traversal. + + * + * @param ar + */ + public static boolean bottomRightTriangleDiagonalNothwest(int[][] ar) { + System.out.println("diagonal indexes bottom-triangle of array "); + + int rowCount = 0; + int numColumns = 0; + int[] diagonalArray = new int[rowCount + 1]; + if (ar[0].length == ar.length)//square table + { + numColumns = ar[0].length - 1; + } else if (ar[0].length > ar.length)//wide table + { + numColumns = ar.length - 1; + } else //narrow-width rectangle array + { + numColumns = ar[0].length; + } + + for (int columnCounter = 0; columnCounter < numColumns; ++columnCounter) { + int i = ar.length - 1; + int j = ar[0].length - 1 - columnCounter; + for (int diagonalCounter = 0; diagonalCounter <= rowCount; ++diagonalCounter) { + + System.out.print(i + "," + j + " "); + diagonalArray[diagonalCounter] = ar[i][j]; + if (isConsecutiveFour(diagonalArray)) { + return true; + } + --i; + j++; + } + rowCount++; + System.out.println(""); + return false; + } + //middle chunk of narrow array + + System.out.println("-----------------------"); + if (ar.length > ar[0].length) { + System.out.println("diagonal indexes middle part of array when the array " + + "is narrow "); + + for (int i = 1; i < ar.length - ar[0].length; ++i) { + int rowIndex = i; + int columnIndex = ar[0].length - 1; + for (int j = 0; j < ar[0].length; ++j) { + + System.out.print(rowIndex + "," + columnIndex + " "); + diagonalArray[diagonalCounter] = ar[i][j]; + if (isConsecutiveFour(diagonalArray)) { + return true; + } + rowIndex++; + columnIndex--; + + } + + System.out.println(""); + } + } + + } + + public static boolean isConsecutiveFour(int[][] values) { + return true; + } + + public static boolean isConsecutiveFour(int[] values) { + for (int i = 0; i < values.length - 4; ++i) { + if (values[i] == values[i + 1] + && values[i + 1] == values[i + 2] + && values[i + 2] == values[i + 3]) { + return true; + } else { + return false; + } + } + return false; + } + + private static void printIndexesDiagonally(int ar[][]) { + topLeftTriangleDiagonalNothwest(ar); + System.out.println("------------------------"); + bottomRightTriangleDiagonalNothwest(ar); + } + + public static void main(String[] args) { + int[][] ar1 + = { + { + 1, 1, 1, 1, 8 + }, + { + 1, 1, 1, 8, 9 + }, + { + 1, 1, 8, 1, 9 + }, + { + 1, 8, 1, 3, 2 + },}; + + int[][] ar2 + = { + { + 1, 1, 1, 1, 1, 1, 1, 1 + }, + { + 1, 1, 1, 1, 1, 1, 1, 1 + }, + { + 1, 1, 1, 1, 1, 1, 1, 1 + }, + { + 1, 1, 1, 1, 1, 1, 1, 1 + }, + { + 1, 1, 1, 1, 1, 1, 1, 1 + },}; + + int[][] ar3 + = { + { + 1, 1, 1 + }, + { + 1, 1, 1 + }, + { + 1, 1, 1 + }, + { + 1, 1, 1 + }, + { + 1, 1, 1 + }, + { + 1, 1, 1 + }, + { + 1, 1, 1 + }, + { + 1, 1, 1 + }, + { + 1, 1, 1 + }, + { + 1, 1, 1 + },}; + System.out.println(topLeftTriangleDiagonalNothwest(ar1)); + /* + System.out.println("SQUARE array of size 4x4"); + printIndexesDiagonally(ar1); + + System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); + System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); + System.out.println("\nWIDE array of size 8x5"); + printIndexesDiagonally(ar2); + + System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); + System.out.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); + System.out.println("\nNARROW array of size 10x3"); + printIndexesDiagonally(ar3); + */ + + } +} diff --git a/Semester 2/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/Circle2D.java b/Semester 2/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/Circle2D.java new file mode 100644 index 0000000..dc138f8 --- /dev/null +++ b/Semester 2/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/Circle2D.java @@ -0,0 +1,290 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp2_chloefontenot; + +/** + * + * @author chloe + */ +public class Circle2D { + + private double x; + private double y; + private double radius; + private String name; + + /** + * Get the value of name + * + * @return the value of name + */ + public String getName() { + return name; + } + + public Circle2D() { + this.x = this.y = 0; + this.radius = 1; + this.name = "Default Circle"; + } + + public Circle2D(double x, double y, double radius, String name) { + this.x = x; + this.y = y; + this.radius = radius; + this.name = name; + } + + public Circle2D(double x, double y, double radius) { + this.x = x; + this.y = y; + this.radius = radius; + } + + /** + * Get the value of x + * + * @return the value of x + */ + public double getX() { + return x; + } + + /** + * Get the value of y + * + * @return the value of y + */ + public double getY() { + return y; + } + + /** + * Get the value of radius + * + * @return the value of radius + */ + public double getRadius() { + return radius; + } + + public double getArea() { + return Math.PI * this.radius * this.radius; + } + + public double getPerimeter() { + return 2 * Math.PI * this.radius; + } + + @Override + public String toString() { + return name + "{" + "x=" + x + ", y=" + y + ", radius=" + radius + " }"; + } + + @Override + public int hashCode() { + int hash = 5; + return hash; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Circle2D other = (Circle2D) obj; + if (Double.doubleToLongBits(this.x) != Double.doubleToLongBits(other.x)) { + return false; + } + if (Double.doubleToLongBits(this.y) != Double.doubleToLongBits(other.y)) { + return false; + } + return Double.doubleToLongBits(this.radius) == Double.doubleToLongBits(other.radius); + } + + /** + * Determines if a point is inside the circle. + * + * @param x + * @param y + * @return true if the specified point (x, y) is inside the circle, otherwise false. + */ + public boolean contains(Circle2D other) { + double dx = this.x - other.x; + double dy = this.y - other.y; + double distance = Math.sqrt(dx * dx + dy * dy); + + return distance + other.radius <= this.radius; + } + + /** + * Determines if this circle overlaps with parameter circle. + * + * @param circle to compare for overlapping. + * @return true + */ + public boolean overlaps(Circle2D other) { + double dx = this.x - other.x; + double dy = this.y - other.y; + double distance = Math.sqrt(dx * dx + dy * dy); + + return distance <= this.radius + other.radius; + } + + /** + * + * @param x1 x of point 1 + * @param y1 x of point 1 + * @param x2 x of point 1 + * @param y2 x of point 1 + * @return the distance between the two points + */ + private static double distance(double x1, double y1, double x2, double y2) { + return Math.sqrt((x1 - x2) * (x1) * (x1 - x2) + + (y1 - y2) * (y1 - y2)); + } + + /** + * Sort the array in ascending order by perimeter i=size; + * + * @param array the array to be used for sorting, not altered. + * @return a new sorted array; + */ + public static Circle2D[] sortCirclesByPerimeter(Circle2D[] oldArray) { + Circle2D[] array = new Circle2D[oldArray.length]; + System.arraycopy(oldArray, 0, array, 0, oldArray.length); + for (int i = 0; i < array.length - 1; ++i) { + for (int j = i + 1; j < array.length; ++j) { + double perimeter1 = array[i].getPerimeter(); + double perimeter2 = array[j].getPerimeter(); + if (perimeter1 > perimeter2) { + Circle2D temp = array[i]; + array[i] = array[j]; + array[j] = temp; + } + } + } + return array; + } + + public static void printPerimeter(Circle2D[] array) { + for (Circle2D circle : array) { + System.out.println(circle.name + " " + circle.getPerimeter()); + } + System.out.println(); + } + + /** + * Sort the array in ascending order by perimeter size. Returns a new sorted array. You compare every circle with all other circles. If it overlaps with all others it should be placed first. + * + * @param array The array used for sorting. + * @return + */ + public static int[] circleOverlap(Circle2D[] array) { + int[] overlapCount = new int[array.length]; + // count the number of times each circle overlaps + for (int i = 0; i < array.length; ++i) { + for (int j = 0; j < array.length; ++j) { + if (i != j && array[i].overlaps(array[j])) { + overlapCount[i]++; + } + } + } + return overlapCount; + } + + public static Circle2D[] sortCirclesByNumberOfTimesOverlapping(Circle2D[] array) { + int[] overlapCount = circleOverlap(array); + + // count the number of times each circle overlaps + for (int i = 0; i < array.length; ++i) { + for (int j = 0; j < array.length; ++j) { + if (i != j && array[i].overlaps(array[j])) { + overlapCount[i]++; + } + } + } + for (int i = 0; i < array.length; i++) { + int min = i; + for (int j = i + 1; j < array.length; j++) { + if (overlapCount[j] < overlapCount[min]) { + min = j; + } + if (overlapCount[j] == overlapCount[min]) { + if (array[j].getPerimeter() < array[min].getPerimeter()) { + min = j; + } + } + } + // swap the elements + int tmpCount = overlapCount[i]; + overlapCount[i] = overlapCount[min]; + overlapCount[min] = tmpCount; + + Circle2D temp = array[i]; + array[i] = array[min]; + array[min] = temp; + } + print(circleOverlap(array)); + return array; + } + + public static void print(Circle2D[] array) { + for (Circle2D circle : array) { + System.out.println(circle); + } + } + + public static void print(int[] array) { + for (int circle : array) { + System.out.println(circle); + } + } + + public static void print(Circle2D[] array, Circle2D c1) { + for (Circle2D circle : array) { + System.out.println(circle); + System.out.println("c1.contains: " + c1.contains(circle)); + System.out.println("c1.overlaps: " + c1.overlaps(circle)); + } + } + + public static Circle2D[] createArrayOfCircle() { + Circle2D[] circleArray = new Circle2D[8]; + circleArray[0] = new Circle2D(0, 0, 1, "c1"); + circleArray[1] = new Circle2D(1, 1, 2, "c2"); + circleArray[2] = new Circle2D(3.2, -2.2, 1.2, "c3"); + circleArray[3] = new Circle2D(4.2, 0, 4, "c4"); + circleArray[4] = new Circle2D(-7, 5, 4.5, "c5"); + circleArray[5] = new Circle2D(19, 1, 10, "c6"); + circleArray[6] = new Circle2D(1, 8.8, 3, "c7"); + circleArray[7] = new Circle2D(4.1, 9.1, 1.3, "c8"); + return circleArray; + } + + public static void main(String[] args) { + Circle2D c1 = new Circle2D(2, 2, 5.5); + //System.out.println(c1); + //System.out.println("Area is " + c1.getArea()); + //System.out.println("Perimeter is " + c1.getPerimeter()); + Circle2D[] circleArray = createArrayOfCircle(); + System.out.println(); + printPerimeter(circleArray); + Circle2D[] sortedArray = sortCirclesByPerimeter(circleArray); + printPerimeter(sortedArray); + print(circleArray); + System.out.println(); + Circle2D[] overlapArray = Circle2D.sortCirclesByNumberOfTimesOverlapping(circleArray); + print(overlapArray); + + } + +} diff --git a/Semester 2/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/MP2_CalebFontenot.java b/Semester 2/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/MP2_CalebFontenot.java new file mode 100644 index 0000000..d981608 --- /dev/null +++ b/Semester 2/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/MP2_CalebFontenot.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package com.chloefontenot.mp2_chloefontenot; + +/** + * + * @author chloe + */ +public class MP2_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/Bicycle.java b/Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/Bicycle.java new file mode 100644 index 0000000..8397c68 --- /dev/null +++ b/Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/Bicycle.java @@ -0,0 +1,61 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package com.chloefontenot.mp4_chloefontenot; + +/** + * + * @author chloe + */ +abstract public class Bicycle +{ + private int cadence; + private int gear; + private int speed; + + @Override + public boolean equals(Object obj) + { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + + final Bicycle other = (Bicycle) obj; + if (this.cadence != other.cadence) { + return false; + } + if (this.gear != other.gear) { + return false; + } + return this.speed == other.speed; + } + + public Bicycle(int cadence, int gear, int speed) + { + this.cadence = cadence; + this.gear = gear; + this.speed = speed; + } + + public int getGear(){return gear;} + public void setGear(int gear){this.gear = gear;} + public int getCadence(){return cadence;} + public void setCadence(int cadence){this.cadence = cadence;} + public int getSpeed(){return speed;} + public void setSpeed(int speed){this.speed = speed;} + @Override + public String toString() + { + return "Bicycle{" + "cadence=" + cadence + ", gear=" + gear + ", speed=" + speed + '}'; + } + + abstract Details calculatedDetails(); + +} diff --git a/Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/BikeStores.java b/Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/BikeStores.java new file mode 100644 index 0000000..618913a --- /dev/null +++ b/Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/BikeStores.java @@ -0,0 +1,265 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp4_chloefontenot; + +import java.util.ArrayList; +import java.util.Collection; + +/** + * + * @author chloe + */ +public class BikeStores { + + ArrayList> storesOfBikes = new ArrayList>(); + + /** + * Add a bike at storeNumber ( i.e. the storeNumber indicates the store) + * + * @param storeNumber which store + * @param b the bike to add + * @return true if the bike added, false if the storeNumber is invalid or b is null. + */ + public BikeStores() { + for (int i = 0; i < 3; i++) { + storesOfBikes.add(new ArrayList()); + } + } + + public boolean addBike(int storeNumber, Bicycle b) { + if (storeNumber < 0 || storeNumber > this.storesOfBikes.size() - 1) { + return false; + } + if (b == null) { + return false; + } + System.out.println("Attempting to add " + b + " to store at index " + storeNumber); + //Unpack array + ArrayList bikesInInventory = storesOfBikes.get(storeNumber); + bikesInInventory.add(b); + + // Repack array + storesOfBikes.set(storeNumber, bikesInInventory); + System.out.println("success!"); + return true; + } + + /** + * Removes a bike at a specific store. + * + * @param storeNumber the store that has the bike + * @param b the bike to be removed + * @return true of the bike is removed, false if the bike does not exist, or bike is null. + */ + public boolean removeBike(int storeNumber, Bicycle b) { + if (storeNumber < 0 || storeNumber > this.storesOfBikes.size() - 1) { + return false; + } + if (b == null) { + return false; + } + System.out.println("Attempting to remove " + b + " to store at index " + storeNumber); + // Remove bike from array. + ArrayList bikesInInventory = storesOfBikes.get(storeNumber); + bikesInInventory.remove(b); //YEET + System.out.println("success!"); + return true; + } + + /** + * Prints the indexes before each bike , one store per line + * + * @param stores stores of bikes + */ + public static void print(ArrayList> stores) { + for (int i = 0; i < stores.size(); ++i) { + System.out.println("---------- " + "printing row " + (i + 1) + " ----------"); + for (int j = 0; j < stores.get(i).size(); ++j) { + System.out.println(stores.get(i).get(j) + " "); + + } + } + } + + public static void printSingle(ArrayList stores) { + System.out.println("----------" + "printSingle" + "----------"); + for (int j = 0; j < stores.size(); ++j) { + System.out.println(stores.get(j) + " "); + } + + } + + public static void printRank(ArrayList stores) { + System.out.println("----------" + "printRank" + "----------"); + for (int j = 0; j < stores.size(); ++j) { + System.out.println(stores.get(j) + " " + stores.get(j).calculatedDetails().getRank()); + } + + } + + /** + * Groups bikes by type ans sorts them by the ranking of Details. There will be three groups and each group stored in descending order by rank. + * + * @param stores the stores of bikes + * @return a newly created ArrayList> with the bikes sorted. + */ + public static ArrayList> sortBikesByType(final ArrayList> stores) { + ArrayList> newStore = new ArrayList>(); + // group arrayLists + ArrayList mountainBikes = new ArrayList(); + ArrayList speedBikes = new ArrayList(); + ArrayList childBikes = new ArrayList(); + System.out.println("---------- " + "grouping by bike type... " + " ----------"); + for (int i = 0; i < stores.size(); ++i) { + for (int j = 0; j < stores.get(i).size(); ++j) { + // System.out.println(stores.get(i).get(j).calculatedDetails().getRank() + " "); + Bicycle bike = stores.get(i).get(j); + if (bike instanceof ChildBike) { + childBikes.add(bike); + } else if (bike instanceof MountainBike) { + mountainBikes.add(bike); + } else if (bike instanceof SpeedBike) { + speedBikes.add(bike); + } + } + } + //printRank(childBikes); + //printRank(mountainBikes); + //printRank(speedBikes); + System.out.println("sorting..."); + sortType(childBikes); + sortType(mountainBikes); + sortType(speedBikes); + System.out.println("sorted"); + //printRank(childBikes); + //printRank(mountainBikes); + //printRank(speedBikes); + newStore.add(childBikes); + newStore.add(mountainBikes); + newStore.add(speedBikes); + return newStore; + } + + private static void sortType(ArrayList arrList) { + for (int x = 0; x < arrList.size(); ++x) { + for (int i = 0; i < arrList.size(); ++i) { + for (int j = i + 1; j < arrList.size(); ++j) { + int compare1 = arrList.get(i).calculatedDetails().getRank(); + int compare2 = arrList.get(j).calculatedDetails().getRank(); + if (compare1 < compare2) { + Bicycle tmp = arrList.get(i); + arrList.set(i, arrList.get(j)); + arrList.set(j, tmp); + } + } + } + } + } + + public static void print(Object[] arr) { + for (Object o : arr) { + System.out.println(o); + } + } + + public static void print(Object[][] arr) { + for (int i = 0; i < arr.length; i++) { + System.out.println("---------- " + "printing row " + (i + 1) + " ----------"); + print(arr[i]); + + } + } + + /** + * Returns a 2D array containing all the bikes in the store in proper sequence (from first to last element). Store 0 with all its bikes, store 1 with all its bikes, and so on. + * + * @return a 2D array of all stores with bikes. + */ + public Object[][] toArray() { + Object[][] arr = new Object[storesOfBikes.size()][]; + for (int i = 0; i < storesOfBikes.size(); i++) { + arr[i] = storesOfBikes.toArray(); + } + return arr; + } + + /** + * Retains only the Bicycles in the stores that are contained in the specified collection. In other words, removes from this list all of bikes that are not contained in the specified location. + * + * @param c the bikes to be removed + * @return true if any store changed as a result of the call. + */ + public boolean retainAll(Collection c) { + boolean modified = false; + for (int i = storesOfBikes.size() - 1; i >= 0; i--) { + ArrayList bikes = storesOfBikes.get(i); + for (int j = bikes.size() - 1; j >= 0; j--) { + Bicycle bike = bikes.get(j); + if (!c.contains(bike)) { + bikes.remove(j); + System.out.println("Removing " + bike); + modified = true; + } + } + } + System.out.println("Bikes to remove:"); + printSingle((ArrayList) c); + return modified; + } + + public static void main(String[] args) { + BikeStores bikes = new BikeStores(); + //add 5 bikes to store 0 ( 2 speedBikes, 2 mountain 1 child) + bikes.addBike(0, new SpeedBike(4, 3, 10, 40)); + bikes.addBike(0, new SpeedBike(1, 2, 10, 30)); + bikes.addBike(0, new MountainBike(1, 2, 3, 20)); + bikes.addBike(0, new MountainBike(3, 2, 10, 25)); + bikes.addBike(0, new ChildBike(false, 1, 1, 10)); + //add 5 bikes to store 1 ( 3 speedbikes, 1 mountain 1 child) + bikes.addBike(1, new SpeedBike(10, 4, 10, 20)); + bikes.addBike(1, new SpeedBike(0, 2, 10, 50)); + bikes.addBike(1, new SpeedBike(3, 2, 10, 38)); + bikes.addBike(1, new MountainBike(1, 3, 5, 44)); + bikes.addBike(1, new ChildBike(true, 1, 1, 15)); + //add 6 bikes to store 2 ( 2 speedBikes, 2 mountain 2 child ) + bikes.addBike(2, new SpeedBike(7, 10, 20, 25)); + bikes.addBike(2, new SpeedBike(0, 8, 40, 55)); // retainAll should match this one + bikes.addBike(2, new MountainBike(2, 3, 15, 33)); + bikes.addBike(2, new MountainBike(1, 3, 15, 24)); + bikes.addBike(2, new ChildBike(true, 1, 2, 20)); + bikes.addBike(2, new ChildBike(false, 1, 1, 18));// retainAll should match this one + //remove one child bike from store 2 + bikes.removeBike(2, new ChildBike(true, 1, 2, 20)); // Java reuses the object created earlier since it has the same values. + //PRINT + print(bikes.storesOfBikes); + //SORT + ArrayList> sortedBikes = sortBikesByType(bikes.storesOfBikes); + //PRINT what the method return + System.out.println("SORTED BIKES"); + print(sortedBikes); + //PRINT the original store + System.out.println("ORIGINAL STORE ARRAYLIST"); + print(bikes.storesOfBikes); + // ---------- TEST retainAll ---------- + System.out.println("Testing retainAll();..."); + Collection c1 = new ArrayList(); + c1.add(new SpeedBike(0, 8, 40, 55)); + c1.add(new ChildBike(false, 1, 1, 18)); + Bicycle b1 = bikes.storesOfBikes.get(2).get(1); + Bicycle b2 = bikes.storesOfBikes.get(2).get(4); + Bicycle b3 = ((ArrayList) c1).get(0); + Bicycle b4 = ((ArrayList) c1).get(1); + + System.out.println(b1.equals(b3) + " " + b2.equals(b4)); + bikes.retainAll(c1); + print(bikes.storesOfBikes); + + } + +} + +class NotABike { + +} diff --git a/Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/ChildBike.java b/Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/ChildBike.java new file mode 100644 index 0000000..c5e29cc --- /dev/null +++ b/Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/ChildBike.java @@ -0,0 +1,60 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp4_chloefontenot; + +/** + * + * @author chloe + */ +public class ChildBike extends Bicycle //remove comment in front of extends +{ + @Override + public boolean equals(Object obj) + { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final ChildBike other = (ChildBike) obj; + System.out.println("Super returns: " + super.equals(obj)); + return this.helpWheels == other.helpWheels && super.equals(obj); + } + + private boolean helpWheels; + + public ChildBike(boolean helpWheels, int cadence, int gear, int speed) + { + super(cadence, gear, speed); + this.helpWheels = helpWheels; + } + + public boolean isHelpWheels() + { + return helpWheels; + } + + public void setHelpWheels(boolean helpWheels) + { + this.helpWheels = helpWheels; + } + + @Override + Details calculatedDetails() + { + return Details.getDetails(this); + } + + @Override + public String toString() + { + return super.toString() + "ChildBike{" + "helpWheels=" + helpWheels + '}'; + } + +} diff --git a/Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/Details.java b/Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/Details.java new file mode 100644 index 0000000..9d41dd0 --- /dev/null +++ b/Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/Details.java @@ -0,0 +1,57 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp4_chloefontenot; + +/** + * + * @author chloe + */ +public class Details { + + private int rank; + private String info; + + public int getRank() + { + return rank; + } + + public String getInfo() + { + return info; + } + + public static Details getDetails(Bicycle b) + { + Details d = new Details(); + if (b instanceof SpeedBike) { + if (((SpeedBike) b).getWeight() < 1) { + d.rank = 10; + } else if (((SpeedBike) b).getWeight() > 1 && ((SpeedBike) b).getWeight() < 8) { + d.rank = 9; + } else { + d.rank = 0; + } + } else if (b instanceof MountainBike) { + if (((MountainBike) b).getSeatHeight() > 2) { + d.rank = 10; + } else { + d.rank = 0; + } + } else if (b instanceof ChildBike) { + if (((ChildBike) b).isHelpWheels()) { + d.rank = 10; + } else { + d.rank = 0; + } + } else { + return null; + } + + d.info = b.toString(); + return d; + } + +} diff --git a/Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/MountainBike.java b/Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/MountainBike.java new file mode 100644 index 0000000..0d2ea86 --- /dev/null +++ b/Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/MountainBike.java @@ -0,0 +1,62 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp4_chloefontenot; + +/** + * + * @author chloe + */ +public class MountainBike extends Bicycle +{ + + private int seatHeight; + + @Override + public boolean equals(Object obj) + { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final MountainBike other = (MountainBike) obj; + System.out.println("Super returns: " + super.equals(obj)); + return this.seatHeight == other.seatHeight && super.equals(obj); + } + + public MountainBike(int seatHeight, int cadence, int gear, int speed) + { + super(cadence, gear, speed); + this.seatHeight = seatHeight; + } + + public int getSeatHeight() + { + return seatHeight; + } + + public void setSeatHeight(int seatHeight) + { + this.seatHeight = seatHeight; + } + + @Override + public String toString() + { + return super.toString() + " MountainBike{" + "seatHeight=" + seatHeight + '}'; + } + + @Override + Details calculatedDetails() + { + return Details.getDetails(this); + } + +} + diff --git a/Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/SpeedBike.java b/Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/SpeedBike.java new file mode 100644 index 0000000..0ae8a21 --- /dev/null +++ b/Semester 2/Assignments/MP4_ChloeFontenot/src/main/java/com/chloefontenot/mp4_chloefontenot/SpeedBike.java @@ -0,0 +1,69 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp4_chloefontenot; + +/** + * + * @author chloe + */ +public class SpeedBike extends Bicycle +{ + + @Override + public int hashCode() + { + int hash = 5; + return hash; + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final SpeedBike other = (SpeedBike) obj; + System.out.println("Super returns: " + super.equals(obj)); + return Double.doubleToLongBits(this.weight) == Double.doubleToLongBits(other.weight) && super.equals(obj); + } + + private double weight; + + public SpeedBike(double weight, int cadence, int gear, int speed) + { + super(cadence, gear, speed); + this.weight = weight; + } + + public double getWeight() + { + return weight; + } + + public void setWeight(double weight) + { + this.weight = weight; + } + + @Override + public String toString() + { + return super.toString() + " SpeedBike{" + "weight=" + weight + '}'; + } + + @Override + Details calculatedDetails() + { + return Details.getDetails(this); + } + + +} diff --git a/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/Circle.java b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/Circle.java new file mode 100644 index 0000000..f0c14cb --- /dev/null +++ b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/Circle.java @@ -0,0 +1,55 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5_chloefontenot; + +/** + * + * @author chloe + */ +public class Circle extends GeometricObject { + private double diameter; + + public Circle(double diameter) { + this.diameter = diameter; + System.out.println("Circle Diameter: " + diameter); + } + + public double getRadius() { + return diameter / 2; + } + + @Override + public double getArea() { + double radius = diameter / 2; + return Math.PI * Math.pow(radius, 2); + } + + @Override + public double getPerimeter() { + return Math.PI * diameter; + } + + @Override + public String toString() { + return "Circle{" + "diameter=" + diameter + '}'; + } + + @Override + public int compareTo(GeometricObject t) { + System.out.println(this.getArea() + ", " + (t).getArea()); + if (this.getArea() < (t).getArea()) { + return -1; + } else if (this.getArea() > (t).getArea()) { + return 1; + } else { + return 0; + } + } + + @Override + public int compareTo(Object t) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } +} diff --git a/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/Combinations.java b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/Combinations.java new file mode 100644 index 0000000..ccc1a94 --- /dev/null +++ b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/Combinations.java @@ -0,0 +1,145 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5_chloefontenot; + +/** + * + * @author chloe + */ + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Set; + +class Combinations +{ + + private static void findCombinations(String[] A, int i, int k, + Set> subarrays, + List out) + { + if (A.length == 0 || k > A.length) + { + return; + } + + // base case: combination size is `k` + if (k == 0) + { + subarrays.add(new ArrayList<>(out)); + return; + } + + // start from the next index till the last index + for (int j = i; j < A.length; j++) + { + // add current element `A[j]` to the solution and recur for next index + // `j+1` with one less element `k-1` + out.add(A[j]); + findCombinations(A, j + 1, k - 1, subarrays, out); + out.remove(out.size() - 1); // backtrack + } + } + + private static Set> findCombinations(String[] A, int k) + { + Set> subarrays = new HashSet<>(); + findCombinations(A, 0, k, subarrays, new ArrayList<>()); + return subarrays; + } + + private static Set> findAllCombinations(String[] A) + { + Set> subarrays = new HashSet<>(); + for (int k = 1; k <= A.length; ++k) + { + findCombinations(A, 0, k, subarrays, new ArrayList<>()); + } + return subarrays; + } +/** Finds all distinct combinations of all sizes for elements of array. + * + * @param A the elements to find their combinations + * @return all distinct combinations of the elements, sorted by length. ascending order. + */ + public static ArrayList allCombinations(String[] A) + { + Set> set = findAllCombinations(A); + ArrayList all = new ArrayList(); + Iterator it = set.iterator(); + while (it.hasNext()) + { + List list = (List) it.next(); + String s1 = ""; + for (String s2 : list) + { + s1 += s2; + } + all.add(s1); + } + Collections.sort(all, new Comparator(){ + @Override + public int compare(String o1, String o2) + { + return o1.length() - o2.length(); + } + }); + return all; + } +/** Finds all distinct combinations of all sizes for chars of the String. + * + * @param A the characters to find their combinations. + * @return all distinct combinations of the characters sorted by length, ascending order. + */ + public static ArrayList allCombinations(String a) + { + String[] A = new String[a.length()]; + for (int i = 0; i < A.length; ++i) + { + A[i] = Character.toString(a.charAt(i)); + } + Set> set = findAllCombinations(A); + ArrayList all = new ArrayList(); + Iterator it = set.iterator(); + while (it.hasNext()) + { + List list = (List) it.next(); + String s1 = ""; + for (String s2 : list) + { + s1 += s2; + } + all.add(s1); + } + + Collections.sort(all, new Comparator(){ + @Override + public int compare(String o1, String o2) + { + return o1.length() - o2.length(); + } + }); + return all; + } + + public static void main(String[] args) + { + String[] A = + { + "1", "2", "3", "4" + }; + int k = 2; + + // process elements from left to right + System.out.println(allCombinations(A)); + System.out.println(allCombinations("1234")); + + } +} + diff --git a/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/FD.java b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/FD.java new file mode 100644 index 0000000..359c9b5 --- /dev/null +++ b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/FD.java @@ -0,0 +1,97 @@ +package com.chloefontenot.mp5_chloefontenot; + + +/** + * + * @author ASDV2 + */ +public class FD +{ + + private String lhs; + + private String rhs; + + /** + * + * @param lhs the LHS of the FD + * @param rhs the RHS of the FD + * @throws IllegalArgumentException if the length of the LHS or the length + * of the RHS are less than 1 or if they are null. + */ + public FD(String lhs, String rhs) + throws IllegalArgumentException + { + if (lhs == null || rhs == null ) + throw new IllegalArgumentException( "the LHS and/or RHS cannot be null."); + + if (lhs.length() < 1 || rhs.length() < 1 ) + throw new IllegalArgumentException( "the LHS and/or RHS cannot be of lenght less than 1."); + + this.lhs = lhs; + this.rhs = rhs; + } + + /** + * Get the value of rhs + * + * @return the value of rhs + */ + public String getRhs() + { + return rhs; + } + + /** + * Set the value of rhs + * + * @param rhs new value of rhs + */ + public void setRhs(String rhs) + { + this.rhs = rhs; + } + + /** + * Get the value of lhs + * + * @return the value of lhs + */ + public String getLhs() + { + return lhs; + } + + /** + * Set the value of lhs + * + * @param lhs new value of lhs + */ + public void setLhs(String lhs) + { + this.lhs = lhs; + } + + @Override + public String toString() + { + return lhs + " -> " + rhs; + } + + /** + * Decomposes the RHS of the FD into singletons. where the LHS is the same + * as this FD and the RHS is 1 character of each character of the FD. + * + * @return array of FD he + */ + public FD[] decomposeRightHandSide() + { + FD[] fdDecomosition = new FD[this.rhs.length()]; + + for (int i = 0; i < this.rhs.length(); ++i) + { + fdDecomosition[i] = new FD(this.lhs, Character.toString(rhs.charAt(i))); + } + return fdDecomosition; + } +} \ No newline at end of file diff --git a/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/GeometricObject.java b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/GeometricObject.java new file mode 100644 index 0000000..c2919b4 --- /dev/null +++ b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/GeometricObject.java @@ -0,0 +1,95 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5_chloefontenot; + +/** + * + * @author chloe + */ +public abstract class GeometricObject implements Comparable { + + private String color = "white"; + private boolean filled; + private java.util.Date dateCreated; + + /** + * Construct a default geometric object + */ + protected GeometricObject() { + dateCreated = new java.util.Date(); + } + + /** + * Construct a geometric object with color and filled value + */ + protected GeometricObject(String color, boolean filled) { + dateCreated = new java.util.Date(); + this.color = color; + this.filled = filled; + } + + /** + * Return color + */ + public String getColor() { + return color; + } + + /** + * Set a new color + */ + public void setColor(String color) { + this.color = color; + } + + /** + * Return filled. Since filled is boolean, the get method is named isFilled + */ + public boolean isFilled() { + return filled; + } + + /** + * Set a new filled + */ + public void setFilled(boolean filled) { + this.filled = filled; + } + + /** + * Get dateCreated + */ + public java.util.Date getDateCreated() { + return dateCreated; + } + + @Override + public String toString() { + return "created on " + dateCreated + "\ncolor: " + color + + " and filled: " + filled; + } + + /** + * Abstract method getArea + */ + public abstract double getArea(); + + /** + * Abstract method getPerimeter + */ + public abstract double getPerimeter(); + + // Additional code below + public abstract int compareTo(GeometricObject t); + + public static GeometricObject max(GeometricObject o1, GeometricObject o2) { + if (o1.getArea() >= o2.getArea()) { + return o1; + } else { + return o2; + } + } +} + diff --git a/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/Large.java b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/Large.java new file mode 100644 index 0000000..a409d7f --- /dev/null +++ b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/Large.java @@ -0,0 +1,45 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5_chloefontenot; + +import java.io.File; +import java.io.FileNotFoundException; +import java.util.ArrayList; +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class Large { + public static void main(String[] args) { + // Read data file + // ArrayLists + ArrayList firstNameArr = new ArrayList(); + ArrayList lastNameArr = new ArrayList(); + ArrayList jobTitleArr = new ArrayList(); + ArrayList salaryArr = new ArrayList(); + + File file = new File("Salary.txt"); + try (Scanner fileScanner = new Scanner(file)) { + while (fileScanner.hasNext()) { + firstNameArr.add(fileScanner.next()); + lastNameArr.add(fileScanner.next()); + jobTitleArr.add(fileScanner.next()); + salaryArr.add(fileScanner.next()); + fileScanner.nextLine(); // consume newline + } + } catch (Exception ex) { + System.out.println("Unable to read file"); + } + for (int i = 0; i < firstNameArr.size(); ++i) { + System.out.println("first name :" + firstNameArr.get(i)); + System.out.println("last name: " + lastNameArr.get(i)); + System.out.println("job title: " + jobTitleArr.get(i)); + System.out.println("salary: " + salaryArr.get(i)); + System.out.println("--------------------------------------"); + } + } +} diff --git a/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/MP5_CalebFontenot.java b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/MP5_CalebFontenot.java new file mode 100644 index 0000000..8d0e539 --- /dev/null +++ b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/MP5_CalebFontenot.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package com.chloefontenot.mp5_chloefontenot; + +/** + * + * @author chloe + */ +public class MP5_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/MyStack.java b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/MyStack.java new file mode 100644 index 0000000..b16b038 --- /dev/null +++ b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/MyStack.java @@ -0,0 +1,62 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5_chloefontenot; + +/** + * + * @author chloe + */ +import java.util.ArrayList; + +public class MyStack implements Cloneable { + private ArrayList list = new ArrayList<>(); + + public boolean isEmpty() { + return list.isEmpty(); + } + + public int getSize() { + return list.size(); + } + + public Object peek() { + return list.get(getSize() - 1); + } + + public Object pop() { + Object o = list.get(getSize() - 1); + list.remove(getSize() - 1); + return o; + } + + public void push(Object o) { + list.add(o); + } + + @Override /** Override the toString in the Object class */ + public String toString() { + return "stack: " + list.toString(); + } + + @Override + public Object clone() throws CloneNotSupportedException { + MyStack clonedStack = (MyStack) super.clone(); + ArrayList newList = new ArrayList<>(list); + clonedStack.list = newList; + return clonedStack; + } + + public static void main(String[] args) throws CloneNotSupportedException { + MyStack stack = new MyStack(); + final int STACK_SIZE = 50; + for (int i = 0; i < STACK_SIZE; ++i) { + stack.push(i + 1); // Fill Stack with sequential numbers. + //System.out.println(stack.peek()); + } + System.out.println(stack.peek()); + MyStack clonedStack = (MyStack) stack.clone(); + System.out.println(clonedStack.peek()); + } +} diff --git a/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/NormalizeDatabase.java b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/NormalizeDatabase.java new file mode 100644 index 0000000..c25db22 --- /dev/null +++ b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/NormalizeDatabase.java @@ -0,0 +1,173 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5_chloefontenot; + +/** + * + * @author chloe + */ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +import java.util.ArrayList; + +/** + * + * @author ASDV2 + */ +public class NormalizeDatabase +{ +/**Finds the closure of a set of attributes given a set of FDs of a relation R + * + * @param attributes attributes to find their closure + * @param fds set of FDs of relation R + * @return the closure of the parameter attributes. + */ + public static String closure(String attributes, ArrayList fds ) + { + attributes = attributes.toUpperCase(); + for (int j = 0; j < fds.size(); ++j) + { + FD capitalsFD = new FD(fds.get(j).getLhs().toUpperCase(), + fds.get(j).getRhs().toUpperCase()); + fds.set(j, capitalsFD); + } + // 1. Set x+ = x + String closure = attributes; + String closurePreveious = attributes; +// 2. Starting with x+ apply each FD xF —> y in F where +// xF belongs in closure x+ but but the rhs y is not already in x+, to find determined +// attributes y +// 3. x+ = x+ U y + + while (true) + { + + for (int i = 0; i < fds.size(); ++i) + { + if (closure.contains(fds.get(i).getRhs())) + continue; + // if the left hand side of the FD is contained in the closure + // then add to the closure the RHS of the FD + if (closure.contains(fds.get(i).getLhs())) + closure += fds.get(i).getRhs(); + } + if (closurePreveious.equals(closure)) + break; + else + closurePreveious = closure; + } + +// 4, If y not empty goto (2) +// 5. Return x+ + return closure; + + } + /** + * Eliminates redundant attributes from the LHS of each FD of a set of FDs + * given as parameters. + * + * @param fds the set of FDs to eliminate the redundancy + * @return and ArrayList with no redundancy on LHS of each FD. + */ + public static ArrayList eliminateRedundantAttributes(ArrayList fds) + { + for (int j = 0; j < fds.size(); ++j) + { + int s = fds.get(j).getLhs().length(); + if (s < 2) + { + continue; + } + else + { + String fl = fds.get(j).getLhs().substring(0, 1); + ArrayList fFD = new ArrayList(); + String s1 = " "; + if (fds.get(j).getLhs().length() == 2) + { + s1 = fds.get(j).getLhs().substring(1); + if (closure(s1,fds).contains(fl)) + { + + fds.add(new FD (fds.get(j).getLhs().substring(1, 2), fds.get(j).getRhs())); + fds.remove(j); + + } + } + else if (fds.get(j).getLhs().charAt(1) == 3) + { + s1 = fds.get(j).getLhs().substring(1); + if (closure(s1,fds).contains(fl)) + { + fds.add(new FD (fds.get(j).getLhs().substring(1, 2), fds.get(j).getRhs())); + fds.add(new FD (fds.get(j).getLhs().substring(2, 3), fds.get(j).getRhs())); + fds.remove(j); + } + } + else if (fds.get(j).getLhs().charAt(1) == 4) + { + s1 = fds.get(j).getLhs().substring(1); + if (closure(s1,fds).contains(fl)) + { + fds.add(new FD (fds.get(j).getLhs().substring(1, 2), fds.get(j).getRhs())); + fds.add(new FD (fds.get(j).getLhs().substring(2, 3), fds.get(j).getRhs())); + fds.add(new FD (fds.get(j).getLhs().substring(3, 4), fds.get(j).getRhs())); + fds.remove(j); + } + } + + else + { + return fds; + } + } + + } + + return fds; + } + public static void main(String[] args) + { + ArrayList fds = new ArrayList(); + FD fd = new FD("a", "BC"); + FD[] fdDecomposed = fd.decomposeRightHandSide(); + for (int i = 0; i < fdDecomposed.length; ++i) + { + fds.add( new FD(fdDecomposed[i].getLhs(), fdDecomposed[i].getRhs())); + } + + fds.add(new FD("B", "C")); + fds.add(new FD("AB", "B")); + fds.add(new FD("C", "A")); + System.out.println(fds); + System.out.println(closure("b", fds)); + System.out.println(eliminateRedundantAttributes(fds)); + /* TEST it with + Let F1 = {1. A -> BC + 2. B -> C, + 3. AB -> D }. + Attribute B is extraneous in FD 3 AB -> D + + */ + + + /* + F2 = { 1. AB -> C, + 2. C -> A, + 3. BC -> D, + 4. ACD -> B, + 5. D -> E, + 6. D -> G, + 7. BE -> C, + 8. CG -> B, + 9. CG -> D, + 10. CE -> A, + 11. CE -> G} + */ + } +} diff --git a/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/PrintCalendar.java b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/PrintCalendar.java new file mode 100644 index 0000000..d587baf --- /dev/null +++ b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/PrintCalendar.java @@ -0,0 +1,160 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5_chloefontenot; + +/** + * + * @author chloe + */ +import java.util.Calendar; +import java.util.Scanner; +import java.util.Date; +import java.util.GregorianCalendar; + +public class PrintCalendar { + /** Main method */ + public static void main(String[] args) { + Scanner input = new Scanner(System.in); + int year, month; + String userInput; + + do { + System.out.println("What would you like to do?"); + System.out.println("1. Print today's date."); + System.out.println("2. Print a specified date."); + System.out.println("Q/q. Quit."); + System.out.print("Respond with 1, 2 or Q/q: "); + userInput = input.next(); + if (userInput.toLowerCase().charAt(0) == 'q') { + System.exit(0); + } + if (Integer.parseInt(userInput) < 0 || Integer.parseInt(userInput) > 2) { + System.out.println("Invalid input!"); + } else { + if (Integer.parseInt(userInput) == 1) { + Date date = new Date(); + printMonth((date.getYear() + 1900), date.getMonth()); + } else if (Integer.parseInt(userInput) == 2) { + System.out.print("Enter a month (1-12): "); + month = (input.nextInt() + 1); + System.out.print("Enter a year: "); + year = (input.nextInt()); + GregorianCalendar date = new GregorianCalendar(year, month, 0, 0, 0); + printMonth(date.get(Calendar.YEAR), date.get(Calendar.MONTH)); + } + } + } while (true); + + } + + /** Print the calendar for a month in a year */ + public static void printMonth(int year, int month) { + // Print the headings of the calendar + printMonthTitle(year, month); + + // Print the body of the calendar + printMonthBody(year, month); + } + + /** Print the month title, e.g., May, 1999 */ + public static void printMonthTitle(int year, int month) { + System.out.println(" " + getMonthName(month) + + " " + year); + System.out.println("-----------------------------"); + System.out.println(" Sun Mon Tue Wed Thu Fri Sat"); + } + + /** Get the English name for the month */ + public static String getMonthName(int month) { + String monthName = ""; + switch (month) { + case 1: monthName = "January"; break; + case 2: monthName = "February"; break; + case 3: monthName = "March"; break; + case 4: monthName = "April"; break; + case 5: monthName = "May"; break; + case 6: monthName = "June"; break; + case 7: monthName = "July"; break; + case 8: monthName = "August"; break; + case 9: monthName = "September"; break; + case 10: monthName = "October"; break; + case 11: monthName = "November"; break; + case 12: monthName = "December"; + } + + return monthName; + } + + /** Print month body */ + public static void printMonthBody(int year, int month) { + // Get start day of the week for the first date in the month + int startDay = getStartDay(year, month); + + // Get number of days in the month + int numberOfDaysInMonth = getNumberOfDaysInMonth(year, month); + + // Pad space before the first day of the month + int i = 0; + for (i = 0; i < startDay; i++) + System.out.print(" "); + + for (i = 1; i <= numberOfDaysInMonth; i++) { + System.out.printf("%4d", i); + + if ((i + startDay) % 7 == 0) + System.out.println(); + } + + System.out.println(); + } + + /** Get the start day of month/1/year */ + public static int getStartDay(int year, int month) { + final int START_DAY_FOR_JAN_1_1800 = 3; + // Get total number of days from 1/1/1800 to month/1/year + int totalNumberOfDays = getTotalNumberOfDays(year, month); + + // Return the start day for month/1/year + return (totalNumberOfDays + START_DAY_FOR_JAN_1_1800) % 7; + } + + /** Get the total number of days since January 1, 1800 */ + public static int getTotalNumberOfDays(int year, int month) { + int total = 0; + + // Get the total days from 1800 to 1/1/year + for (int i = 1800; i < year; i++) + if (isLeapYear(i)) + total = total + 366; + else + total = total + 365; + + // Add days from Jan to the month prior to the calendar month + for (int i = 1; i < month; i++) + total = total + getNumberOfDaysInMonth(year, i); + + return total; + } + + /** Get the number of days in a month */ + public static int getNumberOfDaysInMonth(int year, int month) { + if (month == 1 || month == 3 || month == 5 || month == 7 || + month == 8 || month == 10 || month == 12) + return 31; + + if (month == 4 || month == 6 || month == 9 || month == 11) + return 30; + + if (month == 2) return isLeapYear(year) ? 29 : 28; + + return 0; // If month is incorrect + } + + /** Determine if it is a leap year */ + public static boolean isLeapYear(int year) { + return year % 400 == 0 || (year % 4 == 0 && year % 100 != 0); + } +} + diff --git a/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/Rectangle.java b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/Rectangle.java new file mode 100644 index 0000000..48431f2 --- /dev/null +++ b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/Rectangle.java @@ -0,0 +1,67 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5_chloefontenot; + +/** + * + * @author chloe + */ +public class Rectangle extends GeometricObject{ + private double width; + private double height; + + public Rectangle() { + + } + + public Rectangle(double width, double height) { + this.width = width; + this.height = height; + } + + public double getWidth() { + return width; + } + + public void setWidth(double width) { + this.width = width; + } + + public double getHeight() { + return height; + } + + public void setHeight(double height) { + this.height = height; + } + + @Override + public double getArea() { + return width * height; + } + + @Override + public double getPerimeter() { + return 2 * (width + height); + } + + @Override + public int compareTo(GeometricObject t) { + System.out.println(this.getArea() + ", " + (t).getArea()); + if (this.getArea() < (t).getArea()) { + return -1; + } else if (this.getArea() > (t).getArea()) { + return 1; + } else { + return 0; + } + } + + @Override + public int compareTo(Object t) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + +} diff --git a/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/ShuffleArrayList.java b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/ShuffleArrayList.java new file mode 100644 index 0000000..18175bb --- /dev/null +++ b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/ShuffleArrayList.java @@ -0,0 +1,73 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5_chloefontenot; + +import java.util.*; + +/** + * + * @author chloe + */ +public class ShuffleArrayList { + +public static void shuffle(ArrayList list) { + // Create a new Random object. + Random rng = new Random(); + // Create an ArrayList to store the indices of the elements that have been selected. + ArrayList selectedIndices = new ArrayList(); + + // Loop through each element in the list. + for (int i = 0; i < list.size(); ++i) { + // Generate a random index that has not been selected before. + int randomIndex; + do { + randomIndex = rng.nextInt(list.size()); // Generate a random integer between 0 (inclusive) and the size of the list (exclusive). + } while (selectedIndices.contains(randomIndex)); // Repeat until an unselected index is found. + selectedIndices.add(randomIndex); // Add the selected index to the list of selected indices. + //System.out.println(randomIndex + ", " + i); + // Swap the element at the random index with the element at the current index of the loop. + // This shuffles the list by randomly selecting an element to swap with the current element at each iteration. + Number temp = list.get(randomIndex); // Save the element at the random index to a temporary variable. + list.set(randomIndex, list.get(i)); // Overwrite the element at the random index with the element at the current index of the loop. + list.set(i, temp); // Set the current index of the loop to the saved element, effectively swapping the two elements. + } +} + + + public static String checkForDuplicates(ArrayList list) { + // Ensure Array does not include repeat numbers. + boolean repeatNumber = false; + for (int i = 0; i < list.size(); ++i) { + for (int j = 0; j < list.size(); ++j) { + if (i != j) { + //System.out.println("Checking " + list.get(i) + " and " + list.get(j)); + if (list.get(i) == list.get(j)) { + repeatNumber = true; + } + } + } + } + if (repeatNumber) { + return "Numbers repeat in ArrayList."; + } else { + return "Numbers do not repeat in ArrayList."; + } + } + + public static void main(String[] args) { + final int ARRAY_SIZE = 50; + ArrayList list = new ArrayList<>(); + for (int i = 0; i < ARRAY_SIZE; ++i) { + list.add(i + 1); // Fill ArrayList with sequential numbers. + } + + System.out.println(list); + System.out.println(checkForDuplicates(list)); + shuffle(list); + System.out.println(list); + System.out.println(checkForDuplicates(list)); + } + +} diff --git a/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/SortArrayList.java b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/SortArrayList.java new file mode 100644 index 0000000..54387e9 --- /dev/null +++ b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/SortArrayList.java @@ -0,0 +1,47 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5_chloefontenot; + +import java.math.BigDecimal; +import java.util.ArrayList; + +/** + * + * @author chloe + */ +public class SortArrayList { + + public static void sort(ArrayList list) { + // Selection sort implementation for ArrayLists. + for (int i = 0; i < list.size(); ++i) { + for (int j = i + 1; j < list.size(); ++j) { + // BigDecimal should work for any type. Have not confirmed this. + Number numI = list.get(i); + Number numJ = list.get(j); + BigDecimal bigNumI = new BigDecimal(list.get(i).toString()); + BigDecimal bigNumJ = new BigDecimal(list.get(j).toString()); + if (bigNumI.compareTo(bigNumJ) == 1) { + Number tmp = numI; + list.set(i, numJ); + list.set(j, tmp); + } + } + } + } + + public static void main(String[] args) { + final int ARRAY_SIZE = 50; + ArrayList list = new ArrayList<>(); + for (int i = 0; i < ARRAY_SIZE; ++i) { + list.add((i) + Math.random()); // Fill ArrayList with sequential numbers. + } + System.out.println(list); + ShuffleArrayList.shuffle(list); // Use our shuffle method from earlier + System.out.println(list); + sort(list); + System.out.println(list); + + } +} diff --git a/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/TestGeometricObject.java b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/TestGeometricObject.java new file mode 100644 index 0000000..97d3c48 --- /dev/null +++ b/Semester 2/Assignments/MP5_ChloeFontenot/src/main/java/com/chloefontenot/mp5_chloefontenot/TestGeometricObject.java @@ -0,0 +1,32 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5_chloefontenot; + +/** + * + * @author chloe + */ +public class TestGeometricObject { +public static void main(String[] args) { + // Create two comparable Circles + Circle circle1 = new Circle(5); + Circle circle2 = new Circle(4); + + // Display the max Circle + Circle circle = (Circle) GeometricObject.max(circle1, circle2); + System.out.println("The max Circle's radius is " + circle.getRadius()); + System.out.println(circle); + + // Create two comparable rectangles + Rectangle r1 = new Rectangle(5, 4); + Rectangle r2 = new Rectangle(4, 5); + + System.out.println(r1.compareTo(r2)); + System.out.println("The max rectangle is " + (Rectangle) Rectangle.max(r1, r2)); + + System.out.println("The max geometric object is " + GeometricObject.max(circle1, r2)); + } +} + diff --git a/Semester 2/Assignments/lab-2D-arrays-sort_ChloeFontenot/src/main/java/com/chloefontenot/lab/d/arrays/sort_chloefontenot/Lab2DArraysSort_CalebFontenot.java b/Semester 2/Assignments/lab-2D-arrays-sort_ChloeFontenot/src/main/java/com/chloefontenot/lab/d/arrays/sort_chloefontenot/Lab2DArraysSort_CalebFontenot.java new file mode 100644 index 0000000..29d5e44 --- /dev/null +++ b/Semester 2/Assignments/lab-2D-arrays-sort_ChloeFontenot/src/main/java/com/chloefontenot/lab/d/arrays/sort_chloefontenot/Lab2DArraysSort_CalebFontenot.java @@ -0,0 +1,134 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ +package com.chloefontenot.lab.d.arrays.sort_chloefontenot; + +/** + * + * @author chloe + */ +public class Lab2DArraysSort_ChloeFontenot { + + public static int maxNumberOfColumnsInJagged2dArray(char[][] ar) + { + int maxNumberOfColumns = 0; + for (int row = 0; row < ar.length; ++row) { + if (ar[row].length > maxNumberOfColumns) { + maxNumberOfColumns = ar[row].length; + } + } + + return maxNumberOfColumns; + } + + public static void printColumnMajorOrder(char[][] ar) + { + int row = 0; + int column = 0; + int max = maxNumberOfColumnsInJagged2dArray(ar); + for (column = 0; column < max; ++column) { + for (row = 0; row < ar.length; ++row) { + if (column < ar[row].length) { + System.out.print(ar[row][column] + " "); + } + } + System.out.println(""); + } + } + + /** + * Prints row by row + * + * @param ar + */ + public static void printRowMajorOrder(char[][] ar)//normal + { + for (int x = 0; x < ar.length; ++x) { + for (int y = 0; y < ar[x].length; ++y) { + System.out.print(ar[x][y] + ""); + } + System.out.println(); + } + + } + public static String returnRowMajorOrder(char[] ar)//normal + { + String returnString = ""; + for (int x = 0; x < ar.length; ++x) { + returnString += ar[x]; + } + return returnString; + } + + /** + * Sorts the methods in ascending order using Selection Sort + * + * @param names the names to be sorted + */ + public static void sortNames(char[][] names) + { + for (int i = 0; i < names.length - 1; ++i) { + for (int j = i + 1; j < names.length; ++j) { + char compChar1 = names[i][0], compChar2 = names[j][0]; + // Reoder entire row + for (int rowIterate = 1; rowIterate < maxNumberOfColumnsInJagged2dArray(names); ++rowIterate) { + if (Character.toLowerCase(compChar1) == Character.toLowerCase(compChar2)) { + try { + compChar1 = names[i][rowIterate]; + compChar2 = names[j][rowIterate]; + } catch (Exception ex) { + // If it's failed, the index has gone out of range. + // Check the length of the arrays and swap the larger one with the smaller one. + if (names[i].length > names[j].length) { + System.out.println(names[i].length + " " + names[j].length); + System.out.println("Swapping " + returnRowMajorOrder(names[i]) + " with " + returnRowMajorOrder(names[j])); + char[] temp = names[i]; + names[i] = names[j]; + names[j] = temp; + } + break; + } + + } + if (Character.toLowerCase(compChar1) > Character.toLowerCase(compChar2)) { + System.out.println("Swapping " + returnRowMajorOrder(names[i]) + " with " + returnRowMajorOrder(names[j])); + char[] temp = names[i]; + names[i] = names[j]; + names[j] = temp; + } + } + } + } + } + + public static void main(String[] args) + { + /* +char[][] names = { + {'j', 'o', 'h', 'n'}, + {'a', 'n'}, + {'b', 'y', 'r', 'o', 'n'},}; + */ + ///* + char[][] names = { + {'j', 'o', 'h', 'n'}, + {'a', 'n'}, + {'b', 'y', 'r', 'o', 'n'}, + {'b', 'y', 'r', 'o', 'n', 'i'}, + {'a', 'a', 'o', 'n'}, + {'b', 'b', 'b', 'b'}, + {'b', 'b', 'b', 'c'}, + {'b', 'b', 'b'} + }; +//*/ + //printColumnMajorOrder(names); + printRowMajorOrder(names); + System.out.println(); + sortNames(names); + System.out.println(); + printRowMajorOrder(names); + //printColumnMajorOrder(names); + + } + +} diff --git a/Semester 2/Assignments/lab-2D-arrays_ChloeFontenot/src/main/java/com/chloefontenot/lab/d/arrays_chloefontenot/Lab2DArrays_CalebFontenot.java b/Semester 2/Assignments/lab-2D-arrays_ChloeFontenot/src/main/java/com/chloefontenot/lab/d/arrays_chloefontenot/Lab2DArrays_CalebFontenot.java new file mode 100644 index 0000000..06b7f43 --- /dev/null +++ b/Semester 2/Assignments/lab-2D-arrays_ChloeFontenot/src/main/java/com/chloefontenot/lab/d/arrays_chloefontenot/Lab2DArrays_CalebFontenot.java @@ -0,0 +1,209 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template + */ +package com.chloefontenot.lab.d.arrays_chloefontenot; + +/** + * + * @author chloe + */ +public class Lab2DArrays_ChloeFontenot { + + public static void main(String[] args) + { + int[][] a1 = { + {1, 2, 3, 4}, + {5, 6, 7, 8}, + {9, 10, 11, 12} + }; + String[][] a2 = { + {"john", "paul", "james"}, + {"mary", "laura", "margaret"} + }; + + print(a1); + System.out.println(); + print(a2); + + int a3[][] = new int[5][5]; + initializeArray(a3); + System.out.println(); + print(a3); + + System.out.println(); + int[][] dupDup = dup(a1); + print(dupDup); + + System.out.println(); + String[][] a4 = { + {"ASDV", "MATH", "ENGL"}, + {"BIOL", "CHEM"}, + {"PHYS"} + }; + print(a4); + + System.out.println(); + printColumnMajorOrder(a4); + + System.out.println(); + int[][] a5 = { + {1}, + {1, 2}, + {1, 2, 3} + }; + System.out.println("Max number of columns in ar5 is " + maxNumberOfColumnsInJagged2DArray(a5)); + + System.out.println(); + int[][][] a6 = { + { {1, 2}, {3, 4} }, // table 1 NOT jagged 2x2 + {{5, 6}, {-1} }, // table 2 jagged + {{7, 8 ,9}, {10, 11}, {12, 13, 14, 15}} // table 3 jagged + }; + print(a6); + + String[] a7 = {"john", "Mary", "Paul", "nick", "Peter", "anna"}; + + System.out.println(); + selectionSort(a7); + print(a7); + } + + public static void print(int[][] a1) + { + for (int i = 0; i < a1.length; ++i) { + for (int j = 0; j < a1[i].length; ++j) { + System.out.print(a1[i][j] + " "); + } + System.out.println(); + } + } + public static void print(int[][][] a1) + { + for (int i = 0; i < a1.length; ++i) { + System.out.println("\n Table: " + (i+1)); + for (int j = 0; j < a1[i].length; ++j) { + for (int k = 0; k < a1[i][j].length; ++k) { + System.out.print(a1[i][j][k] + " "); + } + System.out.println(); + } + + } + } + + public static void print(String[][] a1) + { + for (int i = 0; i < a1.length; ++i) { + for (int j = 0; j < a1[i].length; ++j) { + System.out.print(a1[i][j] + " "); + } + System.out.println(); + } + } + + public static void print(String[] a1) + { + for (int i = 0; i < a1.length; ++i) { + System.out.print(a1[i] + " "); + } + System.out.println(); + } + + public static void initializeArray(int[][] a1) + { + for (int i = 0; i < a1.length; ++i) { + for (int j = 0; j < a1[i].length; ++j) { + a1[i][j] = (int) (Math.random() * 11); + } + } + } + + public static int[][] dup(int[][] a1) + { + int[][] dupArray = new int[a1.length][a1[0].length]; + + for (int i = 0; i < a1.length; ++i) { + for (int j = 0; j < a1[i].length; ++j) { + dupArray[i][j] = a1[i][j]; + } + } + return dupArray; + } + + public static void printColumnMajorOrder(String[][] ar) + { + int row = 0; + int column = 0; + int max = maxNumberOfColumnsInJagged2DArray(ar); + for (column = 0; column < max; ++column) { + for (row = 0; row < ar.length; ++row) { + if (column < ar[row].length) { + System.out.print(ar[row][column] + " "); + } + } + System.out.println(); + } + } + + public static int maxNumberOfColumnsInJagged2DArray(int[][] ar) { + int maxNumberOfColumns = 0; + for (int row = 0; row < ar.length; ++row) { + if (ar[row].length > maxNumberOfColumns) { + maxNumberOfColumns = ar[row].length; + } + } + return maxNumberOfColumns; + } + public static int maxNumberOfColumnsInJagged2DArray(String[][] ar) { + int maxNumberOfColumns = 0; + for (int row = 0; row < ar.length; ++row) { + if (ar[row].length > maxNumberOfColumns) { + maxNumberOfColumns = ar[row].length; + } + } + return maxNumberOfColumns; + } + public static void printARow(int[] rowOf2D) { + for (int i = 0; i < rowOf2D.length; ++i) { + System.out.print(rowOf2D[i] + " "); + } + System.out.println(); + } + public static void selectionSort(int[] ar1) { + for (int i = 0; i < ar1.length - 1; ++i) { + for (int j = i + 1; j < ar1.length; ++j) { + if (ar1[i] > ar1[j]) { + int temp = ar1[i]; + ar1[i] = ar1[j]; + ar1[j] = temp; + } + } + } + } + public static void selectionSort(String[] ar1) { + for (int i = 0; i < ar1.length - 1; ++i) { + for (int j = i + 1; j < ar1.length; ++j) { + // Compare all chars in string if first chars match + char compChar1 = ar1[i].charAt(0), compChar2 = ar1[j].charAt(0); + for (int index = 1; index < ar1[i].length(); ++index) { + if (Character.toLowerCase(compChar1) == Character.toLowerCase(compChar2)) { + try { + compChar1 = ar1[i].charAt(index); + compChar2 = ar1[j].charAt(index); + } catch (Exception ex) { + // If it's failed, the index has gone out of range. + break; + } + } + } + if (Character.toLowerCase(compChar1) > Character.toLowerCase(compChar2)) { + String temp = ar1[i]; + ar1[i] = ar1[j]; + ar1[j] = temp; + } + } + } + } + +} diff --git a/Semester 2/Assignments/lab1-ChloeFontenot/src/main/java/com/chloefontenot/lab1/chloefontenot/JakartaRestConfiguration.java b/Semester 2/Assignments/lab1-ChloeFontenot/src/main/java/com/chloefontenot/lab1/chloefontenot/JakartaRestConfiguration.java new file mode 100644 index 0000000..cf84dcd --- /dev/null +++ b/Semester 2/Assignments/lab1-ChloeFontenot/src/main/java/com/chloefontenot/lab1/chloefontenot/JakartaRestConfiguration.java @@ -0,0 +1,13 @@ +package com.chloefontenot.lab1.chloefontenot; + +import jakarta.ws.rs.ApplicationPath; +import jakarta.ws.rs.core.Application; + +/** + * Configures Jakarta RESTful Web Services for the application. + * @author Juneau + */ +@ApplicationPath("resources") +public class JakartaRestConfiguration extends Application { + +} diff --git a/Semester 2/Assignments/lab1-ChloeFontenot/src/main/java/com/chloefontenot/lab1/chloefontenot/resources/JakartaEE91Resource.java b/Semester 2/Assignments/lab1-ChloeFontenot/src/main/java/com/chloefontenot/lab1/chloefontenot/resources/JakartaEE91Resource.java new file mode 100644 index 0000000..7dec4c4 --- /dev/null +++ b/Semester 2/Assignments/lab1-ChloeFontenot/src/main/java/com/chloefontenot/lab1/chloefontenot/resources/JakartaEE91Resource.java @@ -0,0 +1,20 @@ +package com.chloefontenot.lab1.chloefontenot.resources; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.Response; + +/** + * + * @author + */ +@Path("jakartaee9") +public class JakartaEE91Resource { + + @GET + public Response ping(){ + return Response + .ok("ping Jakarta EE") + .build(); + } +} diff --git a/Semester 2/Assignments/lab1-ChloeFontenot2/src/main/java/edu/slcc/asdv/chloe/lab1/chloefontenot2/JakartaRestConfiguration.java b/Semester 2/Assignments/lab1-ChloeFontenot2/src/main/java/edu/slcc/asdv/chloe/lab1/chloefontenot2/JakartaRestConfiguration.java new file mode 100644 index 0000000..c82f48f --- /dev/null +++ b/Semester 2/Assignments/lab1-ChloeFontenot2/src/main/java/edu/slcc/asdv/chloe/lab1/chloefontenot2/JakartaRestConfiguration.java @@ -0,0 +1,13 @@ +package edu.slcc.asdv.chloe.lab1.chloefontenot2; + +import jakarta.ws.rs.ApplicationPath; +import jakarta.ws.rs.core.Application; + +/** + * Configures Jakarta RESTful Web Services for the application. + * @author Juneau + */ +@ApplicationPath("resources") +public class JakartaRestConfiguration extends Application { + +} diff --git a/Semester 2/Assignments/lab1-ChloeFontenot2/src/main/java/edu/slcc/asdv/chloe/lab1/chloefontenot2/resources/JakartaEE91Resource.java b/Semester 2/Assignments/lab1-ChloeFontenot2/src/main/java/edu/slcc/asdv/chloe/lab1/chloefontenot2/resources/JakartaEE91Resource.java new file mode 100644 index 0000000..9492564 --- /dev/null +++ b/Semester 2/Assignments/lab1-ChloeFontenot2/src/main/java/edu/slcc/asdv/chloe/lab1/chloefontenot2/resources/JakartaEE91Resource.java @@ -0,0 +1,20 @@ +package edu.slcc.asdv.chloe.lab1.chloefontenot2.resources; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.Response; + +/** + * + * @author + */ +@Path("jakartaee9") +public class JakartaEE91Resource { + + @GET + public Response ping(){ + return Response + .ok("ping Jakarta EE") + .build(); + } +} diff --git a/Semester 2/Assignments/lab2_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/Lab5_CalebFontenot.java b/Semester 2/Assignments/lab2_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/Lab5_CalebFontenot.java new file mode 100644 index 0000000..0de4c9f --- /dev/null +++ b/Semester 2/Assignments/lab2_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/Lab5_CalebFontenot.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package com.chloefontenot.lab5_chloefontenot; + +/** + * + * @author chloe + */ +public class Lab5_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 2/Assignments/lab2_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/QuadraticEquation.java b/Semester 2/Assignments/lab2_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/QuadraticEquation.java new file mode 100644 index 0000000..76c3c73 --- /dev/null +++ b/Semester 2/Assignments/lab2_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/QuadraticEquation.java @@ -0,0 +1,92 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab5_chloefontenot; + +/** + * + * @author chloe + */ +public class QuadraticEquation { + + private double a; + private double b; + private double c; + + public QuadraticEquation(double a, double b, double c) + { + this.a = a; + this.b = b; + this.c = c; + } + + public double getDiscriminant() + { + return b * b - 4 * a * c; + } + + public double getRoot1() + { + if (getDiscriminant() < 0) { + return -88888888; + } + return (b + Math.sqrt(b * b - 4 * a * c)) / (2 * a); + } + + + public double getRoot2() + { + if (getDiscriminant() < 0) { + return -88888888; + } + return (-b + Math.sqrt(b * b - 4 * a * c)) / (2 * a); + + //return getDiscriminant() < 0 ? 0 + // : ((-b) + Math.sqrt(Math.pow(b, 2) - 4 * a * c)) / (2 * a); + } + + @Override + public String toString() + { + return "QuadraticEquation{" + "a=" + a + ", b=" + b + ", c=" + c + '}'; + } + + /** + * Get the value of b + * + * @return the value of b + */ + public double getB() + { + return b; + } + + /** + * Get the value of c + * + * @return the value of c + */ + public double getC() + { + return c; + } + + /** + * Get the value of a + * + * @return the value of a + */ + public double getA() + { + return a; + } + + public static void main(String[] args) + { + QuadraticEquation eq1 = new QuadraticEquation(1, -4, 4); + System.out.println(eq1); + System.out.println(eq1.getRoot1()); + System.out.println(eq1.getRoot2()); + } +} diff --git a/Semester 2/Assignments/lab2_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/TakeQuiz.java b/Semester 2/Assignments/lab2_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/TakeQuiz.java new file mode 100644 index 0000000..6939439 --- /dev/null +++ b/Semester 2/Assignments/lab2_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/TakeQuiz.java @@ -0,0 +1,71 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab5_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class TakeQuiz { + public static void takeQuiz(TrueFalseQuiz quiz) { + //>Create a scanner for reading + Scanner scan = new Scanner(System.in); + String s = ""; + + //>do forever + do + { + + System.out.println("q\\Q to quit"); + System.out.println("n\\N next question"); + s = scan.next(); + + if (s.compareToIgnoreCase("q") == 0) + { + break; + } + else if ("n".compareToIgnoreCase(s) == 0) + { + System.out.println("+++++++++++" + quiz.nextQuestion() + "+++++++++++"); + + String answer = ""; + do + { + System.out.println("\tt\\T for true"); + System.out.println("\tf\\F for false"); + answer = scan.next(); + if ("t".compareToIgnoreCase(answer) != 0 && "f".compareToIgnoreCase(answer) != 0) + { + System.out.println("\t\tf INVALID CHOICE"); + } + + } + while ("t".compareToIgnoreCase(answer) != 0 && "f".compareToIgnoreCase(answer) != 0); + + boolean convertAnswerToBoolean = "t".compareToIgnoreCase(answer) == 0; + + System.out.println(quiz.isTrue() == convertAnswerToBoolean + ? "\t\t---------correct" + : "\t\t---------incorrect"); + + } + else + { + System.out.println("Invalid choice. Try again"); + } + } + while (true); + } + public static void main(String[] args) + { + TrueFalseQuiz quiz = new TrueFalseQuiz(); + TakeQuiz.takeQuiz(quiz); + for (int i = 0; i < quiz.getTrueFalseQuestions().length; ++i) { + System.out.println(quiz.getTrueFalseQuestions()[i].getWhenLastUsed()); + } + } +} diff --git a/Semester 2/Assignments/lab2_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/TrueFalseQuestion.java b/Semester 2/Assignments/lab2_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/TrueFalseQuestion.java new file mode 100644 index 0000000..6683575 --- /dev/null +++ b/Semester 2/Assignments/lab2_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/TrueFalseQuestion.java @@ -0,0 +1,86 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab5_chloefontenot; + +import java.util.Date; + +/** + * + * @author chloe + */ +public class TrueFalseQuestion { + + private String question; + private boolean isTrue; + private Date whenLastUsed; + + public TrueFalseQuestion(){} + public TrueFalseQuestion(String question, boolean isTrue, Date whenLastUsed) { + this.question = question; + this.isTrue = isTrue; + this.whenLastUsed = whenLastUsed; + } + + /** + * Get the value of whenLastUsed + * + * @return the value of whenLastUsed + */ + public Date getWhenLastUsed() + { + return whenLastUsed; + } + + /** + * Set the value of whenLastUsed + * + * @param whenLastUsed new value of whenLastUsed + */ + public void setWhenLastUsed(Date whenLastUsed) + { + this.whenLastUsed = whenLastUsed; + } + + + /** + * Get the value of isTrue + * + * @return the value of isTrue + */ + public boolean isIsTrue() + { + return isTrue; + } + + /** + * Set the value of isTrue + * + * @param isTrue new value of isTrue + */ + public void setIsTrue(boolean isTrue) + { + this.isTrue = isTrue; + } + + /** + * Get the value of question + * + * @return the value of question + */ + public String getQuestion() + { + return question; + } + +/**Sets the question to a new question. + * + * @param question the new question + */ + public void setQuestion(String question) + { + this.question = question; + } + +} diff --git a/Semester 2/Assignments/lab2_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/TrueFalseQuiz.java b/Semester 2/Assignments/lab2_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/TrueFalseQuiz.java new file mode 100644 index 0000000..6408b93 --- /dev/null +++ b/Semester 2/Assignments/lab2_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/TrueFalseQuiz.java @@ -0,0 +1,99 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab5_chloefontenot; + +import java.util.Date; + +/** + * + * @author chloe + */ +public class TrueFalseQuiz { + + int currentQuestion; + TrueFalseQuestion[] trueFalseQuestions; + + public TrueFalseQuiz() + { + trueFalseQuestions = new TrueFalseQuestion[5]; + + trueFalseQuestions[0] + = new TrueFalseQuestion("The Pacific Ocean is larger than the Atlantic Ocean.", + true, new Date()); + + trueFalseQuestions[1] + = new TrueFalseQuestion("The Suez Canal connects the Red Sea and the Indian Ocean.", false, new Date()); + + trueFalseQuestions[2] + = new TrueFalseQuestion("The source of the nile River is in Egypt.", false, new Date()); + + trueFalseQuestions[3] + = new TrueFalseQuestion("Lake Baikal is the world\'s oldest and deepest freshwater lake.", true, new Date()); + + trueFalseQuestions[4] + = new TrueFalseQuestion("The Amazon River is the longest river in the Americas.", true, new Date()); + this.currentQuestion = 0; + } + + public TrueFalseQuiz(String[] questions, boolean[] trueFalse) + { + //> Create an array of REFERENCES of size questions.length + //the references are initializesed to null + trueFalseQuestions = new TrueFalseQuestion[questions.length]; + + //> assign to each reference of the array an object of type TrueFalseQuestion + for (int i = 0, j = 0; i < questions.length; ++i, ++j) { + trueFalseQuestions[i] = new TrueFalseQuestion( + questions[i], + trueFalse[j], + new Date()); + //> set the index of the first question + this.currentQuestion = 0; + } + } + + /** + * Gets the current question. If the current question is the last last question in the quiz and we call this method the method will return the first question. + * + * @return current question; + */ + public String nextQuestion() + { + + if (++this.currentQuestion == this.trueFalseQuestions.length) { + this.currentQuestion = 0; + } + this.trueFalseQuestions[this.currentQuestion].setWhenLastUsed(new Date()); + return this.trueFalseQuestions[this.currentQuestion].getQuestion(); + } + /** + * Returns true if the current question is true. + * @return true if the current question is true, false otherwise. + */ + public boolean isTrue() { + return this.trueFalseQuestions[this.currentQuestion].isIsTrue(); + } + + public int getCurrentQuestion() + { + return currentQuestion; + } + + public void setCurrentQuestion(int currentQuestion) + { + this.currentQuestion = currentQuestion; + } + + public TrueFalseQuestion[] getTrueFalseQuestions() + { + return trueFalseQuestions; + } + + public void setTrueFalseQuestions(TrueFalseQuestion[] trueFalseQuestions) + { + this.trueFalseQuestions = trueFalseQuestions; + } + +} diff --git a/Semester 2/Assignments/lab3_ChloeFontenot/src/main/java/com/chloefontenot/lab3_chloefontenot/Fan.java b/Semester 2/Assignments/lab3_ChloeFontenot/src/main/java/com/chloefontenot/lab3_chloefontenot/Fan.java new file mode 100644 index 0000000..d02954b --- /dev/null +++ b/Semester 2/Assignments/lab3_ChloeFontenot/src/main/java/com/chloefontenot/lab3_chloefontenot/Fan.java @@ -0,0 +1,138 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ +package com.chloefontenot.lab3_chloefontenot; + +/** + * + * @author chloe + */ +public class Fan { + // Constants + public static final int SLOW = 1; + public static final int MEDIUM = 2; + public static final int FAST = 3; + + private int speed; + private boolean isOn; + private int radius; + private String color; + + public Fan() { + this.speed = 1; + this.isOn = false; + this.radius = 5; + this.color = "blue"; + } + + /** + * Get the value of color + * + * @return the value of color + */ + public String getColor() + { + return color; + } + + /** + * Set the value of color + * + * @param color new value of color + */ + public void setColor(String color) + { + this.color = color; + } + + /** + * Get the value of radius + * + * @return the value of radius + */ + public int getRadius() + { + return radius; + } + + /** + * Set the value of radius + * + * @param radius new value of radius + */ + public void setRadius(int radius) + { + this.radius = radius; + } + + /** + * Get the value of isOn + * + * @return the value of isOn + */ + public boolean isOn() + { + return isOn; + } + + /** + * Set the value of isOn + * + * @param isOn new value of isOn + */ + public void setOn(boolean isOn) + { + this.isOn = isOn; + } + + /** + * Get the value of speed + * + * @return the value of speed + */ + public int getSpeed() + { + return speed; + } + + /** + * Set the value of speed + * + * @param speed new value of speed + */ + public void setSpeed(int speed) + { + this.speed = speed; + } + + @Override + public String toString() + { + String returnString; + if (this.isOn) { + returnString = "fan is on. "; + } + else { + returnString = "fan is off. "; + } + returnString += "{" + "speed=" + speed + ", radius=" + radius + ", color=" + color + '}'; + return returnString; + } + + public static void main(String[] args) + { + Fan fan1 = new Fan(); + fan1.setSpeed(Fan.FAST); + fan1.setRadius(10); + fan1.setColor("yellow"); + fan1.setOn(true); + System.out.println(fan1); + + Fan fan2 = new Fan(); + fan2.setSpeed(Fan.MEDIUM); + fan2.setRadius(5); + fan2.setColor("blue"); + fan2.setOn(false); + System.out.println(fan2.toString()); + } +} diff --git a/Semester 2/Assignments/lab3_ChloeFontenot/src/main/java/com/chloefontenot/lab3_chloefontenot/FanList.java b/Semester 2/Assignments/lab3_ChloeFontenot/src/main/java/com/chloefontenot/lab3_chloefontenot/FanList.java new file mode 100644 index 0000000..6ad54f4 --- /dev/null +++ b/Semester 2/Assignments/lab3_ChloeFontenot/src/main/java/com/chloefontenot/lab3_chloefontenot/FanList.java @@ -0,0 +1,79 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab3_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class FanList { + + private Fan[] list; + + // A constructor that creates a list of type fan + public FanList(int listSize) + { + list = new Fan[listSize]; + createListObjects(); + } + + // Creates a list of Fan objects from User's input + private void createListObjects() + { + Scanner scan = new Scanner(System.in); + for (int i = 0; i < list.length; ++i) { + Fan fan = new Fan(); + System.out.println("Enter FAN data for fan " + (i + 1) + + ": color, radius, speed(1, 2 or 3) and if on (t, f)"); + String color = scan.next(); + int radius = scan.nextInt(); + int speed = scan.nextInt(); + String on = scan.next(); + fan.setSpeed(speed); + fan.setRadius(radius); + fan.setColor(color); + if ("t".compareToIgnoreCase(on) == 0) { + fan.setOn(true); + } else { + fan.setOn(false); + } + list[i] = fan; + System.out.println("----------------------------------------"); + } + } + + @Override + public String toString() + { + String s = "FanList{" + "list=\n"; + for (int i = 0; i < list.length; ++i) { + s += list[i].toString() + "\n-----------------------\n"; + } + s += '}'; + return s; + } + + public void sortListByRadius() + { + for (int i = 0; i < list.length - 1; ++i) { + for (int j = i + 1; j < list.length; ++j) { + if (list[i].getRadius() > list[j].getRadius()) { + Fan temp = list[i]; + list[i] = list[j]; + list[j] = temp; + } + } + } + } + public static void main(String[] args) + { + FanList fanList = new FanList(3); + System.out.println(fanList); + fanList.sortListByRadius(); + System.out.println(fanList.toString()); + } +} diff --git a/Semester 2/Assignments/lab3_ChloeFontenot/src/main/java/com/chloefontenot/lab3_chloefontenot/Stock.java b/Semester 2/Assignments/lab3_ChloeFontenot/src/main/java/com/chloefontenot/lab3_chloefontenot/Stock.java new file mode 100644 index 0000000..c179aad --- /dev/null +++ b/Semester 2/Assignments/lab3_ChloeFontenot/src/main/java/com/chloefontenot/lab3_chloefontenot/Stock.java @@ -0,0 +1,119 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab3_chloefontenot; + +/** + * + * @author chloe + */ +public class Stock { + + private String symbol; + private String name; + private double previousClosingPrice; + private double currentPrice; + + /** + * Get the value of currentPrice + * + * @return the value of currentPrice + */ + public double getCurrentPrice() + { + return currentPrice; + } + + /** + * Set the value of currentPrice + * + * @param currentPrice new value of currentPrice + */ + public void setCurrentPrice(double currentPrice) + { + this.currentPrice = currentPrice; + } + + + /** + * Get the value of previousClosingPrice + * + * @return the value of previousClosingPrice + */ + public double getPreviousClosingPrice() + { + return previousClosingPrice; + } + + /** + * Set the value of previousClosingPrice + * + * @param previousClosingPrice new value of previousClosingPrice + */ + public void setPreviousClosingPrice(double previousClosingPrice) + { + this.previousClosingPrice = previousClosingPrice; + } + + + /** + * Get the value of name + * + * @return the value of name + */ + public String getName() + { + return name; + } + + /** + * Set the value of name + * + * @param name new value of name + */ + public void setName(String name) + { + this.name = name; + } + + /** + * Get the value of symbol + * + * @return the value of symbol + */ + public String getSymbol() + { + return symbol; + } + + /** + * Set the value of symbol + * + * @param symbol new value of symbol + */ + public void setSymbol(String symbol) + { + this.symbol = symbol; + } + + public double getChangePercent() { + return this.currentPrice - this.previousClosingPrice; + //(((this.previousClosingPrice - this.currentPrice) / Math.abs(this.previousClosingPrice)) * 100) + } + + @Override + public String toString() + { + return "Stock{" + "symbol=" + symbol + ", name=" + name + ", previousClosingPrice=" + previousClosingPrice + ", currentPrice=" + currentPrice + "}"+ "\n" + "Change in Percent: " + this.getChangePercent(); + } + public static void main(String[] args) + { + Stock stock1 = new Stock(); + stock1.setSymbol("ORCL"); + stock1.setName("Oracle Corporation"); + stock1.setPreviousClosingPrice(34.5); + stock1.setCurrentPrice(34.35); + System.out.println(stock1); + } +} diff --git a/Semester 2/Assignments/lab3_ChloeFontenot/src/main/java/com/chloefontenot/lab3_chloefontenot/StockList.java b/Semester 2/Assignments/lab3_ChloeFontenot/src/main/java/com/chloefontenot/lab3_chloefontenot/StockList.java new file mode 100644 index 0000000..45b4469 --- /dev/null +++ b/Semester 2/Assignments/lab3_ChloeFontenot/src/main/java/com/chloefontenot/lab3_chloefontenot/StockList.java @@ -0,0 +1,75 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab3_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class StockList { + + private Stock[] list; + + // A constructor that creates a list of type stock + public StockList(int listSize) + { + list = new Stock[listSize]; + createListObjects(); + } + + // Creates a list of Fan objects from User's input + private void createListObjects() + { + Scanner scan = new Scanner(System.in); + for (int i = 0; i < list.length; ++i) { + Stock stock = new Stock(); + System.out.println("Enter Stock data for stock " + (i + 1) + + ": symbol, name, previous closing price, and current price"); + String symbol = scan.next(); + String name = scan.next(); + double previousClosingPrice = scan.nextDouble(); + double currentPrice = scan.nextDouble(); + stock.setSymbol(symbol); + stock.setName(name); + stock.setPreviousClosingPrice(previousClosingPrice); + stock.setCurrentPrice(currentPrice); + list[i] = stock; + System.out.println("----------------------------------------"); + } + } + + @Override + public String toString() + { + String s = "StockList{" + "list=\n"; + for (int i = 0; i < list.length; ++i) { + s += list[i].toString() + "\n-----------------------\n"; + } + s += '}'; + return s; + } + + public void sortByChangeInPercentage() + { + for (int i = 0; i < list.length - 1; ++i) { + for (int j = i + 1; j < list.length; ++j) { + if (list[i].getChangePercent() > list[j].getChangePercent()) { + Stock temp = list[i]; + list[i] = list[j]; + list[j] = temp; + } + } + } + } + public static void main(String[] args) + { + StockList stockList = new StockList(3); + System.out.println(stockList); + stockList.sortByChangeInPercentage(); + System.out.println(stockList); + } +} diff --git a/Semester 2/Assignments/lab3_ChloeFontenot_old/src/main/java/com/chloefontenot/lab3_chloefontenot/Account.java b/Semester 2/Assignments/lab3_ChloeFontenot_old/src/main/java/com/chloefontenot/lab3_chloefontenot/Account.java new file mode 100644 index 0000000..964248c --- /dev/null +++ b/Semester 2/Assignments/lab3_ChloeFontenot_old/src/main/java/com/chloefontenot/lab3_chloefontenot/Account.java @@ -0,0 +1,146 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab3_chloefontenot; + +import java.util.Date; +import java.util.Objects; + +/** + * + * @author chloe + */ +public class Account { + + public Account() + { + dateCreated = new Date(); + } + public Account(double balance) { + this.balance = balance; + dateCreated = new Date(); + } + + @Override + public String toString() + { + return "Account{" + "id=" + id + ", balance=" + balance + ", dateCreated=" + dateCreated + '}'; + } + + private int id; + private double balance; + private static int annualInterestRate; + private Date dateCreated; + + /** + * Get the value of id + * + * @return the value of id + */ + public int getId() + { + return id; + } + + /** + * Set the value of id + * + * @param id new value of id + */ + public void setId(int id) + { + this.id = id; + } + + /** + * Get the value of balance + * + * @return the value of balance + */ + public double getBalance() + { + return balance; + } + + /** + * Set the value of balance + * + * @param balance new value of balance + */ + public void setBalance(double balance) + { + this.balance = balance; + } + + + + /** + * Get the value of annualInterestRate + * + * @return the value of annualInterestRate + */ + public static int getAnnualInterestRate() + { + return annualInterestRate; + } + + /** + * Set the value of annualInterestRate + * + * @param annualInterestRate new value of annualInterestRate + */ + public static void setAnnualInterestRate(int annualInterestRate) + { + Account.annualInterestRate = annualInterestRate; + } + public static void main(String[] args) + { + Account account1 = new Account(); + Account account2 = new Account(100); + + System.out.println(account1); + System.out.println(account2); + System.out.println(account1.equals(account2)); + System.out.println(account1.equals(new A())); + + } + public void withdraw(double amount) { + this.balance -= amount; + } + // public void withdraw(double amount) { + // this.balance -= amount; + // } + + @Override + public int hashCode() + { + int hash = 3; + return hash; + } + + @Override + public boolean equals(Object obj) + { + // If the parameter obj is the same as this object + if (this == obj) { // compare addresses + return true; + } + if (obj == null) { // parameter is null + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + // here we are certain + final Account other = (Account) obj; + if (this.id != other.id) { + return false; + } + if (Double.doubleToLongBits(this.balance) != Double.doubleToLongBits(other.balance)) { + return false; + } + return Objects.equals(this.dateCreated, other.dateCreated); + } + +}class A {} diff --git a/Semester 2/Assignments/lab3_ChloeFontenot_old/src/main/java/com/chloefontenot/lab3_chloefontenot/Employee.java b/Semester 2/Assignments/lab3_ChloeFontenot_old/src/main/java/com/chloefontenot/lab3_chloefontenot/Employee.java new file mode 100644 index 0000000..e91923e --- /dev/null +++ b/Semester 2/Assignments/lab3_ChloeFontenot_old/src/main/java/com/chloefontenot/lab3_chloefontenot/Employee.java @@ -0,0 +1,53 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab3_chloefontenot; + +/** + * + * @author chloe + */ +public class Employee { + + private String name; + + public Employee () { + + } + public Employee(String name) + { + this.name = name; + } + + + /** + * Get the value of name + * + * @return the value of name + */ + public String getName() + { + return name; + } + + /** + * Set the value of name + * + * @param name new value of name + */ + public void setName(String name) + { + this.name = name; + } + + public static void main(String[] args) + { + Employee e = new Employee(); + e.setName("John Wayne"); + System.out.println(e.getName()); + + Employee e1 = new Employee("Mary Poppins"); + System.out.println(e1.getName()); + } +} diff --git a/Semester 2/Assignments/lab3_ChloeFontenot_old/src/main/java/com/chloefontenot/lab3_chloefontenot/Lab3_CalebFontenot.java b/Semester 2/Assignments/lab3_ChloeFontenot_old/src/main/java/com/chloefontenot/lab3_chloefontenot/Lab3_CalebFontenot.java new file mode 100644 index 0000000..88622ec --- /dev/null +++ b/Semester 2/Assignments/lab3_ChloeFontenot_old/src/main/java/com/chloefontenot/lab3_chloefontenot/Lab3_CalebFontenot.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package com.chloefontenot.lab3_chloefontenot; + +/** + * + * @author chloe + */ +public class Lab3_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 2/Assignments/lab3_ChloeFontenot_old/src/main/java/com/chloefontenot/lab3_chloefontenot/MyInteger.java b/Semester 2/Assignments/lab3_ChloeFontenot_old/src/main/java/com/chloefontenot/lab3_chloefontenot/MyInteger.java new file mode 100644 index 0000000..d330ad7 --- /dev/null +++ b/Semester 2/Assignments/lab3_ChloeFontenot_old/src/main/java/com/chloefontenot/lab3_chloefontenot/MyInteger.java @@ -0,0 +1,85 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab3_chloefontenot; + +/** + * + * @author chloe + */ +public class MyInteger { + + private int value; + + /** + * Get the value of value + * + * @return the value of value + */ + public int getValue() + { + return this.value; + } + + @Override + public int hashCode() + { + int hash = 7; + return hash; + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final MyInteger other = (MyInteger) obj; + return this.value == other.value; + } + + @Override + public String toString() + { + return "MyInteger{" + "value=" + value + '}'; + } + + public MyInteger(int value) + { + this.value = value; + } +public static boolean isEven(MyInteger other) { + return other.getValue() % 2 == 0; +} +public static boolean isPrime(MyInteger other) { + int numToTest = other.getValue(); + for (int i = 2; i <= numToTest / 2; ++i) { + if (numToTest % i == 0) { + return false; + } + } + return true; +} +public static int parseInteger(char[] array) { + String s = ""; + for (char i: array) { + s += i; + } + return Integer.parseInt(String.valueOf(s)); +} + public static void main(String[] args) + { + + System.out.println(parseInteger(new char[] {'7', '6'})); + System.out.println(MyInteger.isPrime(new MyInteger(3))); + System.out.println(MyInteger.isEven(new MyInteger(4))); + System.out.println(MyInteger.isEven(new MyInteger(3))); + } +} diff --git a/Semester 2/Assignments/lab3_ChloeFontenot_old/target/classes/com/chloefontenot/lab3_chloefontenot/A.class b/Semester 2/Assignments/lab3_ChloeFontenot_old/target/classes/com/chloefontenot/lab3_chloefontenot/A.class new file mode 100644 index 0000000000000000000000000000000000000000..ab2caedc28b88199f7bcccd2b85575056d4d17e0 GIT binary patch literal 308 zcmX^0Z`VEs1_oOO0WJn624;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00Sb_Nbc2DRk;T>a#Xocz?Z{JfIXy!;aVoWvyKcvK-rMg|t={FGEi27aH+ zyi~u^+@#c^ki?{%R7M6NpZw&+oUp{AOb{O`$WoG#S!7#YAKTH6^IH!?6VFfnj3 gFfg!z1t&3ZGcYjlfZ41JJPf=H3=E76d|*}l03`TE<^TWy literal 0 HcmV?d00001 diff --git a/Semester 2/Assignments/lab3_ChloeFontenot_old/target/classes/com/chloefontenot/lab3_chloefontenot/Account.class b/Semester 2/Assignments/lab3_ChloeFontenot_old/target/classes/com/chloefontenot/lab3_chloefontenot/Account.class new file mode 100644 index 0000000000000000000000000000000000000000..ae6b7a3660f7b540f1323fe11b1226e0c0c6e4f8 GIT binary patch literal 3029 zcmX^0Z`VEs1_oP(1}+9B24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00Sb_Nbc20pN&(vr*^eV4?NR4xW~24+qMZU!E923{TpJ_de92A$;mT>a#X zocz?Z{JfIXy!;aVoWvyKcvKNR12&@h70mA z2r&pVGO#Bl<|O7Nr!q1yx`4z*c^JeP#2FcwGE*2C7(KZdBpIaG8Kij_WEf;o{1aSK zl$n>#$iQBfm{XeSpT@|brU9`C$-CB?NJ0=D)ay$25tsTP~2!SGO%d4Xohhz=rHKAGwAU!=rb6g`meIMBsG_jfjPglgpolM z;+D*O{eYs(yprIOqSVA(Yc2*O24i*x6CMUr1~WzmVQ@I3s$pbcF97Mt$zx;?#TGze zAU9d?Fjz8JF*2~F7M3RF6ys1D1+vcuWSK3<`B9+sW6#K-MqJ|HVz6Ui2Bl9Y9tLLy z7e)q-^wbjPoW$Z{Mh0OGQ!|W_ zfh#?=#0i$Sm^CzA7#X;Vk%UCkQ%f8%k}D&FXfbwimfXb5JVpjFjcBBBf;t6cA4_6U zIw&TwNHa2UBtm>@h+rBqGH{e?6ol95`($iN$1l9-(Bn^*vi1+L)y(xT*4w@gqf;ei%QdZ1*$$ROa9pI=g3 zQj}N#3G!loHilv@h7yKSc7`%gu~5#)paN0~DK<0n%JQ>Q^&uXGloW1>$tC$km5dBC zkP{J9A;eIR#JrT8)M6E%{QT_F0&6630009s8HV{XBemv&WSlW z!I>qg)*K9#j11~fe^+Ow*fQ!UK+9PW6RC8zWvpdn;PK4MODzKDy3}HJh8ji&Rg3_@ z<}Y@JIz|RL{7M-a*dT$xpvb_@z{J47z{0=;D&iR!7??m+00RR97pU|E^Z6L~85kIN z85lv;7Xu?h00RSq69Y2?BLf42fYx>fMy=fp?2+3UIJYuzZ3OEGWME+6V_;@rU=U4517R46KX{pxT9zA&em$>Uw(y7O+c1wYD&b zXl-E-(AvVlwSz%o7lRxF!v?q)*uaWpz&1df4zq!gA%Yo7)%*h8O*>YKs?9>HGzSF4IEo=4~l_< zGln4+?j|Ok7uW<$HwiHaGr-*h z3Up3}cz8I;fL+AEz_N)!2^36>44`BJ3FA-(PKE?{pcunKRBAJW61x5I3@i)@VEbV{ zP+<^fV1Pxn3IhWJCqp7b5;TCPFtC6Vmfda!?#S&7sy-lEgh6dPgNE-W25s$a42GK+ zv~?g9h&JEGU=5Pk&0rU~oxx!n14sbj2ss9J1_p*?1`dW424RLY1}TPg21SMp1|5b> z23v+~u)`D}HZmkLq%bfra4?uLq%wpsFfs@;XfvcSgfK9{9GeV|wsd&NJ2S9?wQ_4k zZeb8mPv6QQfUp^oByt(J81lfjK!Tqeo+P*#GLVBm18jCCJos%G7{Muxh0R796#Pu! z;D;Dm#=yi-j$|kc)KE~`%wiA+M~5YY6*NdsK!emrOM4juE6W<~;|#3KYqYj8IBIWW za9j%FXdhtU_66k!oh=L^^Fbn@T(*P3Rc8x>zzzo2DKnvBTsq*K=M8cZGuTB&3_J`B z40Q~w4D}4`42=xj3{4EY3@r>246O`O3>^&e44n*G3|$O53_T2X4805v4ET(7KABJp(90o=Pc?MmETyUW0flDA(c2=H041(+o+`_PE$Yx+*U}ne%XOjYkLU5ch YG88c|GE^{Bfr~;$hH8ddhI$4`00n1p6aWAK literal 0 HcmV?d00001 diff --git a/Semester 2/Assignments/lab3_ChloeFontenot_old/target/classes/com/chloefontenot/lab3_chloefontenot/Employee.class b/Semester 2/Assignments/lab3_ChloeFontenot_old/target/classes/com/chloefontenot/lab3_chloefontenot/Employee.class new file mode 100644 index 0000000000000000000000000000000000000000..0307181792208102f5702e5739d08e762aa2d360 GIT binary patch literal 1100 zcmX^0Z`VEs1_oOOQ!WN324;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00SP6iGJPId+^9tLg(9!3V;MVWc&)?5r649px1{EQ4-Uile$3gL;Bd8r^lK^_Jn z24O}9_TtnMKd^354NUDImx(fnu``JCFi0>+qIe{@vbZEQmyv-vzqEvrK@_4nGhaWT zC^N4lxTGjGF&AvTG!KIegDfKhdpgV}5e-d;WrEzy3yWqw zP>3)nGH@_3F)%PNGBAPC3IhWJD+41akufkbs53Ay7&9<3FoHz2wlgqpWME)mV$fh< zU;w2@1_pix76w5EO$G)A9*80aEe36{VXO?o3`}4H+!&a^7I1+K(9+(@z>YA5kAazi zfkBvog+YXYlR*@0k{Coa)FhBi++fpnK#pK!;07Bn!ypTFpFZ4uTNv0kz}?3Nc8@&R zM0B?a!QEyDbsHO+yCA;PWME~`0-FGF6C2!3Y~Y|`WI%EgCxb479@NYA49sAU>F#FW zh}_P=>!U5iw~awy6N8BMHU_C}400fGA?581s=k{TM06lxh)|JYU}Iol&|~0W&}ZOd zFkp~iFk(<*FlNwUFaf(p0b)3VK7#=R0|N(xDuW?|HUlGr5(77b5rZ}Z6U<%u;IJ|V H2Z{**=EBB3 literal 0 HcmV?d00001 diff --git a/Semester 2/Assignments/lab3_ChloeFontenot_old/target/classes/com/chloefontenot/lab3_chloefontenot/Lab3_CalebFontenot.class b/Semester 2/Assignments/lab3_ChloeFontenot_old/target/classes/com/chloefontenot/lab3_chloefontenot/Lab3_CalebFontenot.class new file mode 100644 index 0000000000000000000000000000000000000000..fbd098b7909967054467c5789e6c8747acd98ca5 GIT binary patch literal 662 zcmX^0Z`VEs1_oOOWiAFL24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00SP6iGJPId+^9tLg(9u(!lmBl5gxr_|V`K2X{45B_@gEI5=1Bx>9N`gy@ zQWJBnIT-jD8F)NWb8_+(!t;xAQWUuu1Q-O_8H9Kkgc(E_8HBOuVq{=10GW}K$H*Y6 z0WlZsz~GXi%)E4K%`kQbF-8XS*CGf0&i zR23rwi*tTTDkB5GPi9`KUukYqYEejHQcfx(gOE>ta$-(cVo@fD4;5r7$;d2bWU%xh z(>`lP2A15!%sfU0F^yo;OBN@WUAjcrjz`&pYvXPNNj)8%JkwFn`s}cZ)L7Q&? literal 0 HcmV?d00001 diff --git a/Semester 2/Assignments/lab3_ChloeFontenot_old/target/classes/com/chloefontenot/lab3_chloefontenot/MyInteger.class b/Semester 2/Assignments/lab3_ChloeFontenot_old/target/classes/com/chloefontenot/lab3_chloefontenot/MyInteger.class new file mode 100644 index 0000000000000000000000000000000000000000..84802cddef10c01848b53e790a5ebf43bc7859fe GIT binary patch literal 2640 zcmX^0Z`VEs1_oP(QceaY24;2!79Ivx1~x_pz2y8{{p5_C{M5Akypq(s{1W|~#3bW* zR3YC=&%Bb<^wc6o2G+8~oYGWA21ZXV1`Y;Jb_OmU25tr(Mh1bb#Ii*FoW#6zegCAa z)Z`LI29EU966c)6;$lVyVGT_mgaWXjwGaaX10N3qKZ5`xgLrOYcB*rJUUFhdcxFk4 zbADcNNn&0}F(ZShh9|Pt;F6-uymV`j4yVo*l$ zDnt__13Nfa{L>g2)R4`DgoHI#BUKsH*csG$7&I6(85sl-fdda}j)KIZ;#AMP5>Oyu zI#kn>lR=w7hn+!}he3})AJtiv#U-h^j10{Ar6Ao9&6)Z70Y#a4CBY>{sfoGPppY`; zVK8DaW@O-jSp|(`jc8|0Pc8;i1~YaBa~=i@21`Z;VXzZX4Pj(pF8~>tlgG%wqTvY% zerr&?Sb~hVIkEC+37D7G;9?P(hZGjLc$2 z1_M%E!^psqkyxAov5N)7WMp7VEi6sU0Vh>RKqF-WYt1N7EF@)t+yM?iWJyK_*8GwT zP`2U?E=f$z_Dw8+x=+A2wIm}yB_OdVF*mg&wWyepfukfJmfA#6auY<*kO|6)S&R%SAf=GvBQvioKRZ<)VmG8ra7#=s$uFv8WSD`RyPygohI%CC zrR1a*tN7&SXO|XOV|oHf1Vv*=WkD(y<;ecTl8vE8I49=h1ZS3{T5~YuFfs_ieO?VN z4{RB0IT-R78JHLu85wvy^YT)Qz(rqbF*`#cBZDf2pRsv`ouQbKK@PuCMg}&BzZn!6 zm>4)17#J8Cm_Q{w0|Nsm10$$7WME`)V_;y=XJBMtWME)m)!M?qxQ2m&fr-JLfq{Vy zEGWj{!N9=417@=_crti_4f1A?fNHh{8_U4JD!^_djnE9r>I@7r49pC&U<1S$m_Rl_ z4Pa(qV(z{;S)z|Nq?z|Ek}z{{Y?Ai|82lLm7#JDk83Y*u8N3*n7=joW73N$22s|6Ss0-PiD+xE*$`LqgF}G<915%qOuPu+2Z9Z^gB#w+zzlYw9LR7RR$Ccq z)||x*g3>Ytvq16H!o;}z|2q~$3`sGtF)%RLF|ab&Gw?AuFo-ZXGKewQGsrNwfb9px z3_F7;Ll^@aI85ZAE@5SmWC#bR7*Nb`Gcf;UU}t3H`^CTtix-H?j2Mie-k!<81hz|0 zNYY2kS7)Ccvl)vhi|ir>2^~=u6EjwAQPy1y(hLkfEi8=7|G&`Q!63JTK?UJbF$PdT zx-&2{crb`Fcrqw3crd6jc*9*O&cMkK#t;EkrNH;_2@Vn|>}WMF_fE&=SFByd7ZW=H|G%NUp#QW+Q-vcY67Lp}p2=`k`C LFcdMAFh~LbUh^hn literal 0 HcmV?d00001 diff --git a/Semester 2/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/A.java b/Semester 2/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/A.java new file mode 100644 index 0000000..1975e86 --- /dev/null +++ b/Semester 2/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/A.java @@ -0,0 +1,32 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ +package com.chloefontenot.lab5_chloefontenot; + +/** + * + * @author chloe + */ +public class A { + public A() { System.out.println("A constructor was called"); } + public A(String msg) {System.out.println(msg);} + public A(String msg1, String msg2) { + this (msg1 + "; " + msg2); + System.out.println("A 2-parm constructor was called"); + } + public void instanceMethod1() { System.out.println("Instance method1 called from A"); } + public void instanceMethod2() { System.out.println("Instance method2 called from A"); } + public static void staticMethod() {System.out.println("Static method 2 called from A"); } +} + +class B extends A { + public B() {System.out.println("B constructor called");} + public B(String msg) + { + System.out.println("B constructor called"); + System.out.println(msg); + } + public void instanceMethod1() { System.out.println("Instance method1 called from B"); } + public void instanceMethod2() { System.out.println("Instance method2 called from B"); } + public static void staticMethod() {System.out.println("Static method 2 called from B"); } +} diff --git a/Semester 2/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/Person.java b/Semester 2/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/Person.java new file mode 100644 index 0000000..5ab7062 --- /dev/null +++ b/Semester 2/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/Person.java @@ -0,0 +1,198 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab5_chloefontenot; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; + +/** + * + * @author chloe + */ +public class Person { + //name, addresss, phone number, and email addresss + + private String name; + private String address; + private String phoneNumber; + private String email; + + public Person(String name, String address, String phoneNumber, String email) + { + this.name = name; + this.address = address; + this.phoneNumber = phoneNumber; + this.email = email; + } + + public String getEmailAddress() {return email;} + public void setEmailAddress(String email) {this.email = email;} + public String getPhoneNumber(){return phoneNumber;} + public void setPhoneNumber(String phoneNumber) {this.phoneNumber = phoneNumber;} + public String getAddress() {return address;} + public void setAddress(String address){ this.address = address;} + public String getName() {return name;} + public void setName(String name) {this.name = name;} + + @Override + public String toString() + { + return "Person{" + "name=" + name + '}'; + } + + public static void checkArrayList() { + Integer[] arr = {3, 1, 2, 3, 6, 3, 4, 6, 3}; + ArrayList list =new ArrayList(Arrays.asList(arr)); + System.out.println(list); + Object[] arr3 = list.toArray(); + for (int i = 0; i < 3; ++i) { + System.out.print(arr3[i] + " "); + } + System.out.println("max is " + Collections.max(list)); + System.out.println(); + + } + + public static void ArrayListGeneric() { + ArrayList returnList = new ArrayList(); + returnList.add(new Person("John Wayne", "123 Sunny Dr. Santa Barabara, 90611", "922-337-3231", "jw@gmail.com")); + returnList.add(new Date()); + returnList.add(new String("Hello, I am a string object.")); + returnList.add(new Employee("123", 1234567, new Date(), "Mary Poppins", "123 Blake Drive, Lafayette, LA, 70506", "337-123-4567", "mp@gmail.com")); + // Print objects in ArrayList + for (Object o: returnList) { + System.out.println(o); + } + + } + + public static ArrayList removeDuplicate(ArrayList list) { + //list.contains(); + //list.remove(); + System.out.println(list); + ArrayList newList = new ArrayList<>(); + for (int i = 0; i < list.size(); ++i) { + if (!newList.contains(list.get(i))) { + newList.add(list.get(i)); + } + } + return newList; + } + + public static void main(String[] args) + { + Integer[] arr = {3, 1, 2, 3, 6, 3, 4, 6, 3}; + ArrayList list2 =new ArrayList<>(Arrays.asList(arr)); + System.out.println(removeDuplicate(list2)); + ArrayListGeneric(); + + ArrayList list = new ArrayList(); + list.add(new Person("John Wayne", "123 Sunny Dr. Santa Barabara, 90611", "922-337-3231", "jw@gmail.com")); + list.add(new Date()); + list.add("This is a string"); + list.add(new String("This is another string")); + list.add(new Employee("123", 1234567, new Date(), "Mary Poppins", "123 Blake Drive, Lafayette, LA, 70506", "337-123-4567", "mp@gmail.com")); + for (int i = 0; i < list.size(); ++i) { + System.out.println(list.get(i)); + } + + } +} +class Student extends Person { + + private Status status; + public Status getStatus() {return status;} + public void setStatus(Status status) {this.status = status;} + + public Student(Status status, String name, String address, String phoneNumber, String email) + { + super(name, address, phoneNumber, email); + this.status = status; + } + + @Override + public String toString() {return super.toString() + "Student{" + "Status=" + this.status + '}';} +} +class Employee extends Person { + // office, salary, and data hired + private String office; + private double salary; + private Date dateHired; + + public Employee(String office, double salary, Date dateHired, String name, String address, String phoneNumber, String email) + { + super(name, address, phoneNumber, email); + this.office = office; + this.salary = salary; + this.dateHired = dateHired; + } + + + + public Date getDateHired() {return dateHired;} + public double getSalary() {return salary;} + public void setSalary(double salary) {this.salary = salary;} + public String getOffice() {return office;} + public void setOffice(String office) {this.office = office;} + + @Override + public String toString() {return super.toString() + ", Employee{" + "Office=" + this.office + ", Salary=" + this.salary + ", dateHired=" +this.dateHired + '}';} +} +class Faculty extends Employee { + + private String officeHours; + private int rank; + + public Faculty(String officeHours, int rank, String office, double salary, Date dateHired, String name, String address, String phoneNumber, String email) + { + super(office, salary, dateHired, name, address, phoneNumber, email); + this.officeHours = officeHours; + this.rank = rank; + } + + + + public int getRank(){return rank;} + public void setRank(int rank) {this.rank = rank;} + public String getOfficeHours() {return officeHours;} + public void setOfficeHours(String officeHours) {this.officeHours = officeHours;} + + @Override + public String toString() {return "Faculty{name=" + this.getName() + ", " +"rank=" + rank + '}';} + +} +class Staff extends Employee { + + private String title; + + public Staff(String title, String office, double salary, Date dateHired, String name, String address, String phoneNumber, String email) + { + super(office, salary, dateHired, name, address, phoneNumber, email); + this.title = title; + } + + + + public String getTitle() {return title;} + public void setTitle(String title) {this.title = title;} + + @Override + public String toString() {return "Staff{name=" + this.getName() + ", " +"title=" + title + '}';} +} +class Status { + + final private String status; + public Status(String status) { this.status = status;} + public String getStatus() + { + return status; + } + + @Override + public String toString() {return "Status{" + "status=" + status + '}';} + +} \ No newline at end of file diff --git a/Semester 2/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/lab5_CalebFontenot.java b/Semester 2/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/lab5_CalebFontenot.java new file mode 100644 index 0000000..5a2e690 --- /dev/null +++ b/Semester 2/Assignments/lab4_ChloeFontenot/src/main/java/com/chloefontenot/lab5_chloefontenot/lab5_CalebFontenot.java @@ -0,0 +1,38 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab5_chloefontenot; + +/** + * + * @author chloe + */ +public class lab5_ChloeFontenot { + public static void main(String[] args) + { + //B b = new B("hi"); + //A a = new A("msg1: The 2-parm constructor of A uses \"this\"", + // "msg2: to call the 1-parm constructor of A "); + //A a1 = new A(); + //B b1 = new B(); + //a.instanceMethod1(); + //a.instanceMethod2(); + //A.staticMethod(); + + //b.instanceMethod1(); + //b.instanceMethod2(); + //B.staticMethod(); + + //A a3 = new B(); + //a3.instanceMethod1(); + + //testPolymorphism(a1); + //testPolymorphism(b1); + + B b2 = (B) new A(); + } + public static void testPolymorphism(A a) { + a.instanceMethod1(); + } +} diff --git a/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/src/main/java/com/chloefontenot/lab4_chloefontenot/Circle.java b/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/src/main/java/com/chloefontenot/lab4_chloefontenot/Circle.java new file mode 100644 index 0000000..2863c37 --- /dev/null +++ b/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/src/main/java/com/chloefontenot/lab4_chloefontenot/Circle.java @@ -0,0 +1,51 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab4_chloefontenot; + +/** + * + * @author chloe + */ +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 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/src/main/java/com/chloefontenot/lab4_chloefontenot/GeometricObject.java b/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/src/main/java/com/chloefontenot/lab4_chloefontenot/GeometricObject.java new file mode 100644 index 0000000..48d65d8 --- /dev/null +++ b/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/src/main/java/com/chloefontenot/lab4_chloefontenot/GeometricObject.java @@ -0,0 +1,65 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab4_chloefontenot; + +/** + * + * @author chloe + */ +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 "GeometricObject{" + "color=" + color + ", filled=" + filled + ", dateCreated=" + dateCreated + '}'; + } + + /** Abstract method getArea */ + public abstract double getArea(); + + /** Abstract method getPerimeter */ + public abstract double getPerimeter(); +} diff --git a/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/src/main/java/com/chloefontenot/lab4_chloefontenot/Lab4_CalebFontenot.java b/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/src/main/java/com/chloefontenot/lab4_chloefontenot/Lab4_CalebFontenot.java new file mode 100644 index 0000000..6c6e452 --- /dev/null +++ b/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/src/main/java/com/chloefontenot/lab4_chloefontenot/Lab4_CalebFontenot.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package com.chloefontenot.lab4_chloefontenot; + +/** + * + * @author chloe + */ +public class Lab4_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/src/main/java/com/chloefontenot/lab4_chloefontenot/Rectangle.java b/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/src/main/java/com/chloefontenot/lab4_chloefontenot/Rectangle.java new file mode 100644 index 0000000..f8dd7be --- /dev/null +++ b/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/src/main/java/com/chloefontenot/lab4_chloefontenot/Rectangle.java @@ -0,0 +1,52 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab4_chloefontenot; + +/** + * + * @author chloe + */ +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); + } +} \ No newline at end of file diff --git a/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/src/main/java/com/chloefontenot/lab4_chloefontenot/TestCircleRectangle.java b/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/src/main/java/com/chloefontenot/lab4_chloefontenot/TestCircleRectangle.java new file mode 100644 index 0000000..66930fc --- /dev/null +++ b/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/src/main/java/com/chloefontenot/lab4_chloefontenot/TestCircleRectangle.java @@ -0,0 +1,48 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab4_chloefontenot; + +/** + * + * @author chloe + */ +public class TestCircleRectangle { + public static void main(String[] args) { + Circle circle = new Circle(1); + System.out.println(circle); + /* + CircleFromSimpleGeometricObject circle = + new CircleFromSimpleGeometricObject(1); + System.out.println("A circle " + circle.toString()); + System.out.println("The color is " + circle.getColor()); + System.out.println("The radius is " + circle.getRadius()); + System.out.println("The area is " + circle.getArea()); + System.out.println("The diameter is " + circle.getDiameter()); + + RectangleFromSimpleGeometricObject rectangle = + new RectangleFromSimpleGeometricObject(2, 4); + System.out.println("\nA rectangle " + rectangle.toString()); + System.out.println("The area is " + rectangle.getArea()); + System.out.println("The perimeter is " + + rectangle.getPerimeter()); + */ +} + + + + class Apple extends Fruit { + +} + + class Fruit { + public Fruit () {} + public Fruit(String name) { + System.out.println("Fruit's constructior is invoked."); + } + } + +} + + diff --git a/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/target/classes/com/chloefontenot/lab4_chloefontenot/Circle.class b/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/target/classes/com/chloefontenot/lab4_chloefontenot/Circle.class new file mode 100644 index 0000000000000000000000000000000000000000..41b3e639a17029ac5e49d961a230ddae9bdb5eb5 GIT binary patch literal 1518 zcmX^0Z`VEs1_l!bcP<7d24;2!79Ivx1~x_pljQtd{p5_C{M5Akypq(s{1W|~#3Yk= zR3Z1&{M^)%qReFfq^#8B5=I6#o6Nk-5<5l)W)00SP6iGJPId+^9tLg(9!3UjqKtIT zEK1HvWn^G0N=(TtEoNk3bYW-UV`SjVN-Rs%&q>Tn*Y`~<$zXHfRQw&{qAS7XzyJZ9 z3?dAo>C4 z2V|r!BZG{F3)D&^=Of%I$)L}}V8CF=$iPvO4+$$q1`(Jmk+fKIF&HzLurrwQFqkoz zGcpK+gBUgN85!6MKv9vC$H*XxEzrUk8Cab2Q&Jfj_k%6-qA;O-X zTH;ugn#jn&4T`4B#N5=9)FMU(p7hj`fYhQ)D3=@TC0J_a3eGPrN=|jl1UZ=-BB}=p z3I;_64hAL$1_nk3CQvqEU|`^2U4V> z7#Kj=m4ShefrWve!HR)_fd`_9!J5GaY#1wpEz|%v24)6kkPeUmTIyRF*b%1ifn@|4 zSQvyDI2nY&CW(Qa!v!@7WD_^obVdd{279QP`V34E`?R(&u&;+ZiVZ9%4mJkeK@M;S z*+Ct|hUOTEmt+`N8DzmGKpesbcL*Ced_bY$2zQ7D0}I$rK9EB|I9r5)KO5aeieU2~ zF5-il$H?FWH^mrg3a1EzAlMLe1JsZV;Dj6C3^%|WY5*_H0Bo+%MlysKZiov5DAYhP z9S$`_a}$H`ZU)K7?F`aFGTRvBw6-xQZDUXq(gd-$FtBf9(B8(Nw~fIF5s#3dGhonQ PFha6K6K;tsIEvf=7gZ`t literal 0 HcmV?d00001 diff --git a/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/target/classes/com/chloefontenot/lab4_chloefontenot/GeometricObject.class b/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/target/classes/com/chloefontenot/lab4_chloefontenot/GeometricObject.class new file mode 100644 index 0000000000000000000000000000000000000000..3752da8191ec3b1b78ebc92e1322ec5b94984fc2 GIT binary patch literal 1649 zcmX^0Z`VEs1_l!b4=x5K24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00S4h9ZJ2G;V7%#u`21}+9}b_O0E23`g}Mh27Q{9OIyjGX+`wEVo1)V%x> z{hY)klXz4i_tgB{)RLmiWSHr!$@w|?MT`tWJ_wtGONuh{(yiGU1Q;3kz`~^^nK}9{ zi6yCA4EzktAe)7G7(^IE85y`!5=&B@i&7IyQd1Zi1R$osm0N?9it{i?Fi0{ou%%_@ zrlFG=y?~|FA>Q|bZlv)&$n3R(Wisby{#GJ6iqD&AUD#%ijky*^hVCF+k0@jHCC-r4#Ze4riega?R-IYw22CH#8k$jz44lQOB`^^d4X}xP>8T~4 zR0vORLa+cpq&P+f_Vm;e$D-6kaE@_dWZ+3pEeS|1%FInINiAYz;0n$!ElN&x%LIjp z2wDo$1Eon8MFvo|WME)sU;1_lNuP!a~yA`GGo3=CWhET9a_z{p_2z`)?cz|6qN zz`!7;wVi=cONf0d1E zm@zOg@IZ7km@`-~Fn~?AgqmE$z|6qRz`&q@)nqMgkWDgM8N?8FNHMU1TmrR2oI#X9 zf8eFjFb+gP=>FmP^wdxQ-v zCFT6|f0n5LHkU7#P@~PGV%R zWw3*qh3pWqHE0ge1RI0y5PJp(sAhyiq*1~O;t)LsRt9~r378I%V2}idfFpww)GTC& z2%(3FG1wS%hZw8H$!=qi2L9N`gy@ zQWJBnIT-jD8F)NWb8_+(!t;xAQWUuu1Q-O_8H9Kkgc(E_8HBOuVq{=10GW}K$H*Y6 z0WlZsz~GXi%)E4K%`kQbF-8XS*CGf0&i zR23rwi*tTTDkB5GPi9`KUukYqYEejHQcfx(gOE>ta$-(cVo@fD4;5r7$;d2bWU%xh z(>`lP2A15!%sfU0F^yIkEC+37D7G;9?P(hZGjLc$21_K|`oMX+%z^dWmq8Y}>z>%I> z5)N@1vxcS%BLhb%QjC^^+F6Xb3_cp&IyC6*;JC^B#`FflMNFflNJf)dQ)XW(IAVBlb21jQEv zBZCkF1A{RGBLgD?0|Tqpb_T|cU}eG#3=E*CWnkcEU||qo5Mf|o;DIP&5M>Z!U;rB+ z4mBW>fti7ofq{V^WPq0XRt9!0&8-Z)2&04;SQr=>K%_7OCxZwBAA=~^NCgIFkT$51 zAj`O+*6@R3je(hgkwJn%5^9Y;0~5pvT3Z;{*Tdb(1{RbA8;I^kDF$h%W;+IEuw`su z_aU4H@ueICD}y}P1Tk=svB90h1`aw<0Lfr=2rs%rl)=WJJ46<{Ly*D<;t&l6Rt8P5 z378H6#U02Ya&U*3FtC6<&jkt*tt||^+32p(1)BwN4Hwi?j12N{6D$}Y!N(`UAOJHY U8N(DKBvU|f2T1@5;3!Z806`~}l>h($ literal 0 HcmV?d00001 diff --git a/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/target/classes/com/chloefontenot/lab4_chloefontenot/TestCircleRectangle$Apple.class b/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/target/classes/com/chloefontenot/lab4_chloefontenot/TestCircleRectangle$Apple.class new file mode 100644 index 0000000000000000000000000000000000000000..079dc414d4f889b7b365348303419138ebfb3ecf GIT binary patch literal 693 zcmX^0Z`VEs1_l!bNlpeP24;2!79Ivx1~x_pyX5>_{p5_C{M5Akypq(s{1W|~#3Yk= zRH2a6;u7b~qU4;^pw#4&#Ju#JR29d9f}B)F2DXxn%wiP-Mg}V%a*eX)V&GulWM|;w zVc=%qp~OvYMWvY~j0|ixnR%Hdc8mH6sI8aDHh~a;jS<$Sw&ip|6*fSeD4h zz~h;hms;eUlUQ7wTFlNM#>iknZX_@=utH;$6T3JgpP91IK$i~<6nqyl0wFn}V6 zfsuiifq}uEfr)_$B%-Cgm4Q)9dpiUBMg|53CI&tR1_m|;Mg|53Wd?o*1_m*RG6n$# oK?V@u1{=r7z{DT~RxivT!oa{F1U62TL7ahsfrCMmL4tt+07YZM1poj5 literal 0 HcmV?d00001 diff --git a/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/target/classes/com/chloefontenot/lab4_chloefontenot/TestCircleRectangle$Fruit.class b/Semester 2/Assignments/lab4_ChloeFontenot_oldGoshDarnitMarkouREEE/target/classes/com/chloefontenot/lab4_chloefontenot/TestCircleRectangle$Fruit.class new file mode 100644 index 0000000000000000000000000000000000000000..b1a42fdfbf7ff933dbe24249a780ef1ee7079ec8 GIT binary patch literal 1017 zcmX^0Z`VEs1_l!bElvg|24;2!79Ivx1~x_pyX5>_{p5_C{M5Akypq(s{1W|~#3Yk= zRH2a6;u7b~qU4;^pw#4&#Ju#JR28?P(##S@2DXxn%wiP-Mg}V%a*eX)V&GulWM|;w zVc=%qVPp`Tn*Y{7#N=*jYVw0JdSz^b?z^tJe#>v3Pz|YPgz{4QOAcUek zxU#q;HJ6crIlr`okwMf4Y*1#ten3%XUP*9CQEFnYH3x$TBZC6i_3Fh6$@zK3B}Jvl zC7Jm}3Yo0m11mTQFeorEF>o+2Ffa-TfN}%_0|OHS zBLg>sGy@}p3a#Xocz?Z{JfIXy!;aVoWvxPcvK1{ z+>8t?8ZMe)oD94SeC!PTJPZO1f+!XSR~DC~<}xxc=a-f+GKl(sosyZaA5fH;R}x%O zl$w}p&BY+hAi~Zd%EKVWAkN4jj71G21A75TM@}9igQy0?6eJH>gFGS0$Y4Q~Cqhz- zOCTNzN=+_F%uCNnWn^G+&QD2YWZ?J7%uDqv%}q)z3Q0@?NeKDmCnx5FB^G6Z_)tNX zl8nq^Mg}V%axJuGWMIin%*2DW5y zOfWL&66XYnf2|oAxPtRbi;`2_GC_Wmz!DUCpx|d@;PK4MOD%HFNh~f-EoNuXWMr@- z*RLvWMWvY~j0~(`nw>$160;l&3P3Jr1=9?Q3=#}X3?RV7zz9n142%p?3=9nV42%qn z3=9mcTH6^IH!?6VFfm9oFfg!z1-Thy7#J9Mz-(3qSq3=<1_n+Bc?JcjW?u#tu%Uvx z8Q3HFw=;11Y+~Ti-o_w=Fo=(VnSp_Umw}Ukk3oPz9&Df(L=%G|gA&+44hCfg6$VBI iCI(fo1JoGQ85kIZ7?>C|7$g|97#J9|86+5V85jT);P&kR literal 0 HcmV?d00001 diff --git a/Semester 2/Assignments/lab5_ChloeFontenot__/target/classes/com/chloefontenot/lab5_chloefontenot/A.class b/Semester 2/Assignments/lab5_ChloeFontenot__/target/classes/com/chloefontenot/lab5_chloefontenot/A.class new file mode 100644 index 0000000000000000000000000000000000000000..b2978aabfbf44a0c49975d86c68bdb68e2453459 GIT binary patch literal 1332 zcmX^0Z`VEs1_l!bJ1zz$24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00SP6iGJPId+^9tLg(9u(!lmBl5gxr_|V`K2X{45B_@gEI5=1Bx>9N`gy@ zQWJBnIT-jD86+GPlJoP5ONvU9OY(~p$`gwfk`r@sQd77X1Q-O_8H9Kkgc(E_8HBNz zz{tQ}05UHpkC8!C17Zi*vB4!pnR)5fnqlk=VvG#pV68|JPNkVSDXB$V45AFoAVQLd zL5e||k%29-pdd9bg^@uQn_(E{LyfWKV31{GV6s*K870rdpunKW$iPvO4{-z|gNTME zhE{7X24w~nb_P{YK#MRks3qs;>L+L9Cl94hBs|2072X;*!L?{?ViVVsO zObj5v#=r>5LJW)ydJGH<<_t^>j0_A6yjt5C7&kGn3-NAa;NQr=z`(?y&%nR{Qp~`> z&0xU5z`z4h$Y97|#J~VHM1+9}Y={E`6WDMbs3F=|%-{i=AqG(gH3MX(F@p&MBZDae z0|P4~gE7=#GpNB?49pD73=9k^TDuuUBeye%Yj0za5R%!(AfdC3L1G(&+;#>fkfYU5 zEaU_0;bV|y;Ac=~5CB`O02Wh$Tdcxh4z`$qL50DB!GwVc>;z6G26F}m1`Dt=EWy49 z1(Go|kT^khX`t8z2_QkR9gqOxgxbN#V1?ZPEi48IVKIP{!5VIWA~@U_7{D&jff~Sw P6h*=ej0`s5XtM|4hBwk1}+{3ZU!Dk27#=^vPAuy#JqI<;L75X)Lcde z=KRtUMg~zIuuNvYen3%XUP*9CQEFnYH3tJ9BZG*OLUMjyaY<2Wa!G!XLULkGPHGAl zg8+jdJA)7pgD`^#BZDv&-HZ(E1t7C>@)#LJH6Z3gY%VFv%uBb{4C7!BV`Px?%quQQ z%u7yH$W1ND$WJkZ+MtkDl%K2M#K9nesm2IhjT9q;Y;Z|pNoF$C6a_RT>10#b90|NsqBZCsy zGF7lsKrS|hx|kE>T2T}mAg+}Kn+kC)C)89%1~u#kh+{E84vPVt4C-(L6u}N=U;w*7 T5^4Y=Qh3QTFfwR>!%!0d(s0Va literal 0 HcmV?d00001 diff --git a/Semester 2/Assignments/lab5_ChloeFontenot__/target/classes/com/chloefontenot/lab5_chloefontenot/Employee.class b/Semester 2/Assignments/lab5_ChloeFontenot__/target/classes/com/chloefontenot/lab5_chloefontenot/Employee.class new file mode 100644 index 0000000000000000000000000000000000000000..e62e83b35a951885ef350e8b6b27b8ea5f6eb904 GIT binary patch literal 1635 zcmX^0Z`VEs1_l!bJ1zz$24;2!79Ivx1~x_p?d1Gi{p5_C{M5Akypq(s{1W|~#3a*r zRH1;>qT>8KMg}&U%)HDJJ4Oa?4WF#UvPAuy#JqI<;F6-uymV{wL^Q)V88{d?*%`Qa z7`PdD7#Vbla*=CpK~8>UYAPcGTYg$vW^yVcgAk?zKt}WNFz_=7Ffy8kL>L)3QxZ#3Ju-_@Qy3WpASRTSWaj9*B$lLFvonY>GKi!5)TuNxCndFr zi$Rn@0u+prj10^gnqi=jmF8iPVUT5H;3&z5gbE{rh=wM_Smdw*>6PbUP+(AGWME4y zC`ipqVPw$75~!GZp|)FdFeo!JaKgf&8f2m>$V4?p1{n=!-1B7jsS&R^2(QpCz6r{)> znkYfiFt#X`AP1@E3eGPrN=|jl1ce4SB(Ld#5*>pA0|x^W0|Nsy0~087FfcGMff6&A z7G@A(U|?WpU}Rur&|qL<&}3j>n9IP*z{$YCAgd+GD#<3vF3GW-fl*6)D+9Zh##RPi zElHNG41ycM+O-%M7{nM@85kH!7;83Y;17{nOL8DtnL7_=D}7=jo$Kn5}BFz7OX zfGpSnj9@W-1_7|MWIFw2mEhk=8^2*hS* z;AUW8;Adc95N2Rt&|_d=&}U#^FkoO{Fl1n0U}P|6FkxT>`$nIEkpW~OtJW3#0vst08WMnX9FoSDmg2-uYVc=blrnwfYW^)D$XgFFiFf%YSFfg!bsc&WA zMFbec>N>D)F>nyDL9J$BU<1btBiNIyj9?EkGFURm!rg=L3_H4K>cJ+Wd&Y{v8txt@ zh;87wM0ZaESU0A7xEVkuf&!hD5gh1@pu!329ybO^_{i*L5RKfgf}H%y)Ko?WHk-`6%o00BhCB_Qti-ZJ{hY+Sbp7CxqRhN>YZr)6X-Q^|zDr_B zsx^d|4hBwk1}+{3ZU!Dk1|6cD?UtBanp0BA$iSVSmX?{E>XBbsRLsaA zgy{&7@q9cC{0st&3@k;7dD)B%jGpWaLW~UJ=)QC+&CE$jE#hJjWDo%bq9`K+vxa6E z2ZJ~x125FZ>b%6*xyJPdLS z@{A1Z>8T}tiMgqa3?dqsI;=Su6d4)Vbre9Z2V1QSvRZ|aK}N$9Q#rx{K?XIDLUoWr zXZ#8^c^I@nF5xK2hr~D|Ln9XNcw%^mmMMdgfyFsLC6$qZ-zPIK)vq)+DYYmhF)1e% z6w&#~i8*13MVTNzRFI`4BeR&1LC=SjBxKFVzy?V}j0|kWi8+Zym5dCGE{qJEDTyVi z9+^d{DU1vP5Pu_*KO+MRC?PO1uqURZ6r~myGcs@&WaPtK$;iN(nwyxJ!^j}un_7~Q zpAwK*l$e`Zk_t+spx6!qCq!lqO;1J!_TtnM2%km6Q!|W_fiFF^#2-0X^A)2Bh+>Hw zkWQ}P{L-T2RJTk}7;y)r78U2`>4B0tg8~Bw0}}%S0}}%iD4&5@{0ssN3=C`xj0~&{ z+6+t#It&a9YZy2gxEUB2WVCc8SR~mb*(Et7IVHKaGcamtZ)ITDlG)0@yAiBgmw|yn zh=GNHfuV;%kfE1BjG>P~nxUUTkAZ<9je!ef27^9>0RsrgfbC=ii-BwfxkQG+kb#GR z87yYRU<@`%hQWlvlz|N_X2!t7zz$}aGw?8QfLRs{JPe#*mL&rZ0~do80|SF9#KHUw z3=D=03=Br#!jOT%jDdl{oPmMCf`Ng-l7WGNk-?h5hJg|6Nqq)J29RS|wYD(uu7Udo z6cP*!lfgdVfhd6bfRVwL!44WiR^TvXU|`ddMhOdu?kQm1V&Jf5gX#u_G04}9VE3{z zGJxF5$Y9SPkHtOg8_?V{6>K89dmI=XG28=+AVl0i+%pZV8`C}93?LIh;m67dj&Md$ z0RVMR5Cap~`x?6$1S7XI2n&gAW026=#vrqeK|)9Y#NNWdyNy9fpmrOB>NW-qbSKXQ UTMDv(fk6Wr2#gF)V2?Qi06E!eg#Z8m literal 0 HcmV?d00001 diff --git a/Semester 2/Assignments/lab5_ChloeFontenot__/target/classes/com/chloefontenot/lab5_chloefontenot/Person.class b/Semester 2/Assignments/lab5_ChloeFontenot__/target/classes/com/chloefontenot/lab5_chloefontenot/Person.class new file mode 100644 index 0000000000000000000000000000000000000000..21f7f1debc42dda5f4b888c305a2b1efab21fe08 GIT binary patch literal 4515 zcmX^0Z`VEs1_l#`qg)J349x5dEIbUX3~Y=H0$GV=iTXK-dFlH8Nm;4MC5#MgHko;u zC3cJq%o>_uoD3Wcoa_u-JPh0nJd6z5$@#hZ$r(BMscHFnC8>G&CHgsuNv83rLIJ5o z#rb)R3@mwxxv7i{LOuvff=h}r^U|$B#`5tn@Po``PfSTEN-Zu1i3##B2!X`73o`Qa zQvFJElTwR7;vzf@q9AeB)ZE0(9CikAMh0Yjy^8Mg~EIUp(_lQqw`cP-D>KVbEgGW@KP5OUx-v^-p7D5YzBP zHUg^Fnw>$HkwF-2MrlcAj=p12QDUV}W^oA@gFb@+JA)w)gAs!4a{0_8Vjy0E=kR0WMIxOEn#F3h1i&xuOCp9nO72AQk0sQYt6-A$6(LS;K0M+ z$lwI?7pfXY2KEAwj+{J322rRpz~;l;9R_l!3lD=UgBv3Qdr3YxL_lgavG@`cuO6Uy z^+Zb%Fw-E;1X}=!OIV8FVDM&SU{nCP*q4XFkHMdjffej9kX0DEtTn?p7y=m?*mDyr z6f%nyxEO*NLf9EXc^JYN!WkJv5fO+8&0zMg}dYH!(sR$r`A8LC%Q;g`Pi% z6%Assfx?3sM8xqh#4{u?GO!e9R;7aTxF<+BiH9MXA%&5FIXx8=F{tSbZmteP8V^G{ zLk1%QM{<5%Nn&PRF`7@IN;RWEhGy|FWP=nlC#IxuF>o;C@-XBv#f%KfhDOE;!KHb5 zl?pCJdJ4gbc_oPoPKiZ{Nr^>?ItrEsW`>3w45f?=JeEdAy2i%ly2eJvh8zs#j0`+k zB=~Vr1}!x(X@gt&xHok`{;((F|i}s9|K_LqxGlVo53&Lp7+V zs%K;n2+7DS2BnEag<^0C$8PV%ZeVI)#=$U=k%0#k$c9G7x+bP( z<{S)@85wwT3y=f4jbSRtz0(*O@~{N73nZk$=^YeUM1?a%5B~T9#l;Lp1}Sh{fRzT7 z=9OgTrn*)nrxt*UFb;-Uj0`rRdCB>?1(`XCNja$s$@wX%3c3opnZ?DKdFcwdsU;ct zDGEvXDU~`3`9%sTsmVEsMX3sjNyQ~aiOD5g4AU7}85vld^HWk88TfrNVU<}3$TU!u zn4g@O6P8$%3F1QqSxPc8iy0YoeTa%WNabeD$ROYgc1%EGQDSatNor9sBLjbWYKbc- zMLR;ORz?Q?VssI{^wg37L@mq6z*meWz?Gg_0yluG7>UE4o?7AuuG`s*VJyDnjMU_8 zcrImRV9aD>VDw~UU`{M5Vq_3OE_h)T7b62pPG&Kvz=1>@II`hJSTi!PBo-AJGcpJx zYlapvj0|EvD1lg6kO~b*Eo`RQKm@@N4zu6RnvsDwxFj(-+c&WQteKr*9XrD&Mg{@6 zE8J7_Qj0Q^85!8~Qp-W55+eg=aAta5Vo7OHDkDP}H0h!`9lK>%i!85vk|6EpKb zRX(!cp+$~n7&vIsi_wAxD$U5i3JO*uc82|o3>-GeInV|jS8#r5QF5wVW=<+212-fA z>4CBVgCYY50}}%S0}BHasG-Nez`z7*oPlW}1|Bdi3a0rP7#Ua@su-9U<}ffYG%zqR zure?(NNH_nVARsy%D}Frvz38YOLr@SfR-f7RtDjXV7+reY8coU7#JiOSQw-jI2oiF z_!wjugc)QRBpKuw=7AfhV3Qc;Gb{iVKnzk~moS2L@-y&&-6sWV9x^b4#X#<1VOYq( zz#z!Nz|FwGz|X+IAjH7HAj-hNz{s$OL6w0K>_~kEMh1{EtXf+bgg3z5!v+>q0Nc$2 zX0t-=W@K2*;1Bho6$2C4W;T%TkbDEttq9gF22lak&A`A0YOFFag5Ac-2zAdAtnLv& zcaIX-M0EEo#qJ&fMCd}?qYT!K=^juV!rcQ3BSwa0Slz>m?j9AeiRkWGj@>=H=&A2sC_drt0mU05!wRhKVMlk58rVd1_pHS39(Hv1sDpK5x`&$qWFjanu`+_w5+kVf z4oyF93{2qUA+wu7EOI-8gplMm25GG=4D8z&qy=iXG01OYP(pX64%i})p$rT%(1gLs zu!;c`O>-C+7~L6I7+4q>7}g4K?qyJmWMTGTX_rEn-mF#9$6}zmBZYHU@Vg zuWby{+ZdF#G5EAFGcNys7ok8XU>k$9_6~-iZ4B;U6%m^l%(pQ_fkKmo0hE`u7`PZ1 z7z`M^7z`Q07>pQV8H^c{7)%&48B7^k7)%(t7|a=#F<3CHVXy)Rgcbt}Lkfc$!)k^# z49pB(49N^@8P+i{fEvCG>lrpMFft@Dcr$Ed*u=oZu$h4Y92;Q_;SB2;wlFXn=D!Sr>=X{1wutaB|>G}87e>_rMsJ< zI&wQhEtoA-2c~v2G(-wDZD(kK^4cPWIz$+{peluWg!+Ug2u<3~Fa;#fY{nwWq6>}> z(M=5Ix}q%LD6wr}VO;+I1tP7PG4L`lF!(ZfG59frG59kiFa$DWFa$BwFa$GnFoZDl zGlVkCWe8)~%Mi|Rk|BcODnmHKZH8!Y%$P8+G8|x#2FDC2yWL^f$FQG)fx(Mm5;z4i zGK4X-F&tpnz`(?i!B7H@H)f<12$I{vzywZ#lAsiLfPs~r;UFv#>VOlW6fC|#Lo6H& rhhUkUK?$4+85p>BGfa;Znz@}}Hpp&9a1H_$1fXh)k>M~nhK~RMZsrx& literal 0 HcmV?d00001 diff --git a/Semester 2/Assignments/lab5_ChloeFontenot__/target/classes/com/chloefontenot/lab5_chloefontenot/Staff.class b/Semester 2/Assignments/lab5_ChloeFontenot__/target/classes/com/chloefontenot/lab5_chloefontenot/Staff.class new file mode 100644 index 0000000000000000000000000000000000000000..76a0c886b5ae4a1582936959e732f84f033e50be GIT binary patch literal 1418 zcmX^0Z`VEs1_l!bOD+Z`24;2!79Ivx1~x_p-Q@gS{p5_C{M5Akypq(s{1W|~#3a*r zR3X>gf}H%y)Ko?WHk-`6%o00BhCB_Qti-ZJ{hY+Sbp7CxqRhN>YZr)6X-Q^|zDr_B zsx^d|4hBwk1}+{3ZU!Dk1}&nT9bA%_md41yT9R3klgh{-glRcD10N%U zIJ!riN;7j(Qj544co_sh;Uvh&z^tJe#=#)W$iNLYv^p;_H`NxTK$M3;j6s}{fi1D1 zAT=+AkwF(rz-VIF47I|Vi-Chdl7~TxL7I_)Jw3I=FEKZjkwHWQQ-?JNgDfKhhmHc+ zH(<>04OpCs;YwP@C?f-lbAC!HBLlxr zW?rgaX>L+#QAlDEB%<<@6LZ26i!wocs31#8MrJW1gN_gJQE$!2z?PqumYEDnxW$P% ziA9x+42&*}44f&6C8-{nMX4!_3<3~eBN8nm0}Cj285!6UQ&Ngji;Ecol2wvTl3kKRl5;x)qn7qo2KJ2%3=B*RY77hvd<@JC3=E4H1Q-@Gh%zi; zP-kFZh+*Ia>15Dg&}0AsF|ZAcU@@tYBGv1|9}BFw1~} zhk+f;GGyRk-~h9X7s8H^bi7!)}exEUB2v=|r|v>6x}bQu^J^cff!3>X*~3>g?0 zjKCfA-OR{f%3uZ!2`dIBu#4Hy zd=AmQ60BPcq5`U$fq@O`V~|@}8NqI41Z5DYdx994z}9K(X5fw7&cH7uw2eVTYa4^a rHU<$P84!C51N$}x5rNum4078T6w#f$25c$B$r?~g85zvM9jw3W?s5AI|CmhgE+ddQ)y;SN@@`o11|$J2ZJCZ10Te!YKTd; zAPHd}1`!5PMh3RTf`Zh%6h;PJ4NT)TF@&H-TZ4=c2N@y3$RMNPj9;M?4}&y=3?lVm<-^jqgz{DWWz`(%9z{tSBu#rK5fq_8`qKZM0L5TqbxWJ|{GAJ`J zFt9Q*aD%N-VUS^91RJZ*zzEjNso+&vNLe;FmN;QFfwQpr8gk8s5n25 zk%7%7GcU8mj*-Dz!zU}TEKxrvF)v*|xTGjEFWs6v5zR1m20lgxadhLHN;7j(Qj544 zco_shZWUx?VAjwK136!qhe3ovl#zj>Bp+fmBZG*BCZ_cuz2ZC!5)6`z3~Y%71*v%{ zj10P1T#l(1YP&TDgES)p2QDkFoCPkwS@PFP}5CWsFeWGTtWEM{cTBi0gd zDzau|;4DVC(LjS(-Qc988OF#U;G0^Kk)INfSd^HXT9R5+%*aqdnkks^MxF@BH7t3F zx!?doPfga04D5+1DMhKp#f%Kx1sVCUAZ27=P0dZr%wc5U3eGPrN=|jl1O+iSB*p82 z%wbSqU}E54U|?WmU;^b-1_lNe21W)221N!&1|KCogBH}t5~wQ$v~+YOStMDvGq9r>&d0#az`&5oz{QZpz|W8l zw#1Hsje&td0B(r@*c6bz1Q@g#bihs!V9;gI0qYfD&|}bHU;*pUXV76_WdJ!wlojk4 zZ3YGgT?PgQJ#gTF0#1ZM6dG7=3{2p#klD?^8@Zi7-Y6F X$fJj07TAH1FqDBhkdeUv99D(^c*aHf literal 0 HcmV?d00001 diff --git a/Semester 2/Assignments/lab5_ChloeFontenot__/target/classes/com/chloefontenot/lab5_chloefontenot/lab5_CalebFontenot.class b/Semester 2/Assignments/lab5_ChloeFontenot__/target/classes/com/chloefontenot/lab5_chloefontenot/lab5_CalebFontenot.class new file mode 100644 index 0000000000000000000000000000000000000000..18197df9610573612ef633857df7efec7abb9b0b GIT binary patch literal 883 zcmX^0Z`VEs1_l!bWiAFL24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00Sb_Nbc2DRk;T>a#Xocz?Z{JfIXy!;aVoWvy4cvK-rE(Ugx(cHvpZ~|%I zPq|~C2#H5^5Mg}3D{N%)(u*9NF5FaYYQj(Eb%*bHrL#BP!j0`NfiJ5tf3}PD5 zK8PRmzL7eSQ){G1SkU$DZEK1BxElDjZ zW@Hd3Ni8l3$j_!uAZi&T7$g}O7`Pc28KfAb85kL4K-M!dNPrEOWsrj!ZVY$XHU=JaQ&kvP7*xTg Y!dxfMpuoTYGfSR 'a' & currentChar < 'z') { + letterCount[arrayIndex]++; + } + } + } catch (FileNotFoundException ex) { + System.out.println(ex); + } + //Alright. We should have an array with a count of every char in the file. + for (int i = 0; i < letterCount.length; ++i) { + if (letterCount[i] > 0) { + System.out.println("Number of " + Character.toUpperCase((char) (i + 97)) + "'s: " + letterCount[i]); + } + } + } +} diff --git a/Semester 2/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/removeAllOccurances.java b/Semester 2/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/removeAllOccurances.java new file mode 100644 index 0000000..fcf6e9d --- /dev/null +++ b/Semester 2/Assignments/lab7_ChloeFontenot/src/main/java/com/chloefontenot/lab7_chloefontenot/removeAllOccurances.java @@ -0,0 +1,61 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab7_chloefontenot; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class removeAllOccurances { + + public static void main(String[] args) throws FileNotFoundException, IOException { + Scanner input = new Scanner(System.in); + System.out.print("Enter a path to a file: "); + String sourcePath = input.nextLine(); + System.out.print("Replace what with what? (ex. If you want to replace John with Mary, type: \'John Mary\'): "); + String source = input.next(); + String target = input.next(); + input.nextLine(); // Consume newline left-over + System.out.print("Enter the output file path: "); + String destinationPath = input.nextLine(); + + File sourceFile = new File(sourcePath); + File destinationFile = new File(destinationPath); + String[] fileContents = new String[(int) countLines(sourceFile)]; + try (Scanner sourceScanner = new Scanner(sourceFile)) { + for (int i = 0; i < countLines(sourceFile); ++i) { + fileContents[i] = sourceScanner.nextLine(); + } + } + for (int i = 0; i < fileContents.length; ++i) { + fileContents[i] = fileContents[i].replace(source, target); + System.out.println(fileContents[i]); + } + // Write contents to new file + try (PrintWriter fw = new PrintWriter(destinationFile);) { + for (int i = 0; i < fileContents.length; ++i) { + fw.println(fileContents[i]); + } + } + } + + public static int countLines(File sourceFile) throws IOException { + BufferedReader reader = new BufferedReader(new FileReader(sourceFile)); + int lines = 0; + while (reader.readLine() != null) { + lines++; + } + reader.close(); + return lines; + } +} diff --git a/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/Lab8_2_CalebFontenot.java b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/Lab8_2_CalebFontenot.java new file mode 100644 index 0000000..c94ae13 --- /dev/null +++ b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/Lab8_2_CalebFontenot.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package com.chloefontenot.lab8_2_chloefontenot; + +/** + * + * @author chloe + */ +public class Lab8_2_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/NumberX.java b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/NumberX.java new file mode 100644 index 0000000..e7c2ca2 --- /dev/null +++ b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/NumberX.java @@ -0,0 +1,42 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_2_chloefontenot; + +/** + * + * @author chloe + */ +public class NumberX implements Comparable { + int x; + public NumberX(int x) { + this.x = x; + } + @Override + public int compareTo(NumberX o) + { + if (this.x == o.x) { + return 0; + } else if (this.x > o.x) { + return 1; + } else { + return -1; + } + } + public static void main(String[] args) + { + NumberX x1 = new NumberX(10); + NumberX x2 = new NumberX(20); + NumberX x3 = new NumberX(30); + System.out.println(x1.compareTo(x2)); + System.out.println(x1.compareTo(x3)); + System.out.println(x2.compareTo(x1)); + } + + @Override + public String toString() + { + return "NumberX{" + "x=" + x + '}'; + } +} diff --git a/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/SortComparableObjects.java b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/SortComparableObjects.java new file mode 100644 index 0000000..404ff3e --- /dev/null +++ b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/SortComparableObjects.java @@ -0,0 +1,34 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_2_chloefontenot; + +/** + * + * @author chloe + */ +import java.math.*; +import java.util.Arrays; + +public class SortComparableObjects { + public static void main(String[] args) { + NumberX[] numbers = {new NumberX(20), new NumberX(1), new NumberX(3)}; + Arrays.sort(numbers); + for (NumberX number: numbers) { + System.out.println(number); + } + String[] cities = {"Savannah", "Boston", "Atlanta", "Tampa"}; + java.util.Arrays.sort(cities); + for (String city: cities) + System.out.print(city + " "); + System.out.println(); + + BigInteger[] hugeNumbers = {new BigInteger("2323231092923992"), + new BigInteger("432232323239292"), + new BigInteger("54623239292")}; + java.util.Arrays.sort(hugeNumbers); + for (BigInteger number: hugeNumbers) + System.out.print(number + " "); + } +} \ No newline at end of file diff --git a/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/Interface1.java b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/Interface1.java new file mode 100644 index 0000000..c4cb5f9 --- /dev/null +++ b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/Interface1.java @@ -0,0 +1,13 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped; + +/** + * + * @author chloe + */ +public interface Interface1 { + abstract void I1(); +} diff --git a/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/Interface2.java b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/Interface2.java new file mode 100644 index 0000000..d688d1a --- /dev/null +++ b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/Interface2.java @@ -0,0 +1,13 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped; + +/** + * + * @author chloe + */ +public interface Interface2 { + abstract void I2(); +} diff --git a/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/InterfaceGrouped1.java b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/InterfaceGrouped1.java new file mode 100644 index 0000000..7494c7c --- /dev/null +++ b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/InterfaceGrouped1.java @@ -0,0 +1,23 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped; + +/** + * + * @author chloe + */ +public interface InterfaceGrouped1 extends Interface1, Interface2 { + int x = 10; //public static shared by all who implement or extend the interface + abstract void IG1(); + + static void staticMethodOfInterface() { + System.out.println("A static method inside an Interface is shared by every class" + + " that implements Interface InterfaceGrouped1."); + } + default void defaultMethodOfInterface() { + System.out.println("The default implementation was used as there was no overriding" + + " by a class that was implemented the Interface InterfaceGrouped1."); + } +} diff --git a/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/TestInterfaces.java b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/TestInterfaces.java new file mode 100644 index 0000000..3c32ff5 --- /dev/null +++ b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/TestInterfaces.java @@ -0,0 +1,39 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped; + +/** + * + * @author chloe + */ +public class TestInterfaces implements InterfaceGrouped1 { + @Override + public void IG1() { + System.out.println("TestInterfaces:IG1()"); + } + @Override + public void I1() { + System.out.println("TestInterfaces:I1()"); + } + @Override + public void I2() { + System.out.println("testInterfaces:I2()"); + } + @Override + public void defaultMethodOfInterface() { + System.out.println("overriden implementation of defaultMethodOfInterface"); + } + public static void main(String[] args) + { + System.out.println(TestInterfaces.x); + + InterfaceGrouped1.staticMethodOfInterface(); + TestInterfaces ti = new TestInterfaces(); + ti.I1(); + ti.I2(); + ti.IG1(); + ti.defaultMethodOfInterface(); + } +} diff --git a/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/European.java b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/European.java new file mode 100644 index 0000000..659c46e --- /dev/null +++ b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/European.java @@ -0,0 +1,14 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped.fun; + +/** + * + * @author chloe + */ +public interface European extends Language, Religion, War { + void whatCountry(); + +} diff --git a/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/French.java b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/French.java new file mode 100644 index 0000000..eff31a7 --- /dev/null +++ b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/French.java @@ -0,0 +1,41 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped.fun; + +/** + * + * @author chloe + */ +public class French implements European +{ + @Override + public void whatCountry() { + System.out.println("+++ I am from France! +++"); + } + + @Override + public void speakLanguage() + { + System.out.println("speak French"); + } + + @Override + public void practiceReligion() + { + System.out.println("Roman Catholic"); + } + + @Override + public void WWI() + { + System.out.println("In WW1 the French won -- Allies!"); + } + + @Override + public void WWII() + { + System.out.println("In WW2 the French wan -- Allies!"); + } +} diff --git a/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/German.java b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/German.java new file mode 100644 index 0000000..c502366 --- /dev/null +++ b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/German.java @@ -0,0 +1,43 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped.fun; + +/** + * + * @author chloe + */ +public class German implements European { + + @Override + public void whatCountry() + { + System.out.println("+++ I am from Germany! +++"); + } + @Override + public void speakLanguage() + { + System.out.println("speak German"); + } + + @Override + public void practiceReligion() + { + System.out.println("Protestant"); + } + + @Override + public void WWI() + { + System.out.println("in WW1 the Germans lost -- Axis!"); + } + + + @Override + public void WWII() + { + System.out.println("in WW2 the Germans lost -- Axis!"); + } + +} diff --git a/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/Italian.java b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/Italian.java new file mode 100644 index 0000000..554d8ea --- /dev/null +++ b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/Italian.java @@ -0,0 +1,43 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped.fun; + +/** + * + * @author chloe + */ +public class Italian implements European { + + @Override + public void whatCountry() + { + System.out.println("+++ I am from Itally! +++"); + } + + @Override + public void speakLanguage() + { + System.out.println("speak Italian"); + } + + @Override + public void practiceReligion() + { + System.out.println("Roman Catholic"); + } + + @Override + public void WWI() + { + System.out.println("in WW1 the Italians won -- Allies!"); + } + + @Override + public void WWII() + { + System.out.println("In WW2 the Italians lost -- Axis!"); + } + +} diff --git a/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/Language.java b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/Language.java new file mode 100644 index 0000000..611499d --- /dev/null +++ b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/Language.java @@ -0,0 +1,13 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped.fun; + +/** + * + * @author chloe + */ +public interface Language { + void speakLanguage(); +} diff --git a/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/Religion.java b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/Religion.java new file mode 100644 index 0000000..2a9052f --- /dev/null +++ b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/Religion.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped.fun; + +/** + * + * @author chloe + */ +public interface Religion { + public void practiceReligion(); + default void beforeChrist() { + System.out.println("paganism"); + } +} diff --git a/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/Russian.java b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/Russian.java new file mode 100644 index 0000000..6b9c1ad --- /dev/null +++ b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/Russian.java @@ -0,0 +1,43 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped.fun; + +/** + * + * @author chloe + */ +public class Russian implements European { + + @Override + public void whatCountry() + { + System.out.println("+++ I am from Russia! +++"); + } + + @Override + public void speakLanguage() + { + System.out.println("speak Russian"); + } + + @Override + public void practiceReligion() + { + System.out.println("Orthodox"); + } + + @Override + public void WWI() + { + System.out.println("In WW1 the Russians won -- Allies!"); + } + + @Override + public void WWII() + { + System.out.println("In WW2 the Russians won -- Allies!"); + } + +} diff --git a/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/TestEuropeans.java b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/TestEuropeans.java new file mode 100644 index 0000000..05c302d --- /dev/null +++ b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/TestEuropeans.java @@ -0,0 +1,73 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped.fun; + +import java.util.ArrayList; + +/** + * + * @author chloe + */ +public class TestEuropeans { + + public static void testWithArrayList() { + ArrayList europeans = new ArrayList(); + + europeans.add(new French()); + europeans.add(new German()); + europeans.add(new Russian()); + europeans.add(new Italian()); + + for (European man : europeans) { + man.whatCountry(); + man.beforeChrist(); + man.practiceReligion(); + man.speakLanguage(); + man.WWI(); + man.WWII(); + } + } + + public static void testWithArrayOfObjects() { + European[] europeans = { + new French(), + new German(), + new Russian(), + new Italian() + }; + for (European person : europeans) { + person.whatCountry(); + person.beforeChrist(); + person.practiceReligion(); + person.speakLanguage(); + person.WWI(); + person.WWII(); + } + } + + public static void testWithArrayOfInterfaces() { + European[] europeans = new European[4]; + europeans[0] = new French(); + europeans[1] = new German(); + europeans[2] = new Russian(); + europeans[3] = new Italian(); + + for (European person : europeans) { + person.whatCountry(); + person.beforeChrist(); + person.practiceReligion(); + person.speakLanguage(); + person.WWI(); + person.WWII(); + } + } + public static void main(String[] args) { + testWithArrayList(); + System.out.println("-------------------"); + testWithArrayOfObjects(); + System.out.println("-------------------"); + testWithArrayOfInterfaces(); + } +} diff --git a/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/TestEuropeansAgain.java b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/TestEuropeansAgain.java new file mode 100644 index 0000000..4973d81 --- /dev/null +++ b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/TestEuropeansAgain.java @@ -0,0 +1,31 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped.fun; + +/** + * + * @author chloe + */ +public class TestEuropeansAgain { + public static void testWithArrayOfInterfaces() { + European[] europeans = new European[4]; + europeans[0] = new French(); + europeans[1] = new German(); + europeans[2] = new Russian(); + europeans[3] = new Italian(); + + for (European person : europeans) { + person.whatCountry(); + person.beforeChrist(); + person.practiceReligion(); + person.speakLanguage(); + person.WWI(); + person.WWII(); + } + } + public static void main(String[] args) { + testWithArrayOfInterfaces(); + } +} diff --git a/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/War.java b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/War.java new file mode 100644 index 0000000..8140b23 --- /dev/null +++ b/Semester 2/Assignments/lab8_2_ChloeFontenot/src/main/java/com/chloefontenot/lab8_2_chloefontenot/interfacesGrouped/fun/War.java @@ -0,0 +1,14 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package com.chloefontenot.lab8_2_chloefontenot.interfacesGrouped.fun; + +/** + * + * @author chloe + */ +public interface War { + void WWI(); + void WWII(); +} diff --git a/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Animal.java b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Animal.java new file mode 100644 index 0000000..897927b --- /dev/null +++ b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Animal.java @@ -0,0 +1,13 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +/** + * + * @author chloe + */ +public abstract class Animal { + public abstract String sound(); +} diff --git a/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Apple.java b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Apple.java new file mode 100644 index 0000000..c04f14a --- /dev/null +++ b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Apple.java @@ -0,0 +1,18 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +/** + * + * @author chloe + */ +public class Apple extends Fruit{ + + @Override + public String howToEat() + { + return "Apple: Make apple cider."; + } +} diff --git a/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Brocoli.java b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Brocoli.java new file mode 100644 index 0000000..53981e0 --- /dev/null +++ b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Brocoli.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +/** + * + * @author chloe + */ +public class Brocoli extends Fruit { + @Override + public String howToEat() { + return "Brocolli: Steam it"; + } +} diff --git a/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Chicken.java b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Chicken.java new file mode 100644 index 0000000..e83739d --- /dev/null +++ b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Chicken.java @@ -0,0 +1,20 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +/** + * + * @author chloe + */ +public class Chicken extends Animal implements Edible { + @Override + public String sound() { + return "Chicken: cock-a-doodle-do!"; + } + @Override + public String howToEat() { + return "Chicken: Fry it!"; + } +} diff --git a/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Duck.java b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Duck.java new file mode 100644 index 0000000..53776bd --- /dev/null +++ b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Duck.java @@ -0,0 +1,21 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +/** + * + * @author chloe + */ +public class Duck extends Animal implements Edible { + @Override + public String howToEat() { + return "Duck: Roast it!"; + } + + @Override + public String sound() { + return "Duck: Quack! Quack! Quack!"; + } +} diff --git a/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Edible.java b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Edible.java new file mode 100644 index 0000000..cb3172b --- /dev/null +++ b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Edible.java @@ -0,0 +1,13 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +/** + * + * @author chloe + */ +public interface Edible { + String howToEat(); +} diff --git a/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Fruit.java b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Fruit.java new file mode 100644 index 0000000..659c624 --- /dev/null +++ b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Fruit.java @@ -0,0 +1,13 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +/** + * + * @author chloe + */ +public abstract class Fruit implements Edible{ + +} diff --git a/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/House.java b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/House.java new file mode 100644 index 0000000..061a584 --- /dev/null +++ b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/House.java @@ -0,0 +1,133 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +import java.util.Date; + +/** + * + * @author chloe + */ +public class House implements Cloneable{ + + private int id; + private double area; + private Date whenBuilt; + + public House(int id, double area) + { + this.id = id; + this.area = area; + this.whenBuilt = new Date(); + } + + @Override + protected Object clone() throws CloneNotSupportedException + { + Object o = super.clone(); + ((House) o).whenBuilt = new Date(this.whenBuilt.getTime()); + return o; + } + + + + /** + * Get the value of whenBuilt + * + * @return the value of whenBuilt + */ + public Date getWhenBuilt() + { + return whenBuilt; + } + + /** + * Set the value of whenBuilt + * + * @param whenBuilt new value of whenBuilt + */ + public void setWhenBuilt(Date whenBuilt) + { + this.whenBuilt = whenBuilt; + } + + + /** + * Get the value of area + * + * @return the value of area + */ + public double getArea() + { + return area; + } + + /** + * Set the value of area + * + * @param area new value of area + */ + public void setArea(double area) + { + this.area = area; + } + + /** + * Get the value of id + * + * @return the value of id + */ + public int getId() + { + return id; + } + + /** + * Set the value of id + * + * @param id new value of id + */ + public void setId(int id) + { + this.id = id; + } + + @Override + public String toString() + { + return "House{" + "id=" + id + ", area=" + area + ", whenBuilt=" + whenBuilt + '}'; + } + + public int compareTo(House o) { + if (this.getId() == o.getId() && + this.getArea() == o.getArea() && + this.getWhenBuilt().equals(o.getWhenBuilt())) { + return 0; + } + if (this.area > o.area) { + return 1; + } else if (this.area < o.area) { + return -1; + } else { + return -2; // Same area for this and o but either var id or var whenBuilt are different + } + } + +public static void main(String[] args) throws CloneNotSupportedException, InterruptedException { + House house1 = new House(1, 1000); + House house2 = (House) house1.clone(); + house2.whenBuilt.setDate(8); + System.out.println(house1); + System.out.println(house2); + House house3 = new House(3, 2000); + House house4 = new House(4, 2000); + System.out.println("house 1 and house 2 are identical: "+ house1.compareTo(house2)); + System.out.println("house 3 and house 3 have the same area: " + house3.compareTo(house4)); + System.out.println("House 4 is harger than house 2: " + house4.compareTo(house2)); + + +} + +} diff --git a/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Lab8_CalebFontenot.java b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Lab8_CalebFontenot.java new file mode 100644 index 0000000..c9b637c --- /dev/null +++ b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Lab8_CalebFontenot.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package com.chloefontenot.lab8_chloefontenot; + +/** + * + * @author chloe + */ +public class Lab8_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Orange.java b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Orange.java new file mode 100644 index 0000000..ec47fef --- /dev/null +++ b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Orange.java @@ -0,0 +1,19 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +import com.chloefontenot.lab8_chloefontenot.Fruit; + +/** + * + * @author chloe + */ +public class Orange extends Fruit { + + @Override + public String howToEat() { + return "Orange: Make orange juice."; + } +} diff --git a/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Test.java b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Test.java new file mode 100644 index 0000000..a00d27d --- /dev/null +++ b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Test.java @@ -0,0 +1,36 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +/** + * + * @author chloe + */ +public class Test { + Edible getEdible() { + Edible e = new Edible() { + @Override + public String howToEat() { + return "Beans: make a soup"; + } + }; + return e; + } +/* +Comparable getComparable() { + Comparable c = new Comparable() { + @Override + public int compareTo(Object o) { + return == "dummy value" ? ((o.hashCode() == 11 ? 1 : -1) : 0; + } + }; + return c; + } +*/ + public static void main(String[] args) + { + Edible[] edible = {new Chicken()}; + } +} diff --git a/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/TestEdible.java b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/TestEdible.java new file mode 100644 index 0000000..a86d57e --- /dev/null +++ b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/TestEdible.java @@ -0,0 +1,60 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +import java.util.ArrayList; + +/** + * + * @author chloe + */ + + +public class TestEdible { + public static void testWithArrayList() { + ArrayList edible = new ArrayList(); + + edible.add(new Chicken()); + edible.add(new Apple()); + edible.add(new Orange()); + edible.add(new Duck()); + edible.add(new Brocoli()); + + for (Edible eat: edible) { + System.out.println(eat.howToEat()); + } + } + public static void testWithArrayOfInterfaces() { + Edible[] edible = { + new Chicken(), new Apple(), new Orange(), new Duck(), new Brocoli() + }; + for (int i = 0; i < edible.length; ++i) { + System.out.println(edible[i].howToEat()); + } + } + public static void testWithArrayOfObjects() { + Object[] objects = { + new Tiger(), new Chicken(), new Apple(), new Duck(), new Brocoli() + }; + for (int i = 0; i < objects.length; ++i) { + if (objects[i] instanceof Edible) { + System.out.println(((Edible) objects[i]).howToEat()); + } + if (objects[i] instanceof Animal) { + System.out.println(((Animal) objects[i]).sound()); + } + } + } + public static void main(String[] args) + { + testWithArrayOfObjects(); + System.out.println("-------------------"); + testWithArrayOfInterfaces(); + System.out.println("------------------ "); + testWithArrayList(); + } +} + + diff --git a/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Tiger.java b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Tiger.java new file mode 100644 index 0000000..5aa7e68 --- /dev/null +++ b/Semester 2/Assignments/lab8_ChloeFontenot/src/main/java/com/chloefontenot/lab8_chloefontenot/Tiger.java @@ -0,0 +1,19 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.lab8_chloefontenot; + +/** + * + * @author chloe + */ +public class Tiger extends Animal { + + @Override + public String sound() + { + return "Tiger: ROAAAAAAAR!"; + } + +} diff --git a/Semester 2/Exams/Exam1_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/Exam1_CalebFontenot.java b/Semester 2/Exams/Exam1_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/Exam1_CalebFontenot.java new file mode 100644 index 0000000..d8cdcf1 --- /dev/null +++ b/Semester 2/Exams/Exam1_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/Exam1_CalebFontenot.java @@ -0,0 +1,17 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Project/Maven2/JavaApp/src/main/java/${packagePath}/${mainClassName}.java to edit this template + */ + +package com.chloefontenot.exam1_chloefontenot; + +/** + * + * @author ar114 + */ +public class Exam1_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!".toUpperCase()); + } +} diff --git a/Semester 2/Exams/Exam1_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/Location.java b/Semester 2/Exams/Exam1_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/Location.java new file mode 100644 index 0000000..e920fbe --- /dev/null +++ b/Semester 2/Exams/Exam1_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/Location.java @@ -0,0 +1,54 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.exam1_chloefontenot; + +/** + * + * @author ar114 + */ +public class Location { + + public static int row; + public static int column; + public static double maxValue; + + int x, y; + Location(int x, int y) { + this.x = x; + this.y = y; + } + + public static Location locateLargest(double[][] arr) { + maxValue = arr[0][0]; + //Find max value + for (int i = 0; i < arr.length - 1; ++i) { + for (int j = 0; j < arr[i].length; ++j) { + if (maxValue < arr[i][j]) { + maxValue = arr[i][j]; + column = i; + row = j; + } + } + } + return new Location(column, row); + } + + @Override + public String toString() { + String s = "The location of the largest element is "; + s += maxValue + " at (" + this.x + ", "+ this.y +")"; + return s; + } + + public static void main(String[] args) { + double[][] arr = { + {23.5, 35, 2, 10, 12}, + {4.5, 3, 45}, + {35, 44, 5.5, 9.6} + }; + System.out.println(locateLargest(arr)); + + } +} diff --git a/Semester 2/Exams/Exam1_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/MyStringBuilder.java b/Semester 2/Exams/Exam1_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/MyStringBuilder.java new file mode 100644 index 0000000..72a05e1 --- /dev/null +++ b/Semester 2/Exams/Exam1_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/MyStringBuilder.java @@ -0,0 +1,123 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.exam1_chloefontenot; + +import java.util.Arrays; + +/** + * + * @author chloe + */ +public class MyStringBuilder { + + //private int size = 0; // Size is not necessary. Remove it and modify the code. + //private int capacity = 0; //not necessary + private char[] buffer; + + public MyStringBuilder() { + } + + public MyStringBuilder(char[] chars) { + buffer = chars; + } + + public MyStringBuilder(String s) { + buffer = s.toCharArray(); + } + + private void increaseCapacity(int newCapacity) { + char[] temp = new char[newCapacity]; + System.arraycopy(buffer, 0, temp, 0, buffer.length); + buffer = temp; + } + + public MyStringBuilder append(MyStringBuilder s) { + int oldLength = buffer.length; + char[] toAdd = s.buffer; + increaseCapacity(toAdd.length + oldLength); + int j = 0; + for (int i = oldLength; i < (oldLength + s.buffer.length); ++i) { + buffer[i] = toAdd[j++]; + } + return this; + } + + /** + * public MyStringBuilder append(int i) { + * + * } + * + * @return + * + */ + public int length() { + return buffer.length -1; + } + + public char charAt(int index) { + return buffer[index]; + } + + public MyStringBuilder toLowerCase() { + for (int i = 0; i < buffer.length; ++i) { + buffer[i] = Character.toLowerCase(buffer[i]); + } + return this; + } + + public MyStringBuilder substring(int begin, int end) { + String s = ""; + for (int i = begin; i < end; ++i) { + s += buffer[i]; + } + return new MyStringBuilder(s.toCharArray()); + } + + @Override + public String toString() { + String s = ""; + for(char c: buffer) + { + s += c; + } + return s; + } + + public MyStringBuilder reverse() { + char[] reversed = new char[buffer.length]; + int j = 0; + for (int i = buffer.length - 1; i >= 0; --i) { + reversed[i] = buffer[j]; + j++; + } + buffer = reversed; + return this; + } + + public MyStringBuilder substring(int begin) { + return substring(begin, buffer.length); + } + + public MyStringBuilder toUpperCase() { + for (int i = 0; i < buffer.length; ++i) { + buffer[i] = Character.toUpperCase(buffer[i]); + } + return this; + } + + public static void main(String[] args) { + MyStringBuilder s1 = new MyStringBuilder("Welcome to"); + MyStringBuilder s2 = new MyStringBuilder(" Java"); + + System.out.println(s1.length()); + System.out.println(s1.charAt(3)); + System.out.println(s1.toUpperCase().toString()); + s1.append(s2); + System.out.println(s1.toString()); + System.out.println(s1.substring(1, 4)); + System.out.println(s1.reverse()); + System.out.println(s1.reverse()); + } +} diff --git a/Semester 2/Exams/Exam1_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/Question1.java b/Semester 2/Exams/Exam1_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/Question1.java new file mode 100644 index 0000000..7723152 --- /dev/null +++ b/Semester 2/Exams/Exam1_ChloeFontenot/src/main/java/com/chloefontenot/exam1_chloefontenot/Question1.java @@ -0,0 +1,53 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.exam1_chloefontenot; + +/** + * + * @author ar114 + */ +public class Question1 { + + public static void sort(int[] arr) { + for (int i = 0; i < arr.length - 1; ++i) { + for (int j = i + 1; j < arr.length; ++j) { + if (arr[i] > arr[j]) { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + } + } + } + + public static void print(int[][][] arr) { + for (int i = 0; i < arr.length; ++i) { + for (int j = 0; j < arr[i].length; ++j) { + for (int k = 0; k < arr[i][j].length; ++k) { + System.out.print(arr[i][j][k] + " "); + } + System.out.println(); + } + } + } + public static void main(String[] args) { + int[][][] arr = { + { + {11, 2, 6, 22}, {3, 90, 112, 40, 7, 12} + }, + { + {10, -20, 3}, {300, 50} + } + + }; + for (int i = 0; i < arr.length; ++i) { + for (int j = 0; j < arr[i].length; ++j) { + sort(arr[i][j]); + } + } + + print(arr); + } +} diff --git a/Semester 2/Exams/Exam2-Practice1_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice_chloefontenot/Automobile.java b/Semester 2/Exams/Exam2-Practice1_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice_chloefontenot/Automobile.java new file mode 100644 index 0000000..663471c --- /dev/null +++ b/Semester 2/Exams/Exam2-Practice1_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice_chloefontenot/Automobile.java @@ -0,0 +1,76 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.exam2.practice_chloefontenot; + +import java.util.Objects; + +/** + * + * @author chloe + */ +public class Automobile implements Comparable { + + private String vin; + private CountryOfOrigin origin; + + public Automobile(String vin, CountryOfOrigin origin) + { + this.vin = vin; + this.origin = origin; + } + + public CountryOfOrigin getOrigin() + { + return origin; + } + + public void setOrigin(CountryOfOrigin origin) + { + this.origin = origin; + } + + + public String getVin() + { + return vin; + } + + public void setVin(String vin) + { + this.vin = vin; + } + + @Override + public String toString() + { + return "Automobile{" + "vin=" + vin + ", origin=" + origin + '}'; + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Automobile other = (Automobile) obj; + if (!Objects.equals(this.vin, other.vin)) { + return false; + } + return Objects.equals(this.origin, other.origin); + } + + @Override + public int compareTo(Automobile o) + { + return vin.compareTo(o.vin); + } + +} diff --git a/Semester 2/Exams/Exam2-Practice1_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice_chloefontenot/CountryOfOrigin.java b/Semester 2/Exams/Exam2-Practice1_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice_chloefontenot/CountryOfOrigin.java new file mode 100644 index 0000000..fc268b1 --- /dev/null +++ b/Semester 2/Exams/Exam2-Practice1_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice_chloefontenot/CountryOfOrigin.java @@ -0,0 +1,102 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.exam2.practice_chloefontenot; + +import java.util.Arrays; + +/** + * + * @author chloe + */ +public class CountryOfOrigin implements Cloneable, Comparable { + + private char[] country = "USA".toCharArray(); + + public CountryOfOrigin() {} + + public CountryOfOrigin(char[] country) + { + this.country = country; + } + + public String getCountry() + { + return String.copyValueOf(this.country); + } + + public void setCountry(char[] country) + { + this.country = country; + } + + public boolean changeOneLetter(int index, char newLetter) + { + if (index >= this.country.length || index < 0) { + return false; + } + this.country[index] = newLetter; + return true; + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final CountryOfOrigin other = (CountryOfOrigin) obj; + return Arrays.equals(this.country, other.country); + } + + @Override + public String toString() + { + return String.copyValueOf(this.country); + } + + @Override + public int compareTo(CountryOfOrigin o) + { + return String.copyValueOf(this.country).compareTo(String.copyValueOf(o.country)); + } + + @Override + public Object clone() { + return new CountryOfOrigin(new String(this.country).toCharArray()); + } + + public static void main(String[] args) throws CloneNotSupportedException + { + CountryOfOrigin c1 = new CountryOfOrigin(); + CountryOfOrigin c2 = new CountryOfOrigin("GERMANY".toCharArray()); + CountryOfOrigin c3 = (CountryOfOrigin) c2.clone(); + + System.out.println("c1 is: " + c1); + System.out.println("c2 is: " + c2); + System.out.println("c3 cloned of c2 is: " + c3); + + c3.changeOneLetter(0, 'J'); + c3.changeOneLetter(1, 'A'); + c3.changeOneLetter(2, 'P'); + + System.out.println("c3 after changeOneLetter is: " + c3); + System.out.println("if this displays GERMANY and not JAPMANY\nyour clone is deep: " + c2); + + System.out.println(c1.compareTo(c2)); + System.out.println(c1.compareTo(c3)); + System.out.println(c1.equals(c2)); + System.out.println(c1.equals(c3)); + System.out.println(c2.getCountry()); + c2.setCountry("ITALY".toCharArray()); + System.out.println(c2.getCountry()); + System.out.println(c1.getCountry()); + } +} diff --git a/Semester 2/Exams/Exam2-Practice1_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice_chloefontenot/Dealership.java b/Semester 2/Exams/Exam2-Practice1_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice_chloefontenot/Dealership.java new file mode 100644 index 0000000..1d89954 --- /dev/null +++ b/Semester 2/Exams/Exam2-Practice1_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice_chloefontenot/Dealership.java @@ -0,0 +1,37 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.exam2.practice_chloefontenot; + +import java.util.ArrayList; +import java.util.Arrays; + +/** + * + * @author chloe + */ +public class Dealership extends ArrayList { + /** Sorts the inherited ArrayList of Automobiles + * into ascending order by vin number. + * @param d the Dealership of Automobiles + */ + public static void sortByVin(Dealership d) { //java.util.Collections.sort() could do all of this in a single line + Object[] dealershipArray = d.toArray(); + Arrays.sort(dealershipArray); + d.clear(); + for (int i = 0; i < dealershipArray.length; ++i) { + d.add((Automobile) dealershipArray[i]); + } + } + public static void main(String[] args) + { + Dealership d = new Dealership(); + + d.add(new Automobile("8", new CountryOfOrigin("USA".toCharArray()))); + d.add(new Automobile("1", new CountryOfOrigin("GERMANY".toCharArray()))); + System.out.println("THE ORIGINAL DEALERSHIP\n" + d); + Dealership.sortByVin(d); + System.out.println("\nTHE SORTED BY VIN DEALERSHIP\n" + d); + } +} diff --git a/Semester 2/Exams/Exam2-Practice1_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice_chloefontenot/Exam2Practice_CalebFontenot.java b/Semester 2/Exams/Exam2-Practice1_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice_chloefontenot/Exam2Practice_CalebFontenot.java new file mode 100644 index 0000000..99609bf --- /dev/null +++ b/Semester 2/Exams/Exam2-Practice1_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice_chloefontenot/Exam2Practice_CalebFontenot.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package com.chloefontenot.exam2.practice_chloefontenot; + +/** + * + * @author chloe + */ +public class Exam2Practice_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 2/Exams/Exam2-Practice1_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice_chloefontenot/Main.java b/Semester 2/Exams/Exam2-Practice1_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice_chloefontenot/Main.java new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/Semester 2/Exams/Exam2-Practice1_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice_chloefontenot/Main.java @@ -0,0 +1 @@ + diff --git a/Semester 2/Exams/Exam2-Practice2_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice2_chloefontenot/Automobile.java b/Semester 2/Exams/Exam2-Practice2_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice2_chloefontenot/Automobile.java new file mode 100644 index 0000000..06b8ec3 --- /dev/null +++ b/Semester 2/Exams/Exam2-Practice2_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice2_chloefontenot/Automobile.java @@ -0,0 +1,94 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.exam2.practice2_chloefontenot; + +import java.util.Objects; + +/** + * + * @author chloe + */ +public class Automobile extends Vehicle implements Cloneable{ + + private String make; + + public Automobile(String make) + { + this.make = make; + } + public Automobile(String make, String vin) + { + super(vin); + this.make = make; + } + public String getMake() { return make; } + public void setMake(String make) { this.make = make; } + @Override + public int compareTo(Vehicle o) + { + return this.getVin().compareTo(o.getVin()); + } + @Override + public boolean equals(Object obj) + { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Automobile other = (Automobile) obj; + boolean isSameObjectType = Objects.equals(this.make, other.make); + if (isSameObjectType) { + if (this.make.compareTo(other.make) == 0 && (this.getVin().compareTo(other.getVin()) == 0)) { + return true; + } else { + return false; + } + } else { + return false; + } + } + @Override + protected Object clone() throws CloneNotSupportedException { + String make = new String(this.getMake()); + String vim = new String(this.getVin()); + Automobile clonedAuto = new Automobile(make, vim); + return clonedAuto; + } + + @Override + public String toString() + { + return super.toString() + "\n" + "Automobile{" + "make=" + make + '}'; + } + + public static void main(String[] args) throws CloneNotSupportedException + { + Automobile johnsBeemer = new Automobile ("BMW", "vin1BMW"); + Automobile marysBeemer = new Automobile ("BMW", "vin2BMW"); + + Automobile johnsClonedBeemer = (Automobile) johnsBeemer.clone(); + + System.out.println(johnsBeemer + "\n"); + System.out.println(marysBeemer + "\n"); + System.out.println(johnsClonedBeemer + "\n"); + + + + System.out.println("John\'s beemer EQUALS Mary\'s beemer --> " + johnsBeemer.equals(marysBeemer)); + System.out.println("John\'s beemer EQUALS John\'s beemer --> " + johnsBeemer.equals(johnsClonedBeemer)); + + System.out.println("John\'s beemer COMPARE_TO John\'s cloned beemer --> " + johnsBeemer.compareTo(johnsClonedBeemer)); + System.out.println("John\'s beemer COMPARE_TO Mary\'s beemer --> " +johnsBeemer.compareTo(marysBeemer)); + + System.out.println("John\'s beemer EQUALS Airplane --> " + johnsBeemer.equals(new Airplane())); + } +} + +class Airplane {} diff --git a/Semester 2/Exams/Exam2-Practice2_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice2_chloefontenot/Exam2Practice2_CalebFontenot.java b/Semester 2/Exams/Exam2-Practice2_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice2_chloefontenot/Exam2Practice2_CalebFontenot.java new file mode 100644 index 0000000..345ecdc --- /dev/null +++ b/Semester 2/Exams/Exam2-Practice2_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice2_chloefontenot/Exam2Practice2_CalebFontenot.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package com.chloefontenot.exam2.practice2_chloefontenot; + +/** + * + * @author chloe + */ +public class Exam2Practice2_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 2/Exams/Exam2-Practice2_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice2_chloefontenot/Main.java b/Semester 2/Exams/Exam2-Practice2_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice2_chloefontenot/Main.java new file mode 100644 index 0000000..b85fd1e --- /dev/null +++ b/Semester 2/Exams/Exam2-Practice2_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice2_chloefontenot/Main.java @@ -0,0 +1,121 @@ +package com.chloefontenot.exam2.practice2_chloefontenot; + +import java.util.Objects; + +/** + * + * @author chloe + */ +public class Automobile extends Vehicle implements Cloneable{ + + private String make; + + public Automobile(String make) + { + this.make = make; + } + public Automobile(String make, String vin) + { + super(vin); + this.make = make; + } + public String getMake() { return make; } + public void setMake(String make) { this.make = make; } + @Override + public int compareTo(Vehicle o) + { + return this.getVin().compareTo(o.getVin()); + } + @Override + public boolean equals(Object obj) + { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Automobile other = (Automobile) obj; + boolean isSameObjectType = Objects.equals(this.make, other.make); + if (isSameObjectType) { + if (this.make.compareTo(other.make) == 0 && (this.getVin().compareTo(other.getVin()) == 0)) { + return true; + } else { + return false; + } + } else { + return false; + } + } + @Override + protected Object clone() throws CloneNotSupportedException { + String make = new String(this.getMake()); + String vim = new String(this.getVin()); + Automobile clonedAuto = new Automobile(make, vim); + return clonedAuto; + } + + @Override + public String toString() + { + return super.toString() + "\n" + "Automobile{" + "make=" + make + '}'; + } + + public static void main(String[] args) throws CloneNotSupportedException + { + Automobile johnsBeemer = new Automobile ("BMW", "vin1BMW"); + Automobile marysBeemer = new Automobile ("BMW", "vin2BMW"); + + Automobile johnsClonedBeemer = (Automobile) johnsBeemer.clone(); + + System.out.println(johnsBeemer + "\n"); + System.out.println(marysBeemer + "\n"); + System.out.println(johnsClonedBeemer + "\n"); + + + + System.out.println("John\'s beemer EQUALS Mary\'s beemer --> " + johnsBeemer.equals(marysBeemer)); + System.out.println("John\'s beemer EQUALS John\'s beemer --> " + johnsBeemer.equals(johnsClonedBeemer)); + + System.out.println("John\'s beemer COMPARE_TO John\'s cloned beemer --> " + johnsBeemer.compareTo(johnsClonedBeemer)); + System.out.println("John\'s beemer COMPARE_TO Mary\'s beemer --> " +johnsBeemer.compareTo(marysBeemer)); + + System.out.println("John\'s beemer EQUALS Airplane --> " + johnsBeemer.equals(new Airplane())); + } +} + +abstract public class Vehicle implements Cloneable, Comparable { + + private String vin; + public Vehicle(){} + public Vehicle(String vin) {this.vin = vin;} + public String getVin() { return vin; } + public void setVin(String vin) { this.vin = vin; } + + @Override + public String toString() + { return "Vehicle{" + "vin=" + vin + '}'; } + + @Override + public boolean equals(Object obj) + { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Vehicle other = (Vehicle) obj; + return Objects.equals(this.vin, other.vin); + } + +} + +class Airplane {} + diff --git a/Semester 2/Exams/Exam2-Practice2_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice2_chloefontenot/Vehicle.java b/Semester 2/Exams/Exam2-Practice2_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice2_chloefontenot/Vehicle.java new file mode 100644 index 0000000..6dcd774 --- /dev/null +++ b/Semester 2/Exams/Exam2-Practice2_ChloeFontenot/src/main/java/com/chloefontenot/exam2/practice2_chloefontenot/Vehicle.java @@ -0,0 +1,41 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.exam2.practice2_chloefontenot; + +import java.util.Objects; + +/** + * + * @author chloe + */ +abstract public class Vehicle implements Cloneable, Comparable { + + private String vin; + public Vehicle(){} + public Vehicle(String vin) {this.vin = vin;} + public String getVin() { return vin; } + public void setVin(String vin) { this.vin = vin; } + + @Override + public String toString() + { return "Vehicle{" + "vin=" + vin + '}'; } + + @Override + public boolean equals(Object obj) + { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Vehicle other = (Vehicle) obj; + return Objects.equals(this.vin, other.vin); + } + +} diff --git a/Semester 2/Exams/Exam2-Practice2_ChloeFontenot/target/classes/com/chloefontenot/exam2/practice2_chloefontenot/Airplane.class b/Semester 2/Exams/Exam2-Practice2_ChloeFontenot/target/classes/com/chloefontenot/exam2/practice2_chloefontenot/Airplane.class new file mode 100644 index 0000000000000000000000000000000000000000..e481790a9928b5d207685176b1934fffcacf9638 GIT binary patch literal 347 zcmX^0Z`VEs1_oOO0WJn624;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00Sb_Nbc28-nUT>a#Xocz?Z{JfIXy!;aV)QZGhBmIJ+#N?99*xc>hn1dO3^EL|>~!=TEb#>gNDc0_4OW{y6@fMP}lw$#GX#GGPA26bd#L!_;d{00@#i~@y& z1`mTKC>+?+Q%igkvr|Ey5DqE(imuh{EbdW`Yogsmd!Gct495agwauV}WxftRZn1vYF7(&?@Qea^OE-9Qr z=^!x)T#h*Br=&76@cU%urTUfTCZ!gIKqQ2G@{<#D!V-%zL42qnOG!p%F(ZQw$zDek zUDk{Y0=}sw8TlyziA9OIsU@jJ#f%KhWuP*My%>@S85tP!85t}|wgnczptPElg<3j7 z9yHNPYywTO{HAhS3)F*g+=9#UD5%E-VN#mK-LT#}fa?VDHt^)ho=W-cQG7dY#r zfV{!Tz~x$zoLW$lnV(n8&QQt7paM>Ph>-QmF9|L!D9A4=Nlk$(Wn^HZk!EDz&dSfoD|Sjv%>}ugJ2$bY63!C@%Yh>`1*QU}k)pm4`YCNh4N=&0u6uM%4lJ2CR%w02|H7z~h;hms$j_ zYEz5Z8D=vwsDcs%q+x*)2dI(9&M=peK@PuCMg}%WOfx7la4;}2Fft@FFfuTK8bJ&U z3|tJ146F?N3``8E3=9lz3``76AW^OD42)XZTN&6lGB7YOF{CjtFz_)jGcYiKicVn$ zP6iQ%bOr_nF^Fo042Dbw5a0rv%E*w#z`(%D$iU6O05)D1YJ4E5UB|${z^$dToq-pt z`Qi+$3=#}n43c2;6~K0K!_DW0n$N(%&5+H&!@vZ#i4)`*28L{~ZJG?i42)pU=rb@f zFoGPSwS|Fw1Kb~MU_mLc`8;4YE7W{Oh8%cESV2RA4b7Dh-O^y)5Z|*wbu%!qL0yO9 zdr5{UsP7%1M)GKFV-V2Z#vrndL39n8v*eKs=7Af`!;s66#{du3T(Cz~8G@k(-(g^4 zU}0cj2-MPE#=y$5M*BDeEAtwyZ4A=d+Zd#mf;id-7&v@E;h?jHfqe&qqMhta24xt3 z8-wU924Rq^bha@FfO)JeYnazCgIvc9j(jr)UIqpR6$VxYRR(qjbp~z*4F+BYEd~h& zZ3Za@T?TmuJqB$CeFl970|svfLk3?4V+MZ)Gq7*8AdZ9kCXgYYp@4yrL7u^gp^zby zfr&wzL5-n^p_qZ0p@e~fftP`mot5V=gAqFe2P53m`3wvUETD!I)YBCVEMRk0b~A`Y zYHeds-_D@r17!z+lb5!(hW8!C=dv#9)WyMirxE2(%(pXW`#{;2+ZnWdwYM=? zA7J3{+r(h6y@SDZ7lS7Q!!`z=O$_!rs9arCuC~rLhQM76Au!e2x?p}dGCyJ$Lo}SP zvyCBQ7egGJzndXGayvsJSXUBQ6j3x7G4L=jFnBWXFnBRYF!(SiF!(X(Gx#&uF$6I9 zGK4V1GK4bZGK4eKGDI-+GDI;fW{3ud10-cEVW?rKWnf_7VVJ>C$B@au$RNSc!%z=S z843(73=L?Z4$WRQ3=9H}43Z3u&;(%&&0d^Z+6NezwlPGkLCagbU^^jU&j}5Cs9CuJ z3=GT+O<)bp3@r={3_1+#46O`|4BcR|7fkkp$%$ZcGMJnSCZ{vZ1eKW#j103F<}l1- GkOTlMUUQlN literal 0 HcmV?d00001 diff --git a/Semester 2/Exams/Exam2-Practice2_ChloeFontenot/target/classes/com/chloefontenot/exam2/practice2_chloefontenot/Exam2Practice2_CalebFontenot.class b/Semester 2/Exams/Exam2-Practice2_ChloeFontenot/target/classes/com/chloefontenot/exam2/practice2_chloefontenot/Exam2Practice2_CalebFontenot.class new file mode 100644 index 0000000000000000000000000000000000000000..1b8a450d09f8d2b194320aad931012a56f8b827d GIT binary patch literal 714 zcmX^0Z`VEs1_oOOWiAFL24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00SP6iGJPId+^9tLg(9u(!lmBl5gxr_|V`K2X{45B_@gEI5=1Bx>9N`gy@ zQWJBnIT-jD8F)NWb8_+(!t;xAQWUuu1Q-O_8H9Kkgc(E_8HBOuVq{=10GW}K$H*Y6 z0WlZsz~GXi%)E4K%`kQbF-8WT-*$Ud+fKj76G}LBKb)BqKj1 zAh9ShH?<_SsF;y~D>%QjC^^+F6XX*`d?BC*iU|fq22lnk1`uFkU<9QQ21W*P1_lOw z21W)(1_lOJt?dkq8yOfFm>47&7#P^Vg4_&}3=9lBU^Xj*6oWJa0|O_641+8K6Iio3 z1IRE22F^_k>_WWT82AwefKnp^10Mqi13!`>oD6ad@(c_N3LqO98RQrk7#JB8!L}*^ E0A2#Gc>n+a literal 0 HcmV?d00001 diff --git a/Semester 2/Exams/Exam2-Practice2_ChloeFontenot/target/classes/com/chloefontenot/exam2/practice2_chloefontenot/Vehicle.class b/Semester 2/Exams/Exam2-Practice2_ChloeFontenot/target/classes/com/chloefontenot/exam2/practice2_chloefontenot/Vehicle.class new file mode 100644 index 0000000000000000000000000000000000000000..5e83cb95e2b92343a289cc15a032506c97a70a58 GIT binary patch literal 1808 zcmX^0Z`VEs1_oOOCoTpi24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00SP6iGJPId+^9tLg(9!3W9DEFF3=Dic4EziNj11zriP@>n z`FY8SCE=MR8P556#U+V(CB=*kY8se2H8F)iz7yhM5M~fzWZ+0oEpg6CEG}kb5Y|9e z3l_BIVi02xXJ?S$VUT2yVq_2mJFK)MGY1+F#f%JWsfDG9ImL_&>d3Z3!pR!Ra;S)A z6gz_qBZDy5Byf;A=j7+5CMM;ivNOmrGKe5an32KKhs>C;W@HdW_6;-^G{YDf1bkCVGV)Ub z5{nXZQ%h2dKp~KxS`r3|I1!W(glb}BU@L~obCl#m1ksF#2Mr?wbAD15Y6^f#GBU8{ zmt>?CF*5K5mn0@<`z97ZJ2c1t?itGBT)u zltMCDW?or-cB(!ktRN}fEit(yzo?RtVFq%%Kovp^^+?Q1$w@6%@yXB6E-gUzBE%qM z5fqIfl?AEDl2GN*NFfJ}1mp|?HNrVDCnq?wB-NUO!J3hQ59;sgvdlbN##%-O9?!hI z)FNx zU}Inem0t{u4Dt*N4EhX=42%p646It)85lP*FfcGNC_oi4FbFUxGB7akKol@2F(@-I zfHkWyFo8AOfsJQi-~wsZ(%#Czj&6b=*aR^KCI$uuE~p707B|>bRglGu4BTL2)fm(< z+_Z&(eFK`Cguo`EyGerq<|Zqso7k|rM;NRd;vP1*d)UB1!^nW*9!}${^362DV;-ff-~4+*jHR+6+42Amw4uWl&~dV$cJHHv=;}D-X=8+6)W~EDZYK lFg9Q?1k*+g#taM$91M&MAdg!y*ns1Xk-?V1p23kp5&#c!p& str2) { + return -1; + } else if(str1 == str2) { + return 0; + } else if (str1 < str2) { + return 1; + } + return Integer.MAX_VALUE; + } + +} \ No newline at end of file diff --git a/Semester 3/Assignments/Lab_ChloeFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/chloe/lab_chloefontenot_maximumorderedstring/FindMax.java b/Semester 3/Assignments/Lab_ChloeFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/chloe/lab_chloefontenot_maximumorderedstring/FindMax.java new file mode 100644 index 0000000..c9369ae --- /dev/null +++ b/Semester 3/Assignments/Lab_ChloeFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/chloe/lab_chloefontenot_maximumorderedstring/FindMax.java @@ -0,0 +1,47 @@ +/* + * 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.chloe.lab_chloefontenot_maximumorderedstring; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class FindMax { + public static String findMax(String input) { + int iterationCount = 0; + ArrayList possibleSubStr = new ArrayList<>(); + String currentStr = ""; + for (int i = 0; i < input.length() -2; ++i) { + currentStr = input.charAt(i) + ""; + for(int j = i + 1; j < input.length() -1; ++j) { + iterationCount++; + if (input.toLowerCase().charAt(i) < input.toLowerCase().charAt(j)) { + currentStr += input.charAt(j); + } else { + possibleSubStr.add(currentStr); + break; + } + } + } + System.out.println("Iteration count: " + iterationCount); + System.out.println(possibleSubStr); + Collections.sort(possibleSubStr, new CompareSize()); + return possibleSubStr.get(0); + } + public static void main(String[] args) + { + //System.out.print("Enter a string: "); + //Scanner input = new Scanner(System.in); + String inputString = "abcdabcdefgzabcdefadcdefab"; + //input.nextLine(); + System.out.print("The maximum sorted subString is: "); + System.out.println(findMax(inputString)); + } +} \ No newline at end of file diff --git a/Semester 3/Assignments/Lab_ChloeFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/chloe/lab_chloefontenot_maximumorderedstring/FindMaxOrderedSubstring.java b/Semester 3/Assignments/Lab_ChloeFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/chloe/lab_chloefontenot_maximumorderedstring/FindMaxOrderedSubstring.java new file mode 100644 index 0000000..81261a8 --- /dev/null +++ b/Semester 3/Assignments/Lab_ChloeFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/chloe/lab_chloefontenot_maximumorderedstring/FindMaxOrderedSubstring.java @@ -0,0 +1,38 @@ +/* + * 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.chloe.lab_chloefontenot_maximumorderedstring; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class FindMaxOrderedSubstring { + + public static String findMaxOrderedSubString(String input) { + String outputString = ""; + int j = 0; + for (int i = 0; i < input.length(); ++i) { + if (i == 0) { + outputString += input.charAt(i); + } + if (input.charAt(i) > outputString.charAt(j)) { + System.out.println(++j); + outputString += input.charAt(i); + } + } + return outputString; + } + + public static void main(String[] args) { + Scanner input = new Scanner(System.in); + System.out.print("Enter a string: "); + String inputStr = input.nextLine(); + System.out.println(findMaxOrderedSubString(inputStr)); + } +} diff --git a/Semester 3/Assignments/Lab_ChloeFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/chloe/lab_chloefontenot_maximumorderedstring/GenericMergeSort.java b/Semester 3/Assignments/Lab_ChloeFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/chloe/lab_chloefontenot_maximumorderedstring/GenericMergeSort.java new file mode 100644 index 0000000..ad16450 --- /dev/null +++ b/Semester 3/Assignments/Lab_ChloeFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/chloe/lab_chloefontenot_maximumorderedstring/GenericMergeSort.java @@ -0,0 +1,105 @@ +/* + * 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.chloe.lab_chloefontenot_maximumorderedstring; + +/** + * + * @author chloe + */ +import java.util.Comparator; + +public class GenericMergeSort { + + public static > void mergeSort(E[] list) + { + mergeSort(list, + new Comparator() { + @Override + public int compare(E e1, E e2) + { + return ((Comparable) e1).compareTo(e2); + } + }); + } + static int recursiveCallCount = 0; + public static void mergeSort(E[] list, + Comparator comparator) + { + + if (list.length > 1) { + recursiveCallCount++; + // Merge sort the first half + E[] firstHalf = (E[]) new Object[list.length / 2]; + System.arraycopy(list, 0, firstHalf, 0, list.length / 2); + mergeSort(firstHalf, comparator); + + // Merge sort the second half + int secondHalfLength = list.length - list.length / 2; + E[] secondHalf = (E[]) new Object[secondHalfLength]; + System.arraycopy(list, list.length / 2, + secondHalf, 0, secondHalfLength); + mergeSort(secondHalf, comparator); + + // Merge firstHalf with secondHalf + E[] temp = merge1(firstHalf, secondHalf, comparator); + System.arraycopy(temp, 0, list, 0, temp.length); + } + } + + private static E[] + merge1(E[] list1, E[] list2, Comparator comparator) + { + E[] temp = (E[]) new Object[list1.length + list2.length]; + + int current1 = 0; // Index in list1 + int current2 = 0; // Index in list2 + int current3 = 0; // Index in temp + + while (current1 < list1.length && current2 < list2.length) { + if (comparator.compare(list1[current1], list2[current2]) < 0) { + temp[current3++] = list1[current1++]; + } else { + temp[current3++] = list2[current2++]; + } + } + + while (current1 < list1.length) { + temp[current3++] = list1[current1++]; + } + + while (current2 < list2.length) { + temp[current3++] = list2[current2++]; + } + + return temp; + } + + public static void main(String[] args) + { + Integer[] list + = { + 2, 3, 2, 5, 6, 1, -2, 3, 14, 12 + }; + mergeSort(list); + System.out.println("number of recursive calls: " + recursiveCallCount); + recursiveCallCount = 0; + for (int i = 0; i < list.length; i++) { + System.out.print(list[i] + " "); + } + + System.out.println(); + String[] list1 + = { + "ABC", "abc", "abm", "Anf", "Good", "Bad", "nice" + }; + mergeSort(list1, (s1, s2) -> s1.compareToIgnoreCase(s2)); + System.out.println("number of recursive calls: " + recursiveCallCount); + recursiveCallCount = 0; + for (int i = 0; i < list1.length; i++) { + System.out.print(list1[i] + " "); + } + } + +} diff --git a/Semester 3/Assignments/Lab_ChloeFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/chloe/lab_chloefontenot_maximumorderedstring/JudeFindMax.java b/Semester 3/Assignments/Lab_ChloeFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/chloe/lab_chloefontenot_maximumorderedstring/JudeFindMax.java new file mode 100644 index 0000000..507c602 --- /dev/null +++ b/Semester 3/Assignments/Lab_ChloeFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/chloe/lab_chloefontenot_maximumorderedstring/JudeFindMax.java @@ -0,0 +1,56 @@ +/* + * 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.chloe.lab_chloefontenot_maximumorderedstring; + +/** + * + * @author chloe + */ +public class JudeFindMax { + public static void main(String[] args) { + System.out.println(consecLetters("abcabcdgabxy")); + System.out.println(consecLetters("abcabcdgabmnsxy")); + System.out.println(consecLetters("abchjsfhajshfhijklmnopqjfaksfhkajhsf")); + System.out.println(consecLetters("hnafffgardghikortmmnmnmn")); + } + + public static String consecLetters(String input) + { + String consec = ""; + String maxConsec = ""; + + for (int i = 1; i < input.length(); i++) //n - 1 + { + //If two in order + if (input.charAt(i) > input.charAt(i - 1)) + { + //If length is zero then add previous as well + if (consec.length() == 0) + consec += input.charAt(i - 1); + consec += input.charAt(i); + } + //If not in order + else + { + //Check current consec length against maximum length + if (consec.length() > maxConsec.length()) + { + //set new max + maxConsec = consec; + } + consec = ""; + } + } + + //Check current consec length against maximum length + if (consec.length() > maxConsec.length()) + { + //set new max + maxConsec = consec; + } + + return "Most letters found in order: " + maxConsec; + } +} diff --git a/Semester 3/Assignments/Lab_ChloeFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/chloe/lab_chloefontenot_maximumorderedstring/Lab_CalebFontenot_MaximumOrderedString.java b/Semester 3/Assignments/Lab_ChloeFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/chloe/lab_chloefontenot_maximumorderedstring/Lab_CalebFontenot_MaximumOrderedString.java new file mode 100644 index 0000000..9fd5baf --- /dev/null +++ b/Semester 3/Assignments/Lab_ChloeFontenot_MaximumOrderedString/src/main/java/edu/slcc/asdv/chloe/lab_chloefontenot_maximumorderedstring/Lab_CalebFontenot_MaximumOrderedString.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package edu.slcc.asdv.chloe.lab_chloefontenot_maximumorderedstring; + +/** + * + * @author chloe + */ +public class Lab_ChloeFontenot_MaximumOrderedString { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 3/Assignments/MP2-chapter4_ChloeFontenot/src/MP2_chapter4_CalebFontenot/BallControl.java b/Semester 3/Assignments/MP2-chapter4_ChloeFontenot/src/MP2_chapter4_ChloeFontenot/BallControl.java similarity index 100% rename from Semester 3/Assignments/MP2-chapter4_ChloeFontenot/src/MP2_chapter4_CalebFontenot/BallControl.java rename to Semester 3/Assignments/MP2-chapter4_ChloeFontenot/src/MP2_chapter4_ChloeFontenot/BallControl.java diff --git a/Semester 3/Assignments/MP2-chapter4_ChloeFontenot/src/MP2_chapter4_CalebFontenot/BouncingBall.java b/Semester 3/Assignments/MP2-chapter4_ChloeFontenot/src/MP2_chapter4_ChloeFontenot/BouncingBall.java similarity index 100% rename from Semester 3/Assignments/MP2-chapter4_ChloeFontenot/src/MP2_chapter4_CalebFontenot/BouncingBall.java rename to Semester 3/Assignments/MP2-chapter4_ChloeFontenot/src/MP2_chapter4_ChloeFontenot/BouncingBall.java diff --git a/Semester 3/Assignments/MP2-chapter4_ChloeFontenot/src/MP2_chapter4_CalebFontenot/MediaType.java b/Semester 3/Assignments/MP2-chapter4_ChloeFontenot/src/MP2_chapter4_ChloeFontenot/MediaType.java similarity index 100% rename from Semester 3/Assignments/MP2-chapter4_ChloeFontenot/src/MP2_chapter4_CalebFontenot/MediaType.java rename to Semester 3/Assignments/MP2-chapter4_ChloeFontenot/src/MP2_chapter4_ChloeFontenot/MediaType.java diff --git a/Semester 3/Assignments/MP2-chapter4_Java20_ChloeFontenot/src/MP2_chapter4_CalebFontenot/BallControl.java b/Semester 3/Assignments/MP2-chapter4_Java20_ChloeFontenot/src/MP2_chapter4_ChloeFontenot/BallControl.java similarity index 100% rename from Semester 3/Assignments/MP2-chapter4_Java20_ChloeFontenot/src/MP2_chapter4_CalebFontenot/BallControl.java rename to Semester 3/Assignments/MP2-chapter4_Java20_ChloeFontenot/src/MP2_chapter4_ChloeFontenot/BallControl.java diff --git a/Semester 3/Assignments/MP2-chapter4_Java20_ChloeFontenot/src/MP2_chapter4_CalebFontenot/BouncingBall.java b/Semester 3/Assignments/MP2-chapter4_Java20_ChloeFontenot/src/MP2_chapter4_ChloeFontenot/BouncingBall.java similarity index 100% rename from Semester 3/Assignments/MP2-chapter4_Java20_ChloeFontenot/src/MP2_chapter4_CalebFontenot/BouncingBall.java rename to Semester 3/Assignments/MP2-chapter4_Java20_ChloeFontenot/src/MP2_chapter4_ChloeFontenot/BouncingBall.java diff --git a/Semester 3/Assignments/MP2-chapter4_Java20_ChloeFontenot/src/MP2_chapter4_CalebFontenot/MediaType.java b/Semester 3/Assignments/MP2-chapter4_Java20_ChloeFontenot/src/MP2_chapter4_ChloeFontenot/MediaType.java similarity index 100% rename from Semester 3/Assignments/MP2-chapter4_Java20_ChloeFontenot/src/MP2_chapter4_CalebFontenot/MediaType.java rename to Semester 3/Assignments/MP2-chapter4_Java20_ChloeFontenot/src/MP2_chapter4_ChloeFontenot/MediaType.java diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/AddressBookFX.dat b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/AddressBookFX.dat similarity index 100% rename from Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/AddressBookFX.dat rename to Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/AddressBookFX.dat diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/build.xml b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build.xml similarity index 100% rename from Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/build.xml rename to Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build.xml diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/build/classes/.netbeans_automatic_build b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/.netbeans_automatic_build similarity index 100% rename from Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/build/classes/.netbeans_automatic_build rename to Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/.netbeans_automatic_build diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/build/classes/.netbeans_update_resources b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/.netbeans_update_resources similarity index 100% rename from Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/build/classes/.netbeans_update_resources rename to Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/.netbeans_update_resources diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/com/chloefontenot/mp5/files_chloefontenot/AddressBookEntry.class b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/com/chloefontenot/mp5/files_chloefontenot/AddressBookEntry.class new file mode 100644 index 0000000000000000000000000000000000000000..bdde0adadde28b8e70ad34d469cb431082ed82f7 GIT binary patch literal 1901 zcmX^0Z`VEs1_lQPD=r2m24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00S4h9ZJ1|iqHlGGxFM1{P>+*E~()S^^9P6jRpZgvJ99tK_pK1K$sv7Lc)w3_?B# zw*;3IW#*+@b1(=nGKj!zFD@xcO)Wv#FT}$j46>XJBEi8RisaPf%#uokQgI#z36N42 zkT3^>6eEK$!qmhPBu~lkFvx;bvKE&lmZWkp$TKns!jx8J79fmNQV1KQ)-N$P6`~fx;tI|$ElN&x%LGM*5K`K6i_inb7lQ%=C`T|dC^N7! zFo6;?0|NsSC|!YR2?jneEeoZUz%&m7BPjPUFfynzFfgPtFflMPFfb@f0Eg`wB3o<-GYByB zFo-eqGRQFWF(@(gGpI8#Fo3LKU{GezV9;b>09&cWzy!8(3Ih`Z8v_G_0@zAzkc~PZ z3w1&ENwR?KlVrtW-y{YWhRF<^3{x2R7^X4^GfZQUWSGt%&oBdQpB=SluLz?xtm66Vcsdh}})nh&YD0X*B~Y z!y2#&m~H}vAlyx$uwrB|!s;e5bT@4Pn~3fvW9)7cLwD0w23Ce`U=uLi1WNL7H-X}i zk--G3n*`C_vX~yGan;P5T*G84iF=z;u%^10N#pKxvDS!3?XLIMLm71Z*O@ io6NDhi4)yTCmC27PJvCpbQ3SKn?Pxvk--9-m@NTJ*E4kh literal 0 HcmV?d00001 diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/com/chloefontenot/mp5/files_chloefontenot/AddressBookFX.class b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/com/chloefontenot/mp5/files_chloefontenot/AddressBookFX.class new file mode 100644 index 0000000000000000000000000000000000000000..aca1ce43979eae8bb3c046ad053ba23897d5dacd GIT binary patch literal 5835 zcmX^0Z`VEs1_lR42`&aE24;2!79Ivx1~x_pxva#p#Iy?i#DapH%;dz9%=|okM+BRZ zfz2i}FSEpsk%3u5GmM>qgONcPq(#59Br`|fv8X7q(kHXHgo}Zlftizmn}LU&ftQDY zkAa_&!8|!XS3fx;CqFeUKd&S;FTX@Tx4=|CEi)&zI388pF(suawYb&&VL^gT+Q`b_PL41{sh{T7`aba%x_xeokU#erbumdr@XeKw@4h7lQ!Et0IgH zQYgxj^YcoI@^kck5|dJMI2gnj8Cd)hb5pq(gc&42!6M1XAgTeeGbb@GT|c;_C^IkJ zS~Cn}pfnGI41+8q19M_Z3L}FAL>=4(e)%b>)}Ef4VH^zdj0|kSB}J*JB^(Tjj0`N! znI)AR49biQtidITC8-w6661U9MoD?nwH3nvo?OHqx z+6+333?k{NCC>RdrMY>|`FX`9MTwbtCB=*ksv4SLcc)e8C+Fwnq$Y#nvsm9hsW`Q$ zEHNo36%<$2>5BPi-pD@r&RoEaH70*X@0GV@D|IT&0S8CZN0K`PuC8Q4M#QW8s2 zIT<_|yx1AMc^G^ce4(j0twKLNH9t4Cq^MFqAitQAfz8>~FT^znmgdmptwB-X&%+SF z5Xi{DQ=D4jn3I{Fmz$bbf}9eNO|;ewV{=dehadw;b0`l(7=tk*1AB35iAQ>3fe-@& zLj(^)BtsM<16xL7UP?|XBZDj=7E{Yo^GftxL8J#*w#XV33Nbtku?%sH4BW-3CH{Gi z;Am!Kkb@^iEZQ`~gcukZB7_*2Km;?0U;z=V3=!-Msf-LlC@~NW%1>MjDGceLIL|=# z9wdqa5{pvvO2By{iy@nxA%}+{mmv?yn3BZwRQ+HO$;iM_oLT}lk&!_h?na0?U}2~+ z1w0IepfZW2I3vHDouQbKfd}L${mguQx6GVW4u(=j20@gfLN6t;go~kwK>|cn@Gw*| zR53EJrB-AXgK`721}JsaK(jx{7)YY?FD)r3Edk}t#9VfUIz|QwWNVORxfp608bBe? z$jBfFaXH8skZZthu4ZTk$+j>uNFrpB4X_54nQbJMg)WIDiO%_XC5f4NsYP52t)Prw z&Ctoi(8bWr$iQ7*lv$Dr@du6^6~@I-&Ctuk&<6@j*5sW0;#78q3D6X;4=&L{GK%uc zLFEA#LqEeL9)`&bQy3X|6H`)xOA88$Qj3dI5oH^i4zQ1=!A#4{*Z1^ytw>HS0F^YH z3^N#JvNO!$VVKP@hmk=59IRjqgDZhK}gELK3xqO#HT0#iLK zb)+6r!gtLpDXO$nNKVYl%P&z#N>xbC&nrtUDoIUID9MLdlbNpv@--L3Dp2NF#L&ym zu#u4gEC-2D=bXgiV!!+nxBSw)6u5`j88)NF8@TG@V&G=j%EPdYVLKxOTTWtWUUCK_ zgP2A%xUPX12d^U;890M8)AJHbN{dn%8G<27K%Pc47HoXTY8iliZEa@_s!Q`zQW+We zeKPY>{YrC_Qj0=BVb91QcEi6p|CmzbLhZ#pnCD4^Pe(YUZ?WZ*9bH&l=`@g`@M zR3h>Dib0JQBmthP%mO4XXJSeUq`GEgki~8xMB18>fjbRUdqcR43|x7s6(ukZUjeiZ zhY4`yBo@PEc}l@GIZTcfT!kQqIXEaGRSF{m7d%xLvoqX;l~~|>43}YK5b#Yc$;eL$ zNGwXsO)W_+DrRI*&M!*W%S$auN=?iw)(g%rElN)HNi9pwaRlWza2vT8W-BE1`d#T3+D0qaVu(1)};Ang%wqXnEd7*iP;q;M-iH_-%Lz!+V? z2wlJsUBG~mfeR9Gpi+>LK?tezbc@gfmBfq;0#5n)C7{N00VE9+^RqF0=VJK5@ROb4 z7Z1a4hChr9N+6|>NY2bF%g;{L_W}FfH?<@&Eit(yzo?RtfjbwOcLv%N07nW`6T|{Y z6RudrCqF;Cw7?o1BoMQq#V3*oipG%2f>dPX#7jb~#IG09XMi{aYO-@;PEK%UNvgE~ z!$0I=4-&z!sO4v4WZ+`pW@O}H_{8v9fZ;Vi8zT!yfR%^gBbdhy;&JdWd;s&fKs;_9 zhWB6|FNnv-!|)Ew69Dl9c^F#fjL0l$}uw+Lywu zl#ziA68;Q|4BQM%3=9m63=E(iD+43L4h9AWCWf61oD7Vh?lA)+!!8B}20I33uo?la z?F@`syBXLcw=-~VW#HNfR=t~nfdSO1W?+zKU|~>X*u%iUzyndwu$KYU>tV zx?qRzX0VJDvfj>MYsC#_+JTrnV5S3z$qQyWftY+?rVEJ44`#Z7m;#cllH6dUBv~bS zAP!)a`omuummfB?Z7v(vf6k2Dx5m6NAS#20uww5r&{`3?Y)-yBNY5 z7`8D)OY-buh=;IvcQGVDSbVz}5+N-9T?|POmcTBCWH4(tLrSF1c7`-7L2XIFZ48;( z+Zgf@sbC+2J_7@T8UqJ|I)ea%27@GnCW8`#4uc_sE`tMu9)mxFK0`c%0Yg56Awva& z5kn(`F+&%F3BzOtQ-(PVW(-Rh%o)}&STJm1uw>ZFV8w8Z!J6SbgAK!D23v+#3=Rxm zLH%6@Cq`}tXGSpw7e++}S4JHMH%3zicSbt~4@P$ePsRWSFUCj)Z^k4BAI2;OU&cZP zKgLRi0LEs9V8&jCFvjT&k&Fu&Vi;F5#4~PXNM_v6kivMBA(inYLmD{cZiA#wXv$?^ zJjHO3;Sd8O0|(CY7MD_5e60pCB_vD#~F?=urgFI z1~HsqILW}q(8%b?aEjq113N<(qXWZfhLa2&43inn8O|`AWZ-0&!>Gq_mf<7=7sFSE zs|@ED&NFZ`GBBKCxWI6pfrpWsVL!t~hVu-(jA9I17%nlKXW(O0WLU{?nc+MGKcf!A zJccU_=NSYT_cL%aTxGb%Ajoi?fq{XAfsx?`!z~5|23AIfgA5D|w;321*cccY?l3Sg za5CIw*v`NN%7l!68CV%u85kI5?Pe&76e`)yQ0Ak(jiG!NgX?aF>d4&;wUOG}8S1w) zH2Lc6W@wGv&d|P%p+jdIL(g&sQ9lUHZN;K1$+C@MqVE3X48Fdb7^drNW0<>~!D%0G~@0ZAu98#j!}yq96q4u&lo8Q2*V8FUzo z8TuJa7%Uj98TuIn8C)4W7^X5LGvqSlGW0X#F%&VBGW0V9Gt@KGGfV~3T?`u-m>EDt zQV@d(0|P@A0~bR!gCIi=gCavNgAPL;gE2!6gDXP;g9k$%gC|2iLjXeoLoh=zLox#+ zLoP!xLp?(&Ljyw@LpwtyLl;9iLpMVO!z6|phM5et-~{3Uc9{ypJ%;-XObnh3>g&0V>4K&<_@6|H;7U#Lh64>pz1eLdPPo9Ey%ba2@{{ z7#Wx#27#1K^ZTnC&C(oFf}qTGkgYDjb9kPf~!w9hHnha q41XE^GcrL~jLdKr8=S=nXYs&U{ESSDpfNHo21Z623?qXqig-?9WqxUiesD=*a&|ysUMf3-93z7uiW0y4lvFMTX$A$5 zor;VM;u_IlccxW9Jr7b~tr^DV(82%)Yz}o`nt_W!l0hA$OM{U?3gS|@rhvqv)VvaF z7Z*^JYB6ZDGwARz=rZUbIlLq>Jr(4#^i)O$j^fl3updD7qgoFZwuTsEz{6k&N>ePw z8TsYx491KM0wBL2M=TeEDT5h1gETQge4Ybg7{EDmXeIjVnzmi zAClZ*&B(x7T#{H+f)X5v00TP&qyiLnBJl7+QUG!edeDGO%>kugMg|$U9#FzTP2V78 z;AGFpfG`@Y3=$QL3fONvVl>#d^W{rA5i9 zKB;A?IgWXG`6b|7Uko!35~TiRsYOMZDXG?s3@o{cnR$#1EQv+w#f%KXkn{&p1_CM8B;&dzCYR(FRWdTnfTUp*g%CqM67y1WQj1l5^7FGx3#`F`2T=xf zACd^v28hOx%7RoZ%8`BOpOlrFTw;w}581xw!85kKD7+AHoGcays zU|?Wkux4OjU;_*CGT1OMFz|rctPHjcb_@&*j12Y+4h+m-&D$6_7}yvX7@T%6u>0;{ z;Pu9#Fer&IsBC9Yvtrej zWZlM~slAOsA7Qf`13Lo)gCGM7gAfA;g9w8JgD8VJgBXJ?gE)gDg9O+`b`V>kE@EJC zVsK<|Vqj!oVX$N1W^iU;V&Gt~V&G?RW?*KJV9;W4VQ^(&VK8UlW^iM0XJBRU0C|{^ z!I6Q1!4v9PF9rq%P6lrVO9m#e*UX^d!oj?k!Dt7A3BrM(%94RWnt`1`2J9F}@Nh8r zF!(Ysz>M}`U|?Wo@B@dZKSKZm0|N&GBSRnqBSSbtBm)Bj7Xu?h6hjO{9D^hPcQNsi literal 0 HcmV?d00001 diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/com/chloefontenot/mp5/files_chloefontenot/DataContainer.class b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/com/chloefontenot/mp5/files_chloefontenot/DataContainer.class new file mode 100644 index 0000000000000000000000000000000000000000..abe17cf8a1d1ef54b5319a4831026c078f3ce60e GIT binary patch literal 1982 zcmX^0Z`VEs1_lR)C@uyj24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00SP6iGJPId+^9tLg(9!3W9vn0bgKd-nXF|VYU zkwIMpVhK1rf=h}r^U|$7H8I767#JB8L8d7&GN@tEgH;O?gCZA$DuWt3gE|j`27@L_ z;6p59WMD5#%qdOvPeU^o5;xXZ&1GiL202BCk--v+Q!pLxg2fbe20caw5pV!!=IaNi z7G);pWL706<)kt)usG+Zq%tz_`();&`jzG;r51%iB!qnOlM{2o5{oiHe5fExNk(Qd zBZH+6nJLAZk%2oswZs#iT39qRqdgfJ_|j8LoRQOmkOtHr@C0Pd$iSbTTH=C|0+=;4 zT^JcSO7dYLECSPq9LbCfjG2rKjGl}PoSAtgFr`A6fycdNlsPbqe6R;#*s1eSIIXS_ZC8^dN48DvEOpJ^i4E`WGmV+UX zk%5^}M}dPOn32H(r6j3_l_R!{ItoYy1c-~A_iY(#85wvy^YT)QoO2S3i&Kl)8NwJD zR55}ITL`c-L@+YQ;aAGYzy=8}1_cHV1||kZ23-bb1_n?$2`-g{7=*#J1cM|40|P4< zvoSC-=rb@dq%g2DFfuSO=xJ?dVANvY!xhQQ;vdPv>L1C<<{!z%?!T3RU28W3Z{&6c z{;doGS|SW0TN%VQGB7YOF&Ho~FbFZQFfcIaGO#e{F-SA$GpI2bFc>m0Fz`T3WiVne zW?*1oWH4bch1#gkzzCLO)!M?qz5#9!$UzJYCPw3z{udhz`(%A!19-Ym7PJAQHSjp11p0g0|NsnkewJ97?>HH!QOXa qaAja%kYZqAaARO(@Bx#4U@`zq1~G&%Ffed2FfxQPgfm1kNCE)Ct<^IC literal 0 HcmV?d00001 diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/com/chloefontenot/mp5/files_chloefontenot/Exercise17_01.class b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/com/chloefontenot/mp5/files_chloefontenot/Exercise17_01.class new file mode 100644 index 0000000000000000000000000000000000000000..4754280c013708cf2ec7a6fd0bfbec69bb5d13bb GIT binary patch literal 2177 zcmX^0Z`VEs1_lR)axMlY24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00Sb_Nbc1_`jD%zXWz#JrUJT*u_()Z${d%$!sX1};VhLD!1ZqU6ltR73N4 z14F%%iV_Y69!3VHqH-<Mf{8m>KZ;^Q@~aQmlS2@rCVc)Xohhz2r>wBLg4U5U{6w6H77}8Q6-zVFV667d8ha1~3p}U|>+^VbEaEWMmM} zP0UVp&d*CuED6sn$#BlkD=taQD=7xq=&1?u7T7>&D1n@<&BLGrax*K~bs!NvkT2Lk zA#A|IV8~#^$iPuvlv$GMnODNdz@p))8OFh2!pI;WUX)*w3JQdhj8t$yC={21<1ei= zC#O=8gTaiEfe#dy3d#9-C8>EO#a19gEqE9#8LSu?Sc+3qvq1)WfxOPnV8g>;%V5XI zz+RM^m;$zoSwqv4oxy>TK?EEWnfdyz{%)=n$*Bb;nfZAjvz&MsoIz=gH9050IF+5j z6&ChjUxs89<(DTW<)m^kxG=c$FnBO{GBWTcrlbUy78Dev78j?cFfvFW#|2!6H7I?0 zqnL(du_S{pD2)6-;ffThkYo zb4CUh=lqmZMh1SL%)C^;(%hufq7aZT7#W0o@{<#D!V-%zL42qnOG!p%F(ZSe51IB^ zGcvH`CT8X_GKgtJBl!lJMl{1185lDe85lho85mO;8N?t;&?3W{k%0#sZzZWki6!|( zj0|ibk9ztuGDyKSpyzRGMh2$T3V4PC#~D17LC#7nN-t()5XRyvMh4#ClEma}-^2oN zFt9TuF)|4Frj}&nrvxMxCFZ7I$PgAhtM>wyv#BZGibett=D zNl{_}M0YVi8$%WsLpDPWJ3}rgU*$0}sDPA0in7eSvi$5+eMsOyvYK0Ba!GzsB_qQO z&)088lv2_tX_plA%KEJ($o963Z_sSeW!=fs?x;LMU# zYYv72Mg}HE1x5xQ&%C_UBIlgM;^Nd|c7|d`22~8dVRJG&Ln$MJ9Db#Y3~UhpF(@+l zGcbWmCng3)P;J1#$PmcDz@X2-$iT?Jz`&}toq=&90|NsSLl6T40~=V7pCOomfq@6i zW@QLr2xVYk;A9A62xnjdX=Z%Fz{0@Fz`(F=Hv@a55T_9Lb_QM_X4_2+0zzWj7$jKi zWCcV`q0PCC!JNfz6N7;EHU?{)CV(~HwPIP$z^uKE!Erf*urGw> z^wZJZ#^9#2e>nrU55yFojSMUd84TSFeGK*tJPeZ=W-+)h%x0L+u!zBhfq`Ka!&(L} z24-+*K233Y81~rBb1`UR825p8u22F+u3|b768T1)uF$goPVlZS_ z%b?G&j=_LoD}ymO)IAv386+4i86p@W8JHO+FfcPjF+?-4Fz_+7GAJ=bGB7b@FlaNx zfMt0Y<}t)F#4#{3tYctjh-XLu$JjQ8M1~{=28Lt?1_mnz-hT`d>cOkOZ0OKO!d<;b5e`rQN>X#V`Sg}sR_=kN@ZkV^yFd?We{U$5a(f# zV31^F;6qsKn^=;;$iP;Vn3s~D3-*}{n}Z4i7=T#zoetrpC*%zS-Mf7goS)Pj=C{5(zu9R^)?20b1IeFg)RI0~*T zE=dJ>AiuPPkwFv^w3+$(0Y#a4&^WQ?VlZMbW@j+rVK8MdL$Ux#4I=}40Z2zq9$ExJ z(tx#Q7zcv|BZGK&QGQ9PLP}yuqC!c&LP{RFcyyV1^@XV47=ls0llEl1{VvvhHH6cDnPE;UAdGRoKGw?Dpu!4OD67dB& zlMQ5%q7VZkgBuqEKSLl7Ll7uVIl+->1o5GQEF~G4#f%J=K4d0*YeojfOhyKFP=fZ%D`8~d1Vv0ZB=Jf?0tXr) z$obWpk%1|-0y*Izr8;Xy2HxP3#N=$>!~&=@c|cL`S&~|mSdw4F$iM~SLUKMd=LMxE zrZ6%{qF9KO0<59RAi>EL?a9uN&&a@%o0yr$$RMT>4bg`ji<)7K3@nL7>BWo;!dRpk z8JLSpbJ-b67#Re7Q%f@PQvwo;5_3~aQj3Zi88~c`bD(7xS8#r5QF1D%z+z+&LMb%# zK*^PnLBJ_LzofXND6s%yP%%FnLoF9W9YZ}kLjx!cHZn4(fRsW?$IQI4{OnYHNC^f> zmTrm3CHX~_j0`i7b2wBX#88jKyp){OVilkK{Or;KYfS$liJ)i?bV-76v{BX@+D5VFo4!9tK&46b4}iMg}ehGlo=#GzJC+7Y25QbcPHD28K)q z1_mt#j(-e%>NFtIbRvok0&FtRf!v;JgYbYf@FWM|+6m3`0< z@?>CUU;&x2iGgnqm-lW4Yj8N(`Y_uv+i7oOu$#xAtG$iE$xaItK(hXu7_?<~F}N}? zY-8}0VM!3+Dwy^E_9h1HZ45rk|6kJH#^AS{LD&~UbNcD%Zevi@0fnB=CI)ToZ48E5 z8yJ`w1Q=Wyd>E7&d>H~6LKu`8*cf6M;^D#O#2~=Hz@W~+#-PCLK6m71|bGx zhAeOpiZB>5WHShZZTDfwVaR1*WJrJpAtM7DLo!1iLp~@V7#J8#7&!hjh%m6QGZe5h zSTiy*F#KdNfQ2bDL=;=F7BUnuFo9F;X$B?+b_NCp*G&xCn;7_ZG5CW*%yI`qzz&9B zA7)!^Kiz$1EX-!CqO77Uix@<7MOpRC*knZ65^P&o8JGWmy@^3vW*0*^SQjYOLsFC) z11AFmgAD^8gDry~gB^n?g9C#&gCm13gA;=hgCm0lgA0QTgDcqkpcJIbzzR-5Y#^sF z6f=}CFffQR7=XRX$RN(3$509m98e09U|{;spuoV!&QQkAP{0Vnj0_Av7{nRMLD`Ry zp_qYzfrFs}ob^CCQyrXe7#R4$`6wd0ZwEuvW(GcxYZ<}mACgBwL0$>Yw^a<)3=9k+ i49pBQ42%p-V6p{FwlQ=tFfed2Ffw#9bTjlaNCE%@hHSn7 literal 0 HcmV?d00001 diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/com/chloefontenot/mp5/files_chloefontenot/Exercise17_05.class b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/com/chloefontenot/mp5/files_chloefontenot/Exercise17_05.class new file mode 100644 index 0000000000000000000000000000000000000000..5c6a93bcb0b49e182f64dc9ae1c3806ac09b74d1 GIT binary patch literal 2109 zcmX^0Z`VEs1_lR)EG`Bn24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00Sb_Nbc1|G1Y%zS;f%$!sX1};VhLD!1ZqU6ltR73N415>?}#1bwBb_O1h zp}dR?q8dJ69bjXFONuh{(ycYaKq~lo7z7vu85!78D>92qiote7u`>uWGDv}SWadMi z;a^%(P+AgPQk0sQ%g!Lm$RGie2e|=RmWx4zK^$bU1S5kW)MBVp!Ila!NP%Rf85txI zvd9KlgM2B=$Y7qFpR1pok&~aAmY-LWnwMXqpIcz6pO%@ES{#om?vhxN=$xNdl9-v7 zTExX5!@$hNAjF`+!=T8Z#K^#1UX)pq3JXq@z<>xs-KE0ApbClu*5sW0;#779bw&nZ zurI;k7LrkvU!Ithlgh=Q#-Pc=pv9og$iSPJk`i26P*9XwT%4N1$RGjr5~>cck91+C zW#;R9`ny&nrxuiC=I3!T=rb6wGZ^wP7%>>5#D8#QaY&0%3#LMV9vu}0rDxtxu|Lw8Q2RzI&$*Z8LSu?B*8v{$E#-^QncDIGKj;Z zLD7mN$;DvJAkM{L$zTtPJO_kNLB2tl0S-w^1}7c{X9gEW2Ckyi#1u#vGct&1XhQq| z4jhQ6HONR6b_RDw1_iLqU^(ZU#NuMV{1UhP(!3OSNO3TDGBU`8rz)i9mnf8Eq$;E& zmLw{q73JrGd7yNm2nr8xP+;(aQh_fIgCB!GBLhcCJ|xwnI|3qV&CU==QgTDdY>W&n z&iN^+j12rfnR%&xrMXF|MIoSc!pI=xlb@WJ6P8$%3F1QqSxPc8iy0X#eTYxqDE3)1 zGO*+(X67+6h-pM41t`=nnqiC#T%fRkxizsUy_k_f7>iRG88|>u2uf*;415s7U?l}30}Duwv~WTx2CNww zc!Nt4le2vj3&26o&XB;!AmE!?l98VhkXV$Mn_7}uRLsc06`WsMl$;82h7d|v>w(fF zgCau!0}}%XFflNKifIN$h9Cw827Lxb21W)323D=@42&BY7#Nrsf*BYX*ua9K3?U2* z3_M^qD?=zl7y|)Te0X$vTS3}(A~eBf!lWzgPzVd z1`|f#-3*qIyBVxO2H0+Au=CU1#^88>LB>~i8-wd|1_>(`2!qFpRgy)LbsK|*B+LHg z3}Swp81!_vF__H4142ldY43P{`3``834D1Zi z3^5E$3`tE~pqY!&ERUj)9qhfnhyEJVOEl0|OVsQieo^Byc>(G9)vkFfcKs zGB7X{F!26oFb37vY3vN_>`R!E(R_JZgvJ99tK_pJ`@9jD~n4~a~T=9(^E?V zit-Cmi%KdP8PqgH!oa}51{P#y5M^Ls-~qE)8N?XG85kHi86+4ap_=8uG7JoCLhL&jI5#jb bFfbzNW@F%Fkiw#tAB$Qp21W*Hu0OM} literal 0 HcmV?d00001 diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/build/classes/module-info.class b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/module-info.class similarity index 100% rename from Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/build/classes/module-info.class rename to Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/build/classes/module-info.class diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/manifest.mf b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/manifest.mf similarity index 100% rename from Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/manifest.mf rename to Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/manifest.mf diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/nbproject/build-impl.xml b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/nbproject/build-impl.xml similarity index 100% rename from Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/nbproject/build-impl.xml rename to Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/nbproject/build-impl.xml diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/nbproject/genfiles.properties b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/nbproject/genfiles.properties similarity index 100% rename from Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/nbproject/genfiles.properties rename to Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/nbproject/genfiles.properties diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/nbproject/private/config.properties b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/nbproject/private/config.properties similarity index 100% rename from Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/nbproject/private/config.properties rename to Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/nbproject/private/config.properties diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/nbproject/private/private.properties b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/nbproject/private/private.properties similarity index 100% rename from Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/nbproject/private/private.properties rename to Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/nbproject/private/private.properties diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/nbproject/private/private.xml b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/nbproject/private/private.xml similarity index 100% rename from Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/nbproject/private/private.xml rename to Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/nbproject/private/private.xml diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/nbproject/project.properties b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/nbproject/project.properties similarity index 100% rename from Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/nbproject/project.properties rename to Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/nbproject/project.properties diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/nbproject/project.xml b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/nbproject/project.xml similarity index 100% rename from Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/nbproject/project.xml rename to Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/nbproject/project.xml diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/AddressBookFX.java b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/AddressBookFX.java new file mode 100644 index 0000000..6ab57fa --- /dev/null +++ b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/AddressBookFX.java @@ -0,0 +1,204 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5.files_chloefontenot; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.ArrayList; +import javafx.application.Application; +import javafx.geometry.HPos; +import javafx.geometry.Pos; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.layout.ColumnConstraints; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.RowConstraints; +import javafx.stage.Stage; + +/** + * + * @author chloe + */ +public class AddressBookFX extends Application { + + ArrayList addressArray = new ArrayList<>(); + + @Override + public void start(Stage stage) throws Exception + { + GridPane primaryGridPane = new GridPane(); + GridPane textFieldGridPane = new GridPane(); + GridPane addressFieldPane = new GridPane(); + GridPane buttonFieldPane = new GridPane(); + + // Text fields / labels + textFieldGridPane.add(new Label("Name"), 0, 0); + textFieldGridPane.add(new Label("Street"), 0, 1); + textFieldGridPane.add(new Label("City"), 0, 2); + addressFieldPane.add(new Label("State"), 2, 0); + addressFieldPane.add(new Label("ZIP"), 4, 0); + TextField nameTextField = new TextField(); + TextField streetTextField = new TextField(); + TextField cityTextField = new TextField(); + TextField stateTextField = new TextField(); + TextField zipTextField = new TextField(); + textFieldGridPane.add(nameTextField, 1, 0); + textFieldGridPane.add(streetTextField, 1, 1); + textFieldGridPane.add(addressFieldPane, 1, 2); + addressFieldPane.add(cityTextField, 1, 0); + addressFieldPane.add(stateTextField, 3, 0); + addressFieldPane.add(zipTextField, 5, 0); + textFieldGridPane.getColumnConstraints().add(new ColumnConstraints(50)); + primaryGridPane.add(textFieldGridPane, 0, 0); + + // Buttons + Button addButton = new Button("Add"); + Button firstButton = new Button("First"); + Button nextButton = new Button("Next"); + Button previousButton = new Button("Previous"); + Button lastButton = new Button("Last"); + Button updateButton = new Button("Update"); + buttonFieldPane.add(addButton, 0, 0); + buttonFieldPane.add(firstButton, 1, 0); + buttonFieldPane.add(nextButton, 2, 0); + buttonFieldPane.add(previousButton, 3, 0); + buttonFieldPane.add(lastButton, 4, 0); + buttonFieldPane.add(updateButton, 5, 0); + primaryGridPane.add(buttonFieldPane, 0, 1); + primaryGridPane.setAlignment(Pos.CENTER); + buttonFieldPane.setHgap(10); + + addButton.setOnAction(e -> { + + }); + firstButton.setOnAction(e -> { + + }); + nextButton.setOnAction(e -> { + + }); + previousButton.setOnAction(e -> { + + }); + lastButton.setOnAction(e -> { + + }); + updateButton.setOnAction(e -> { + + }); + + Scene scene = new Scene(primaryGridPane); + stage.setScene(scene); + stage.show(); + } + + public static void main(String[] args) + { + File addressBook = new File("AddressBookFX.dat"); + if (!addressBook.exists()) { + try (ObjectOutputStream fileStream = new ObjectOutputStream(new FileOutputStream(addressBook))) { + fileStream.writeObject(new DataContainer()); + } catch (IOException ex) { + System.out.println(ex); + } + } else { + + try (ObjectInputStream fileStream = new ObjectInputStream(new FileInputStream(addressBook))) { + addressBook = (ArrayList) fileStream.readObject(); + } catch (IOException ex) { + System.out.println(ex); + } catch (ClassNotFoundException ex) { + System.out.println(ex); + } + } + + launch(); + } +} + +class AddressBookEntry implements Serializable { + + private String name; + private String street; + private String city; + private String state; + private String zip; + + public AddressBookEntry() + { + this.name = "Enter a name here."; + this.street = "Enter a street here."; + this.city = "Enter a city here."; + this.state = "Enter a state here."; + this.zip = "Enter a zip here."; + } + + public AddressBookEntry(String name, String street, String city, String state, String zip) + { + this.name = name; + this.street = street; + this.city = city; + this.state = state; + this.zip = zip; + } + + public String getZip() + { + return zip; + } + + public void setZip(String zip) + { + this.zip = zip; + } + + public String getState() + { + return state; + } + + public void setState(String state) + { + this.state = state; + } + + public String getCity() + { + return city; + } + + public void setCity(String city) + { + this.city = city; + } + + public String getStreet() + { + return street; + } + + public void setStreet(String street) + { + this.street = street; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + +} diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/App.java b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/App.java new file mode 100644 index 0000000..a899361 --- /dev/null +++ b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/App.java @@ -0,0 +1,30 @@ +package com.chloefontenot.mp5.files_chloefontenot; + +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.scene.control.Label; +import javafx.scene.layout.StackPane; +import javafx.stage.Stage; + + +/** + * JavaFX App + */ +public class App extends Application { + + @Override + public void start(Stage stage) { + var javaVersion = SystemInfo.javaVersion(); + var javafxVersion = SystemInfo.javafxVersion(); + + var label = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + "."); + var scene = new Scene(new StackPane(label), 640, 480); + stage.setScene(scene); + stage.show(); + } + + public static void main(String[] args) { + launch(); + } + +} \ No newline at end of file diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_01.java b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_01.java new file mode 100644 index 0000000..a230ced --- /dev/null +++ b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_01.java @@ -0,0 +1,52 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5.files_chloefontenot; + +import java.io.EOFException; +import java.io.FileNotFoundException; +import java.io.RandomAccessFile; + +/** + * + * @author chloe + */ +public class Exercise17_01 { + + public static void main(String[] args) + { + try (RandomAccessFile fileIO = new RandomAccessFile("Exercise17_01.txt", "rw")) { + int random = 0; + System.out.println("Writing data to file..."); + for (int i = 1; i < 100 + 1; ++i) { + random = (int) (Math.random() * 9) + 1; + System.out.print(random + " "); + if (i != 0 && i % 10 == 0) { + System.out.println(); + } + fileIO.writeInt(random); + } + System.out.println("Wrote to the file successfully!"); + System.out.println("File contents:"); + fileIO.seek(0); + int readIterator = 1; + while (true) { + try { + System.out.print(fileIO.readInt() + " "); + if (readIterator != 0 && readIterator % 10 == 0) { + System.out.println(); + } + ++readIterator; + } catch (EOFException e) { + break; + } + + } + + } catch (Exception ex) { + System.out.println(ex); + } + + } +} diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_03.java b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_03.java new file mode 100644 index 0000000..e9f10ff --- /dev/null +++ b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_03.java @@ -0,0 +1,70 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5.files_chloefontenot; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; + +/** + * + * @author chloe + */ +public class Exercise17_03 { + + static int fileSize = Math.abs((int) (Math.random() * 1024)); + + public static void writeData() + { + try (FileOutputStream fileWrite = new FileOutputStream("Exercise17_03.dat")) { + // Write a unspecified number of integers into the file. + // Must be positive! + int randInt = 0; + for (int i = 0; i < fileSize; ++i) { + randInt = (int) (Math.random() * 10); + fileWrite.write(randInt); + } + } catch (IOException ex) { + System.out.println(ex); + } + System.out.println("Wrote data to the file!"); + } + + public static int[] readData() + { + int[] fileData = new int[fileSize]; + try (FileInputStream fileRead = new FileInputStream("Exercise17_03.dat")) { + // Read the data back + int dataIterator = 0; + int dataStream = 0; + while (fileRead.available() > 0) { + dataStream = fileRead.read(); + fileData[dataIterator++] = dataStream; + System.out.print(dataStream + " "); + if ((dataIterator + 1) % 10 == 0) { + System.out.println(); + } + } + } catch (IOException ex) { + System.out.println(ex); + } + return fileData; + } + + public static void main(String[] args) + { + System.out.println("Ints to write: " + fileSize); + writeData(); + int[] fileData = readData(); + // Sum the digits + int sum = 0; + for (int i: fileData) { + sum += i; + } + System.out.println("\nThe sum of the integers in the file is: " + sum); + } +} diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_05.java b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_05.java new file mode 100644 index 0000000..e248e54 --- /dev/null +++ b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_05.java @@ -0,0 +1,79 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5.files_chloefontenot; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.Serializable; +import java.io.ObjectOutputStream; +import java.util.Date; + +/** + * + * @author chloe + */ +public class Exercise17_05 { + public static void main(String[] args) { + File dataFile = new File("Exercise17_05.dat"); + if(!dataFile.exists()) { + try (ObjectOutputStream fileStream = new ObjectOutputStream(new FileOutputStream(dataFile))) { + fileStream.writeObject(new DataContainer()); + } catch (IOException ex) { + System.out.println(ex); + } + } + DataContainer data = null; + try (ObjectInputStream fileStream = new ObjectInputStream(new FileInputStream(dataFile))) { + data = (DataContainer) fileStream.readObject(); + } catch (IOException ex) { + System.out.println(ex); + } catch (ClassNotFoundException ex) { + System.out.println(ex); + } + // Now print out the data! + System.out.println("We got the data from the file!"); + System.out.println(data.toString()); + } +} + +class DataContainer implements Serializable { + int[] intArray = {1, 2, 3, 4}; + Date currentDate = new Date(); + double doubleMoment = 5.5; + + public int[] getIntArray() + { + return intArray; + } + + public Date getCurrentDate() + { + return currentDate; + } + + public double getDoubleMoment() + { + return doubleMoment; + } + + @Override + public String toString() + { + String intString = "["; + for (int i = 0; i < intArray.length - 1; ++i) { + intString += intArray[i]; + if (i == (intArray.length - 2)) { + intString += "]"; + } else { + intString += ", "; + } + } + return "DataContainer{" + "intArray=" + intString + ", currentDate=" + currentDate + ", doubleMoment=" + doubleMoment + '}'; + } +} \ No newline at end of file diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/SystemInfo.java b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/SystemInfo.java new file mode 100644 index 0000000..e403d4d --- /dev/null +++ b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/SystemInfo.java @@ -0,0 +1,13 @@ +package com.chloefontenot.mp5.files_chloefontenot; + +public class SystemInfo { + + public static String javaVersion() { + return System.getProperty("java.version"); + } + + public static String javafxVersion() { + return System.getProperty("javafx.version"); + } + +} \ No newline at end of file diff --git a/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/src/module-info.java b/Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/module-info.java similarity index 100% rename from Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_CalebFontenot/src/module-info.java rename to Semester 3/Assignments/MP3_Recursion_ChloeFontenot/MP5-Binary-Files_ChloeFontenot/src/module-info.java diff --git a/Semester 3/Assignments/MP4_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp4_chloefontenot/ArrayListASDV.java b/Semester 3/Assignments/MP4_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp4_chloefontenot/ArrayListASDV.java new file mode 100644 index 0000000..a1a0f5e --- /dev/null +++ b/Semester 3/Assignments/MP4_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp4_chloefontenot/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.chloe.mp4_chloefontenot; + +/** + * + * @author chloe + */ +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_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp4_chloefontenot/MP4_CalebFontenot.java b/Semester 3/Assignments/MP4_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp4_chloefontenot/MP4_CalebFontenot.java new file mode 100644 index 0000000..30210cb --- /dev/null +++ b/Semester 3/Assignments/MP4_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp4_chloefontenot/MP4_CalebFontenot.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package edu.slcc.asdv.chloe.mp4_chloefontenot; + +/** + * + * @author chloe + */ +public class MP4_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/AddressBookFX.java b/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/AddressBookFX.java new file mode 100644 index 0000000..05ac998 --- /dev/null +++ b/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/AddressBookFX.java @@ -0,0 +1,256 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5.files_chloefontenot; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.ArrayList; +import javafx.application.Application; +import javafx.geometry.HPos; +import javafx.geometry.Pos; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.layout.ColumnConstraints; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.RowConstraints; +import javafx.stage.Stage; + +/** + * + * @author chloe + */ +public class AddressBookFX extends Application { + + static File addressBook = new File("AddressBookFX.dat"); + static int addressArrayPointer = 0; + static ArrayList addressArray = new ArrayList<>(); + static TextField nameTextField = new TextField(); + static TextField streetTextField = new TextField(); + static TextField cityTextField = new TextField(); + static TextField stateTextField = new TextField(); + static TextField zipTextField = new TextField(); + static Label addressBookCounter = new Label("Items in address book:"); + static Label indexLabel = new Label(); + + @Override + public void start(Stage stage) throws Exception + { + getData(); + BorderPane primaryBorderPane = new BorderPane(); + GridPane textFieldGridPane = new GridPane(); + GridPane addressFieldPane = new GridPane(); + GridPane buttonFieldPane = new GridPane(); + + // Text fields / labels + textFieldGridPane.add(new Label("Name"), 0, 0); + textFieldGridPane.add(new Label("Street"), 0, 1); + textFieldGridPane.add(new Label("City"), 0, 2); + addressFieldPane.add(new Label("State"), 2, 0); + addressFieldPane.add(new Label("ZIP"), 4, 0); + textFieldGridPane.add(nameTextField, 1, 0); + textFieldGridPane.add(streetTextField, 1, 1); + textFieldGridPane.add(addressFieldPane, 1, 2); + addressFieldPane.add(cityTextField, 1, 0); + addressFieldPane.add(stateTextField, 3, 0); + addressFieldPane.add(zipTextField, 5, 0); + textFieldGridPane.getColumnConstraints().add(new ColumnConstraints(50)); + primaryBorderPane.setTop(textFieldGridPane); + + // Buttons + Button addButton = new Button("Add"); + Button firstButton = new Button("First"); + Button nextButton = new Button("Next"); + Button previousButton = new Button("Previous"); + Button lastButton = new Button("Last"); + Button updateButton = new Button("Update"); + buttonFieldPane.add(indexLabel, 0, 0); + buttonFieldPane.add(addButton, 1, 0); + buttonFieldPane.add(firstButton, 2, 0); + buttonFieldPane.add(nextButton, 3, 0); + buttonFieldPane.add(previousButton, 4, 0); + buttonFieldPane.add(lastButton, 5, 0); + buttonFieldPane.add(updateButton, 6, 0); + buttonFieldPane.add(addressBookCounter, 7, 0); + + primaryBorderPane.setBottom(buttonFieldPane); + buttonFieldPane.setAlignment(Pos.CENTER); + buttonFieldPane.setHgap(10); + + addButton.setOnAction(e -> { + addressArray.add(new AddressBookEntry()); + updateData(); + }); + firstButton.setOnAction(e -> { + addressArrayPointer = 0; + getEntry(addressArrayPointer); + }); + nextButton.setOnAction(e -> { + if (addressArrayPointer >= addressArray.size() - 1) { + addressArrayPointer = 0; + } else { + addressArrayPointer++; + } + getEntry(addressArrayPointer); + }); + previousButton.setOnAction(e -> { + if (addressArrayPointer > 0) { + addressArrayPointer--; + } else { + addressArrayPointer = addressArray.size() - 1; + } + getEntry(addressArrayPointer); + }); + lastButton.setOnAction(e -> { + addressArrayPointer = addressArray.size() - 1; + getEntry(addressArrayPointer); + }); + updateButton.setOnAction(e -> { + AddressBookEntry entry = addressArray.get(addressArrayPointer); + entry.setName(nameTextField.getText()); + entry.setCity(nameTextField.getText()); + entry.setStreet(streetTextField.getText()); + entry.setCity(cityTextField.getText()); + entry.setState(stateTextField.getText()); + entry.setZip(zipTextField.getText()); + updateData(); + }); + + // init fields with data from first entry + getEntry(0); + + Scene scene = new Scene(primaryBorderPane); + stage.setScene(scene); + stage.show(); + } + + public static AddressBookEntry getEntry(int index) + { + AddressBookEntry entry = addressArray.get(index); + indexLabel.setText("Current index: " + index); + addressBookCounter.setText("Items in address book: " + addressArray.size()); + nameTextField.setText(entry.getName()); + streetTextField.setText(entry.getStreet()); + cityTextField.setText(entry.getCity()); + stateTextField.setText(entry.getState()); + zipTextField.setText(entry.getZip()); + return entry; + } + + public static void updateData() + { + try (ObjectOutputStream fileStream = new ObjectOutputStream(new FileOutputStream(addressBook))) { + fileStream.writeObject(addressArray); + } catch (IOException ex) { + System.out.println(ex); + } + } + + public static void getData() + { + if (!addressBook.exists()) { + addressArray.add(new AddressBookEntry()); + updateData(); + } else { + try (ObjectInputStream fileStream = new ObjectInputStream(new FileInputStream(addressBook))) { + addressArray = (ArrayList) fileStream.readObject(); + } catch (IOException ex) { + System.out.println(ex); + } catch (ClassNotFoundException ex) { + System.out.println(ex); + } + } + } + + public static void main(String[] args) + { + launch(); + } +} + +class AddressBookEntry implements Serializable { + + private String name; + private String street; + private String city; + private String state; + private String zip; + + public AddressBookEntry() + { + this.name = "Enter a name here."; + this.street = "Enter a street here."; + this.city = "Enter a city here."; + this.state = "Enter a state here."; + this.zip = "Enter a zip here."; + } + + public AddressBookEntry(String name, String street, String city, String state, String zip) + { + this.name = name; + this.street = street; + this.city = city; + this.state = state; + this.zip = zip; + } + + public String getZip() + { + return zip; + } + + public void setZip(String zip) + { + this.zip = zip; + } + + public String getState() + { + return state; + } + + public void setState(String state) + { + this.state = state; + } + + public String getCity() + { + return city; + } + + public void setCity(String city) + { + this.city = city; + } + + public String getStreet() + { + return street; + } + + public void setStreet(String street) + { + this.street = street; + } + + public String getName() + { + return name; + } + + public void setName(String name) + { + this.name = name; + } + +} diff --git a/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/App.java b/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/App.java new file mode 100644 index 0000000..a899361 --- /dev/null +++ b/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/App.java @@ -0,0 +1,30 @@ +package com.chloefontenot.mp5.files_chloefontenot; + +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.scene.control.Label; +import javafx.scene.layout.StackPane; +import javafx.stage.Stage; + + +/** + * JavaFX App + */ +public class App extends Application { + + @Override + public void start(Stage stage) { + var javaVersion = SystemInfo.javaVersion(); + var javafxVersion = SystemInfo.javafxVersion(); + + var label = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + "."); + var scene = new Scene(new StackPane(label), 640, 480); + stage.setScene(scene); + stage.show(); + } + + public static void main(String[] args) { + launch(); + } + +} \ No newline at end of file diff --git a/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/CombineFilesFX.java b/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/CombineFilesFX.java new file mode 100644 index 0000000..91aa9c6 --- /dev/null +++ b/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/CombineFilesFX.java @@ -0,0 +1,130 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5.files_chloefontenot; + +import java.io.DataInput; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javafx.application.Application; +import javafx.geometry.Pos; +import javafx.scene.Scene; +import javafx.scene.control.Alert; +import javafx.scene.control.Alert.AlertType; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.GridPane; +import javafx.stage.FileChooser; +import javafx.stage.Stage; + +/** + * + * @author chloe + */ +public class CombineFilesFX extends Application { + + static ArrayList files = new ArrayList(); + final FileChooser fileChooser = new FileChooser(); + + @Override + public void start(final Stage stage) throws Exception { + fileChooser.setTitle("Open File to Split..."); + BorderPane primaryBorderPane = new BorderPane(); + GridPane textFieldGridPane = new GridPane(); + + Label infoLabel = new Label("Point me at the files that were output by SplitFilesFX.java."); + Label chooseFile = new Label("Choose files to combine: "); + Button openFilePicker = new Button("Choose..."); + Button run = new Button("Start"); + textFieldGridPane.add(chooseFile, 0, 0); + textFieldGridPane.add(openFilePicker, 1, 0); + primaryBorderPane.setAlignment(run, Pos.CENTER); + + primaryBorderPane.setTop(infoLabel); + primaryBorderPane.setCenter(textFieldGridPane); + primaryBorderPane.setBottom(run); + + openFilePicker.setOnAction(e -> { + // When we initially get the files from the file chooser, it returns an unsortable list. Because of this, we need to create a new List with its data. + files.addAll(fileChooser.showOpenMultipleDialog(openFilePicker.getScene().getWindow())); + // The file picker appears to return files in a random order, so we need to sort them by file name. + Collections.sort(files, new Comparator() { + public int compare(File o1, File o2) { + return extractInt(o1.getName()) - extractInt(o2.getName()); + } + + String findMatch(String s) { + Pattern findNum = Pattern.compile("\\d+$"); + Matcher match = findNum.matcher(s); + while (match.find()) { + return match.group(); + } + return ""; + } + + int extractInt(String s) { + String num = findMatch(s); + System.out.println(num); + // return 0 if no digits found + return num.isEmpty() ? 0 : Integer.parseInt(num); + } + }); + }); + + run.setOnAction(e -> { + if (files == null) { + e.consume(); + } + combineFiles(files); + }); + + Scene scene = new Scene(primaryBorderPane); + stage.setScene(scene); + stage.show(); + } + + public static void combineFiles(List filesToCombine) { + String outputPath = filesToCombine.get(0).getParent(); + try (FileOutputStream dataOut = new FileOutputStream(outputPath + "/" + "reconstructed_" + filesToCombine.get(0).getName().substring(0, (filesToCombine.get(0).getName().length() - 2)))) { + System.out.println("Writing to " + outputPath + "/" + "reconstructed_" + filesToCombine.get(0).getName().substring(0, (filesToCombine.get(0).getName().length() - 2))); + for (File file : filesToCombine) { + try (FileInputStream dataIn = new FileInputStream(file)) { + System.out.println("Opening the source file " + file.getName() + "!"); + byte[] buffer = new byte[4096]; + int bytesRead = -1; + + while ((bytesRead = dataIn.read(buffer)) != -1) { + dataOut.write(buffer, 0, bytesRead); + } + } + catch (IOException ex) { + System.out.println(ex); + } + } + } catch (IOException ex) { + System.out.println(ex); + } + Alert alert = new Alert(AlertType.INFORMATION); + alert.setTitle("Success!"); + alert.setContentText("Successfully combined the files!"); + + alert.showAndWait(); + } + + + + public static void main(String[] args) { + launch(); + } +} diff --git a/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_01.java b/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_01.java new file mode 100644 index 0000000..a230ced --- /dev/null +++ b/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_01.java @@ -0,0 +1,52 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5.files_chloefontenot; + +import java.io.EOFException; +import java.io.FileNotFoundException; +import java.io.RandomAccessFile; + +/** + * + * @author chloe + */ +public class Exercise17_01 { + + public static void main(String[] args) + { + try (RandomAccessFile fileIO = new RandomAccessFile("Exercise17_01.txt", "rw")) { + int random = 0; + System.out.println("Writing data to file..."); + for (int i = 1; i < 100 + 1; ++i) { + random = (int) (Math.random() * 9) + 1; + System.out.print(random + " "); + if (i != 0 && i % 10 == 0) { + System.out.println(); + } + fileIO.writeInt(random); + } + System.out.println("Wrote to the file successfully!"); + System.out.println("File contents:"); + fileIO.seek(0); + int readIterator = 1; + while (true) { + try { + System.out.print(fileIO.readInt() + " "); + if (readIterator != 0 && readIterator % 10 == 0) { + System.out.println(); + } + ++readIterator; + } catch (EOFException e) { + break; + } + + } + + } catch (Exception ex) { + System.out.println(ex); + } + + } +} diff --git a/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_03.java b/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_03.java new file mode 100644 index 0000000..e9f10ff --- /dev/null +++ b/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_03.java @@ -0,0 +1,70 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5.files_chloefontenot; + +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; + +/** + * + * @author chloe + */ +public class Exercise17_03 { + + static int fileSize = Math.abs((int) (Math.random() * 1024)); + + public static void writeData() + { + try (FileOutputStream fileWrite = new FileOutputStream("Exercise17_03.dat")) { + // Write a unspecified number of integers into the file. + // Must be positive! + int randInt = 0; + for (int i = 0; i < fileSize; ++i) { + randInt = (int) (Math.random() * 10); + fileWrite.write(randInt); + } + } catch (IOException ex) { + System.out.println(ex); + } + System.out.println("Wrote data to the file!"); + } + + public static int[] readData() + { + int[] fileData = new int[fileSize]; + try (FileInputStream fileRead = new FileInputStream("Exercise17_03.dat")) { + // Read the data back + int dataIterator = 0; + int dataStream = 0; + while (fileRead.available() > 0) { + dataStream = fileRead.read(); + fileData[dataIterator++] = dataStream; + System.out.print(dataStream + " "); + if ((dataIterator + 1) % 10 == 0) { + System.out.println(); + } + } + } catch (IOException ex) { + System.out.println(ex); + } + return fileData; + } + + public static void main(String[] args) + { + System.out.println("Ints to write: " + fileSize); + writeData(); + int[] fileData = readData(); + // Sum the digits + int sum = 0; + for (int i: fileData) { + sum += i; + } + System.out.println("\nThe sum of the integers in the file is: " + sum); + } +} diff --git a/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_05.java b/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_05.java new file mode 100644 index 0000000..e248e54 --- /dev/null +++ b/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/Exercise17_05.java @@ -0,0 +1,79 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5.files_chloefontenot; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.Serializable; +import java.io.ObjectOutputStream; +import java.util.Date; + +/** + * + * @author chloe + */ +public class Exercise17_05 { + public static void main(String[] args) { + File dataFile = new File("Exercise17_05.dat"); + if(!dataFile.exists()) { + try (ObjectOutputStream fileStream = new ObjectOutputStream(new FileOutputStream(dataFile))) { + fileStream.writeObject(new DataContainer()); + } catch (IOException ex) { + System.out.println(ex); + } + } + DataContainer data = null; + try (ObjectInputStream fileStream = new ObjectInputStream(new FileInputStream(dataFile))) { + data = (DataContainer) fileStream.readObject(); + } catch (IOException ex) { + System.out.println(ex); + } catch (ClassNotFoundException ex) { + System.out.println(ex); + } + // Now print out the data! + System.out.println("We got the data from the file!"); + System.out.println(data.toString()); + } +} + +class DataContainer implements Serializable { + int[] intArray = {1, 2, 3, 4}; + Date currentDate = new Date(); + double doubleMoment = 5.5; + + public int[] getIntArray() + { + return intArray; + } + + public Date getCurrentDate() + { + return currentDate; + } + + public double getDoubleMoment() + { + return doubleMoment; + } + + @Override + public String toString() + { + String intString = "["; + for (int i = 0; i < intArray.length - 1; ++i) { + intString += intArray[i]; + if (i == (intArray.length - 2)) { + intString += "]"; + } else { + intString += ", "; + } + } + return "DataContainer{" + "intArray=" + intString + ", currentDate=" + currentDate + ", doubleMoment=" + doubleMoment + '}'; + } +} \ No newline at end of file diff --git a/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/HexEditorFX.java b/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/HexEditorFX.java new file mode 100644 index 0000000..07bb1a4 --- /dev/null +++ b/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/HexEditorFX.java @@ -0,0 +1,147 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5.files_chloefontenot; + +import static com.chloefontenot.mp5.files_chloefontenot.SplitFilesFX.alert; +import static com.chloefontenot.mp5.files_chloefontenot.SplitFilesFX.file; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import javafx.application.Application; +import javafx.geometry.Pos; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.TextArea; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.GridPane; +import javafx.stage.FileChooser; +import javafx.stage.Stage; + +/** + * + * @author chloe + */ +public class HexEditorFX extends Application { + + final FileChooser fileChooser = new FileChooser(); + static File file = null; + + @Override + public void start(Stage stage) throws Exception { + Label label = new Label("Open a file..."); + Button openFileButton = new Button("Choose..."); + TextArea editorWindow = new TextArea(); + Button saveFileButton = new Button("Save"); + + editorWindow.setWrapText(true); + + BorderPane bp = new BorderPane(); + GridPane openFileGridPane = new GridPane(); + + openFileGridPane.add(label, 0, 0); + openFileGridPane.add(openFileButton, 1, 0); + + bp.setTop(openFileGridPane); + bp.setCenter(editorWindow); + bp.setBottom(saveFileButton); + bp.setAlignment(saveFileButton, Pos.CENTER); + + openFileButton.setOnAction(e -> { + file = fileChooser.showOpenDialog(openFileButton.getScene().getWindow()); + byte[] data = null; + System.out.println("Getting data from fileand encoding it as hex..."); + try (FileInputStream dataIn = new FileInputStream(file)) { + data = dataIn.readAllBytes(); + } catch (FileNotFoundException ex) { + ex.printStackTrace(); + } catch (IOException ex) { + ex.printStackTrace(); + } + String dataString = encodeHexString(data); + editorWindow.setText(dataString); + }); + + saveFileButton.setOnAction(e -> { + if (file == null) { + alert.setTitle("No file selected!"); + alert.setHeaderText("No file selected!"); + alert.setContentText("You have to open a file first, silly!"); + alert.showAndWait(); + } + System.out.println("Re-encoding hex back into a byte array..."); + + try (FileOutputStream dataOut = new FileOutputStream(file)) { + byte[] bytesToSave = decodeHexString(editorWindow.getText()); + dataOut.write(bytesToSave); + } catch (FileNotFoundException ex) { + ex.printStackTrace(); + } catch (IOException ex) { + ex.printStackTrace(); + } catch (IllegalArgumentException ex) { + alert.setTitle("Invalid Hex!"); + alert.setContentText("Invalid hex entered into the text box, unable to save."); + alert.showAndWait(); + } + alert.setTitle("Save successful!"); + alert.setContentText("File saved successfully."); + alert.showAndWait(); + }); + + Scene scene = new Scene(bp); + stage.setScene(scene); + stage.show(); + + } + + private int toDigit(char hexChar) { + int digit = Character.digit(hexChar, 16); + if (digit == -1) { + throw new IllegalArgumentException( + "Invalid Hexadecimal Character: " + hexChar); + } + return digit; + } + + public byte hexToByte(String hexString) { + int firstDigit = toDigit(hexString.charAt(0)); + int secondDigit = toDigit(hexString.charAt(1)); + return (byte) ((firstDigit << 4) + secondDigit); + } + + public byte[] decodeHexString(String hexString) { + if (hexString.length() % 2 == 1) { + throw new IllegalArgumentException( + "Invalid hexadecimal String supplied."); + } + byte[] bytes = new byte[hexString.length() / 2]; + for (int i = 0; i < hexString.length(); i += 2) { + bytes[i / 2] = hexToByte(hexString.substring(i, i + 2)); + } + return bytes; + } + + public String byteToHex(byte num) { + char[] hexDigits = new char[2]; + hexDigits[0] = Character.forDigit((num >> 4) & 0xF, 16); + hexDigits[1] = Character.forDigit((num & 0xF), 16); + return new String(hexDigits); + } + + public String encodeHexString(byte[] byteArray) { + StringBuffer hexStringBuffer = new StringBuffer(); + for (int i = 0; i < byteArray.length; i++) { + hexStringBuffer.append(byteToHex(byteArray[i])); + } + return hexStringBuffer.toString(); + } + + public static void main(String[] args) { + launch(args); + } +} diff --git a/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/SplitFilesFX.java b/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/SplitFilesFX.java new file mode 100644 index 0000000..32f0585 --- /dev/null +++ b/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/SplitFilesFX.java @@ -0,0 +1,122 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp5.files_chloefontenot; + +import java.io.DataInput; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import javafx.application.Application; +import javafx.geometry.Pos; +import javafx.scene.Scene; +import javafx.scene.control.Alert; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.ProgressBar; +import javafx.scene.control.TextField; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.GridPane; +import javafx.stage.FileChooser; +import javafx.stage.Stage; + +/** + * + * @author chloe + */ +public class SplitFilesFX extends Application { + static File file = null; + final FileChooser fileChooser = new FileChooser(); + static ProgressBar pb = new ProgressBar(); + static Alert alert = new Alert(Alert.AlertType.INFORMATION); + @Override + public void start(final Stage stage) throws Exception + { + fileChooser.setTitle("Open File to Split..."); + BorderPane primaryBorderPane = new BorderPane(); + BorderPane secondaryBoarderPane = new BorderPane(); + GridPane textFieldGridPane = new GridPane(); + + pb.prefWidthProperty().bind(stage.widthProperty()); + + Label infoLabel = new Label("If you split a file named tmp into 3 smaller files,\n the three smaller files are temp.txt.1, temp.txt.2, and temp.txt.3. "); + Label chooseFile = new Label("Choose a file to split: "); + Button openFilePicker = new Button("Choose..."); + Label splitCountLabel = new Label("Enter the amount of files to split into: "); + TextField splitCount = new TextField(); + Button run = new Button("Start"); + textFieldGridPane.add(chooseFile, 0, 0); + textFieldGridPane.add(openFilePicker, 1, 0); + textFieldGridPane.add(splitCountLabel, 0, 1); + textFieldGridPane.add(splitCount, 1, 1); + secondaryBoarderPane.setAlignment(run, Pos.CENTER); + + primaryBorderPane.setTop(infoLabel); + primaryBorderPane.setCenter(textFieldGridPane); + + secondaryBoarderPane.setBottom(run); + secondaryBoarderPane.setTop(pb); + + primaryBorderPane.setBottom(secondaryBoarderPane); + + openFilePicker.setOnAction(e -> { + file = fileChooser.showOpenDialog(openFilePicker.getScene().getWindow()); + }); + + run.setOnAction(e -> { + if (file == null) { + e.consume(); + } + splitFile(file, Integer.parseInt(splitCount.getText())); + }); + + Scene scene = new Scene(primaryBorderPane); + stage.setScene(scene); + stage.show(); + } + + public static void splitFile(File fileToSplit, int splitCount) { + int outputFileSize = (int) fileToSplit.length() / splitCount; + System.out.println("output file size will be: " + outputFileSize); + if (outputFileSize < 0) { + alert.setTitle("Output files too large"); + alert.setHeaderText("Output files too large"); + alert.setContentText("Please increase the amount of files to split!"); + + alert.showAndWait(); + return; + } + + double progress = 0; + String outputPath = fileToSplit.getParent(); + // Open the original file + try (FileInputStream dataIn = new FileInputStream(fileToSplit)) { + System.out.println("Opening the source file!"); + for (int i = 0; i < splitCount; ++i) { + progress = (i * 100) / splitCount; + System.out.println(progress); + pb.setProgress(progress); + dataIn.mark(outputFileSize * (i + 1)); + try (FileOutputStream dataOut = new FileOutputStream(outputPath + "/" + fileToSplit.getName() + "." + (i + 1))) { + dataOut.write(dataIn.readNBytes(outputFileSize), 0, outputFileSize); + System.out.println("Writing to " + outputPath + "/" + fileToSplit.getName() + "." + (i + 1)); + } + } + + } catch (IOException ex) { + System.out.println(ex); + } + + } + + + public static void main(String[] args) + { + launch(); + } +} +/* + + */ diff --git a/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/SystemInfo.java b/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/SystemInfo.java new file mode 100644 index 0000000..e403d4d --- /dev/null +++ b/Semester 3/Assignments/MP5-Binary-Files_ChloeFontenot/src/com/chloefontenot/mp5/files_chloefontenot/SystemInfo.java @@ -0,0 +1,13 @@ +package com.chloefontenot.mp5.files_chloefontenot; + +public class SystemInfo { + + public static String javaVersion() { + return System.getProperty("java.version"); + } + + public static String javafxVersion() { + return System.getProperty("javafx.version"); + } + +} \ No newline at end of file diff --git a/Semester 3/Assignments/MP6_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp6_chloefontenot/CircularList.java b/Semester 3/Assignments/MP6_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp6_chloefontenot/CircularList.java new file mode 100644 index 0000000..3b8b144 --- /dev/null +++ b/Semester 3/Assignments/MP6_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp6_chloefontenot/CircularList.java @@ -0,0 +1,208 @@ +package edu.slcc.asdv.chloe.mp6_chloefontenot; + +/** + * + * @author Markou + */ +public class CircularList> { + + Node head; + + public class Node< T extends Comparable> + implements Comparable> { + + private T t; + + public void set(T t) + { + this.t = t; + } + + public T get() + { + return t; + } + Node next; + + @Override + public int compareTo(Node o) + { + return this.t.compareTo(o.get()); + } + } + + /** + * + * @param t + */ + public void add(Object t) + { + Node temp = new Node(); + temp.set((T) t); + + if (head == null) { + head = temp; + head.next = head; + } else { + Node temp2 = head; + do { + temp2 = temp2.next; + } while (temp2.next != head); + temp.next = head; + temp2.next = temp; + } + } + + /** + * + * @return + */ + private int getSize() + { + if (head == null) { + return 0; + } + Node temp = head; + int count = 0; + do { + temp = temp.next; + count++; + } while (temp != head); + + return count; + } + //////////////////////////////////////////////////////// + + public void addAt(Object t, int pos) + { + if (pos < 0 || pos > getSize()) { + return; + } + + Node temp = new Node(); + temp.set((T) t); + + if (head == null) { + add(t); + } else if (pos == 0) { + int oldSize = getSize(); + Node currentHead = head; + temp.next = head; + head = temp; + // Set the node at the end of the list to point back to the new head. + Node pointer = head; + for (int i = 0; i < oldSize; ++i) { + pointer = pointer.next; + } + pointer.next = temp; + } else { + // Iterate to the desired position + Node pointer = head; + for (int i = 0; i < pos -1; ++i) { + pointer = pointer.next; + } + temp.next = pointer.next; + pointer.next = temp; + } + } +////////////////////////////////////////////////////////////// +/** + * removes the last node + */ + public void remove() + { + Node pointer = head; + for (int i = 0; i < this.getSize() - 2; ++i) { + pointer = pointer.next; + } + pointer.next = head; + } +////////////////////////////////////////////////////////////// +/** + * removes a specific object from the list + */ + public boolean remove(Object t) + { + Node pointer = head; + boolean isObjectRemoved = false; + do { + boolean eval = pointer.next.t.equals(t); + if (eval) { + isObjectRemoved = true; + pointer.next = pointer.next.next; + break; + } else { + pointer = pointer.next; + } + } while (pointer != head); + return isObjectRemoved; + } +////////////////////////////////////////////////////////////// + + public void removeAt(int pos) + { + Node pointer = head; + for (int i = 0; i < pos; ++i) { + boolean eval = i == pos - 1; + if (eval) { + pointer.next = pointer.next.next; + break; + } else { + pointer = pointer.next; + } + } + } + + public void print() + { + + if (head == null) { + return; + } + Node temp = head; + int elementNum = 0; + do { + System.out.print(++elementNum + ": "); + System.out.println(temp.get().toString()); + temp = temp.next; + } while (temp != head); + + } + + public static void main(String... ar) + { + CircularList list = new CircularList(); + list.add("Hello"); + list.add("World"); + list.add("one"); + String removeMe = "two"; + list.add(removeMe); + list.add("three"); + list.add("four"); + list.add("five"); + list.add("six"); + list.add("seven"); + list.print(); + System.out.println("-------------"); + System.out.println("Remove the last object:"); + list.remove(); + list.print(); + System.out.println("-------------"); + System.out.println("Remove \"two\""); + list.remove(removeMe); + list.print(); + System.out.println("-------------"); + System.out.println("Remove the 3rd element:"); + list.removeAt(2); + list.print(); + System.out.println("-------------"); + System.out.println("Add an element to the beginning"); + list.addAt("Earth", 0); + list.print(); + System.out.println("-------------"); + System.out.println("Add an element named \"potato\" in the 4th position:"); + list.addAt("potato", 3); + list.print(); + } + +} diff --git a/Semester 3/Assignments/MP6_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp6_chloefontenot/DoubleLinkedList.java b/Semester 3/Assignments/MP6_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp6_chloefontenot/DoubleLinkedList.java new file mode 100644 index 0000000..69502c9 --- /dev/null +++ b/Semester 3/Assignments/MP6_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp6_chloefontenot/DoubleLinkedList.java @@ -0,0 +1,129 @@ +/* + * 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.chloe.mp6_chloefontenot; + +/** + * + * @author chloe + */ +public class DoubleLinkedList { + Node head; + Node tail; + + class Node { + T t; + Node left; + Node right; + } + + public T removeAt(int pos) + { + if (pos < 0 || pos > size()-1) + { + throw new IndexOutOfBoundsException(); + } + + //list is empty + if ( size() == 0 ) + throw new EmptyListException( "The list empty."); + //remove at 0 + if ( pos == 0) + { + + if ( size() == 1) + head = tail = null; + else + head = head.right; + } + else if (pos== size() - 1) { //remove at end + tail = tail.left; + tail.right = null; + } + else { //remove in the middle + Node p = head; + for (int i = 0; i < pos; ++i) { + p = p.right; + p.left.right = p.right; + p.right.left = p.right; + p.right.left = p.left; + } + } + + + + return null; + } + + public void addAt(T t, int pos) { + if (pos < 0 || pos > size()) { + throw new IndexOutOfBoundsException(); + } + Node newNode = new Node(); + newNode.t = t; + if (head == null) { // list is empty + head = tail = newNode; + } else if (pos == 0) { // add at the front + newNode.right = head; + head.left = newNode; + head = newNode; + } else if (pos == size()) {// add at the end + newNode.left = tail; + tail.right = newNode; + tail = newNode; + } else { //We're in the middle + Node p = head; + for (int i = 0; i < pos - 1; ++i) { + p = p.right; + } + newNode.left = p; + newNode.right = p.right; + p.right.left = newNode; + } + } + public int size() { + Node p = head; + int count = 0; + while (p != null) { + count++; + p = p.right; + } + return count; + } + + @Override + public String toString() + { + String outputString = "DoubleLinkedList{" + "head=" + head + ", tail=" + tail +", size=" + this.size() + "}\n Contents= ["; + Node p = head; + int count = 0; + int size = size(); + System.out.println(size); + while (p != null) { + outputString += p.t.toString(); + count++; + if (count < size) { + outputString += ", "; + } else { + outputString += "]"; + } + p = p.right; + } + return outputString; + } + + public static void main(String[] args) + { + DoubleLinkedList list = new DoubleLinkedList<>(); + list.addAt(10, 0); + list.addAt(20, 0); + list.addAt(30, 0); + list.addAt(40, 0); + list.addAt(40, 3); + list.addAt(25, 3); + list.removeAt(3); + list.removeAt(1); + System.out.println(list); + } +} diff --git a/Semester 3/Assignments/MP6_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp6_chloefontenot/EmptyListException.java b/Semester 3/Assignments/MP6_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp6_chloefontenot/EmptyListException.java new file mode 100644 index 0000000..d9033a7 --- /dev/null +++ b/Semester 3/Assignments/MP6_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp6_chloefontenot/EmptyListException.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package edu.slcc.asdv.chloe.mp6_chloefontenot; + +/** + * + * @author chloe + */ +public class EmptyListException extends RuntimeException{ + public EmptyListException() {} + public EmptyListException(String msg) { + super(msg); + } +} diff --git a/Semester 3/Assignments/MP6_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp6_chloefontenot/MP6_CalebFontenot.java b/Semester 3/Assignments/MP6_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp6_chloefontenot/MP6_CalebFontenot.java new file mode 100644 index 0000000..4c64f04 --- /dev/null +++ b/Semester 3/Assignments/MP6_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp6_chloefontenot/MP6_CalebFontenot.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package edu.slcc.asdv.chloe.mp6_chloefontenot; + +/** + * + * @author chloe + */ +public class MP6_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 3/Assignments/MP6_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp6_chloefontenot/PriorityQueueASDV.java b/Semester 3/Assignments/MP6_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp6_chloefontenot/PriorityQueueASDV.java new file mode 100644 index 0000000..6a33e75 --- /dev/null +++ b/Semester 3/Assignments/MP6_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp6_chloefontenot/PriorityQueueASDV.java @@ -0,0 +1,912 @@ +/* + * 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.chloe.mp6_chloefontenot; + +/** + * + * @author chloe + */ +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.NoSuchElementException; +import java.util.PriorityQueue; +import java.util.Queue; +import java.util.function.Consumer; + +public class PriorityQueueASDV> + implements Queue, Cloneable { + + private Node head;//head + private Node tail;//tail + + class Node { + + E e; + Node l; + Node r; + } + + /** + * Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions, returning true upon success and throwing an IllegalStateException if no space is currently available. + * + * Specified by: add in interface Collection + * Parameters: e - the element to add Returns: true (as specified by Collection.add(E)) Throws: IllegalStateException - if the element cannot be added at this time due to capacity restrictions ClassCastException - if the class of the specified element prevents it from being added to this queue NullPointerException - if the specified element is null and this queue does not permit null elements IllegalArgumentException - if some property of this element prevents it from being added to this queue + * + * @param e - the element to add + * @return true if this collection changed as a result of the call + * @throws IllegalStateException - if the element cannot be added at this time due to capacity restrictions + * @throws ClassCastException - if the class of the specified element + * @throws NullPointerException - if the specified element is null and this queue does not permit null elements + * @throws IllegalArgumentException - if some property of this element prevents it from being added to this queue + */ + @Override + public boolean add(E e) { + if (e == null) { + throw new NullPointerException("NULL elements not allowed!"); + } + + Node newNode = new Node(); + newNode.e = e; + + //1. empty queue + if (this.head == null && this.tail == null) { + this.head = this.tail = newNode; + return true; + } + + int index = findCorrectPositionToInsertElement(e); + //int index = findCorrectPositionToInsertElementHashCode(e); + + //2. we add at size ( last node) + if (index == size()) { + tail.r = newNode;//1 + newNode.l = tail;//2 + tail = newNode;//3 + } //3. we add at 0 in the front + else if (index == 0) { + newNode.r = head; + this.head.l = newNode; + this.head = newNode; + if (size() == 1) { + tail = head; + } + } //4. we add in the middle + else { + Node p = head; + + for (int i = 0; i < index - 1; ++i) { + p = p.r; + } + + //after for loop p point one position before insertion + newNode.l = p;//we connect the left of the new node + //to the node that is BEFORE + //the node to be inserted + + newNode.r = p.r;//we connect the right of the new node + // to the node thta is AFTER + //the node to be inserted + + p.r = newNode; //we connect the right the node BEFORE the node + //to be inserted to the new node + + p.r.r.l = newNode;//we connect the left of the node AFTER the node + //to be iserted to the new node + } + + return true; + } + + @Override + public int size() { + Node p = this.head; + int count = 0; + while (p != null) { + p = p.r; + count++; + } + return count; + } + + private int findCorrectPositionToInsertElement(E e) { + Node p = this.head; + int pos = 0; + while (p != null) { + if (e.compareTo(p.e) > 0) { + p = p.r; + ++pos; + } else { + break; + } + } + + return pos; + } + + private int findCorrectPositionToInsertElementHashCode(E e) { + Node p = this.head; + int pos = 0; + while (p != null) { + if (e.hashCode() > p.e.hashCode()) { + p = p.r; + ++pos; + } else { + break; + } + } + + return pos; + } + + /** + * Inserts the specified element into this queue if it is possible to do so immediately without violating capacity restrictions. When using a capacity-restricted queue, this method is generally preferable to add(E), which can fail to insert an element only by throwing an exception. + * + * @param e - the element to add + * @throws IllegalStateException - if the element cannot be added at this time due to capacity restrictions + * @throws ClassCastException - if the class of the specified element + * @throws NullPointerException - if the specified element is null and this queue does not permit null elements + * @throws IllegalArgumentException - if some property of this element prevents it from being added to this queue + * @return true if the element was added + */ + @Override + public boolean offer(E e) { + return add(e); + } + + /** + * Retrieves and removes the head of this queue. This method differs from {@link #poll poll} only in that it throws an exception if this queue is empty. + * + *

+ * This implementation returns the result of {@code poll} unless the queue is empty. + * + * @return the head of this queue + * @throws NoSuchElementException if this queue is empty + */ + @Override + public E remove() { + Node pointer = head.r; + E removedElement = head.e; + head = head.r; + head.l = null; + + return removedElement; + } + + /** + * Retrieves and removes the head of this queue, or returns null if this queue is empty. + * + * Returns: the head of this queue, or null if this queue is empty + * + * @return + */ + @Override + public E poll() { + if (size() == 0) { + return null; + } + if (size() > 1) { + head = head.r; + + E e = head.l.e; + head.l = null; + return e; + } else //size 1 + { + E e = head.e; + head = tail = null; + return e; + } + } + + /** + * Retrieves, but does not remove, the head of this queue. This method differs from {@link #peek peek} only in that it throws an exception if this queue is empty. + * + * @return the head of this queue + * @throws NoSuchElementException if this queue is empty + */ + @Override + public E element() { + if (head != null) { + return (E) head; + } else { + throw new NoSuchElementException("Element does not exist."); + } + } + + /** + * Retrieves, but does not remove, the head of this queue, or returns {@code null} if this queue is empty. + * + * @return the head of this queue, or {@code null} if this queue is empty + */ + @Override + public E peek() { + return (E) head; + } + + @Override + public boolean isEmpty() { + return head == null && tail == null ? true : false; + + } + + /** + * Returns {@code true} if this collection contains the specified element. More formally, returns {@code true} if and only if this collection contains at least one element {@code e} such that {@code Objects.equals(o, e)}. + * + * @param o element whose presence in this collection is to be tested + * @return {@code true} if this collection contains the specified element + * @throws ClassCastException if the type of the specified element is incompatible with this collection ({@linkplain Collection##optional-restrictions optional}) + * @throws NullPointerException if the specified element is null and this collection does not permit null elements ({@linkplain Collection##optional-restrictions optional}) + */ + @Override + public boolean contains(Object o) { + Node pointer = head; + do { + if (pointer.equals(o)) { + return true; + } else { + pointer = pointer.r; + } + } while (pointer != null); + return false; + } + + @Override + public Iterator iterator() { + Iterator it = new Iterator() { + Node p = head; + + @Override + public boolean hasNext() { + return p == null ? false : true; + } + + @Override + public E next() { + if (hasNext() == false) { + throw new NoSuchElementException("the is no next element"); + } + E e = p.e; + p = p.r; + return e; + } + + @Override + public void forEachRemaining(Consumer action) { + while (hasNext()) { + action.accept(p.e); + p = p.r; + } + } + }; + + return it; + + } + + @Override + public Object[] toArray() { + Node pointer = head; + Object[] returnArray = new Object[this.size()]; + int i = 0; + while (pointer.r != null) { + returnArray[i++] = pointer.e; + pointer = pointer.r; + } + returnArray[i++] = pointer.e; + return returnArray; + } + + /** + * Returns an array containing all of the elements in this collection; the runtime type of the returned array is that of the specified array. If the collection 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 collection. + * + *

+ * If this collection fits in the specified array with room to spare (i.e., the array has more elements than this collection), the element in the array immediately following the end of the collection is set to {@code null}. (This is useful in determining the length of this collection only if the caller knows that this collection does not contain any {@code null} elements.) + * + *

+ * If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order. + * + * @apiNote This method acts as a bridge between array-based and collection-based APIs. It allows an existing array to be reused under certain circumstances. Use {@link #toArray()} to create an array whose runtime type is {@code Object[]}, or use {@link #toArray(IntFunction)} to control the runtime type of the array. + * + *

+ * Suppose {@code x} is a collection known to contain only strings. The following code can be used to dump the collection into a previously allocated {@code String} array: + * + *

+     *     String[] y = new String[SIZE];
+     *     ...
+     *     y = x.toArray(y);
+ * + *

+ * The return value is reassigned to the variable {@code y}, because a new array will be allocated and returned if the collection {@code x} has too many elements to fit into the existing array {@code y}. + * + *

+ * Note that {@code toArray(new Object[0])} is identical in function to {@code toArray()}. + * + * @param the component type of the array to contain the collection + * @param a the array into which the elements of this collection 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 all of the elements in this collection + * @throws ArrayStoreException if the runtime type of any element in this collection is not assignable to the {@linkplain Class#getComponentType + * runtime component type} of the specified array + * @throws NullPointerException if the specified array is null + */ + @Override + public T[] toArray(T[] a) { + a = Arrays.copyOf(a, this.size()); + Node pointer = head; + System.out.println(a.getClass()); + System.out.println(pointer.getClass()); + System.out.println(pointer.e.getClass()); + + for (int i = 0; i < this.size(); ++i) { + a[i] = (T) pointer.e; + pointer = pointer.r; + } + return a; + } + + /** + * Removes a single instance of the specified element from this collection, if it is present (optional operation). More formally, removes an element e such that (o==null ? e==null : o.equals(e)), if this collection contains one or more such elements. Returns true if this collection contained the specified element (or equivalently, if this collection changed as a result of the call). + * + * @param o - element to be removed from this collection, if present + * @throws ClassCastException - if the type of the specified element is incompatible with this collection + * @throws NullPointerException - if the specified element is null and this collection does not permit null elements + * @return true if an element was removed as a result of this call + */ + @Override + public boolean remove(Object o) { + if (o == null) { + throw new NullPointerException("null vales not allowed"); + } + if (size() == 0) { + return false; + } + + Node p = this.head; + int pos = 0; + while (p != this.tail) { + if (p.e.equals(o)) { + if (size() == 1) { + this.head = this.tail = null; + return true; + } + this.removeAt(pos, (E) o); + break; + } + ++pos; + p = p.r; + } + if (p == tail && p.e.equals(o)) { + this.removeAt(size() - 1, (E) o); + } + return true; + } + + /** + * + * @param pos + * @param e + * @throws IndexOutOfBoundsException - if pos less 0 OR pos greater-equal size() + * @return + */ + private boolean removeAt(int pos, E e) { + if (pos < 0 || pos >= size()) { + throw new IndexOutOfBoundsException(pos + " is out of bounds"); + } + //1.list is empty + if (isEmpty()) { + return false; + } //2. one node exists + else if (size() == 1) { + this.head = this.tail = null; + } //3. remove in the front( head) + else if (pos == 0) { + this.head = this.head.r; + head.l = null; + } //4. remove in the end ( tail) + else if (pos == size() - 1) { + this.tail = this.tail.l; + this.tail.r = null; + } //5. remove in the middle ( at least 3 nodes are in the queue) + else { + Node p = head; + for (int i = 0; i < pos - 1; ++i) { + p = p.r; + } + p.r = p.r.r; + p.r.l = p; + } + return true; + } + + /** + * Returns {@code true} if this collection contains all of the elements in the specified collection. + * + * @param c collection to be checked for containment in this collection + * @return {@code 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 ({@linkplain Collection##optional-restrictions optional}) + * @throws NullPointerException if the specified collection contains one or more null elements and this collection does not permit null elements ({@linkplain Collection##optional-restrictions optional}) or if the specified collection is null. + * @see #contains(Object) + */ + @Override + public boolean containsAll(Collection c) { + // Java already throws a CastCastException if you give it the wrong type, so we don't have to throw that ourselves + if (c.contains(null) || c == null) { + throw new NullPointerException("The collection you passed to containsAll() contains a null element. Cannot continue."); + } + // Unpack the collection so we can compare them + Object[] compareArray = c.toArray(); + Node pointer = null; + int matchCount = 0; + for (Object compare : compareArray) { + pointer = head; + for (int i = 0; i < size() - 1; ++i) { + if (pointer.e.equals(compare)) { + matchCount++; + } + pointer = pointer.r; + } + } + if (matchCount == compareArray.length - 1) { + return true; + } + return false; + } + + /** + * Adds all of the elements in the specified collection to this collection (optional operation). The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified collection is this collection, and this collection is nonempty.) + * + * @param c - collection containing elements to be added to this collection + * @throws ClassCastException - if the class of an element of the specified collection prevents it from being added to this collection. + * @throws NullPointerException - if the specified collection contains a null element and this collection does not permit null elements, or if the specified collection is null + * @throws IllegalArgumentException - if some property of an element of the specified collection prevents it from being added to this collection + * @throws IllegalArgumentException - if some property of an element of the specified collection prevents it from being added to this collection + * @return true if this collection changed as a result of the call + */ + @Override + public boolean addAll(Collection c) { + int sizeBefore = size(); + for (E e : c) { + add(e); + } + int sizeAfter = size(); + return sizeAfter > sizeBefore; + } + + /** + * 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. + * + * @implSpec This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's so contained, it's removed from this collection with the iterator's {@code remove} method. + * + *

+ * Note that this implementation will throw an {@code UnsupportedOperationException} if the iterator returned by the {@code iterator} method does not implement the {@code remove} method and this collection contains one or more elements in common with the specified collection. + * + * @throws UnsupportedOperationException {@inheritDoc} + * @throws ClassCastException {@inheritDoc} + * @throws NullPointerException {@inheritDoc} + * + * @see #remove(Object) + * @see #contains(Object) + */ + @Override + public boolean removeAll(Collection c) { + if (c.contains(null) || c == null) { + throw new NullPointerException("The collection you passed to removeAll() contains a null element. Cannot continue."); + } + // Unpack the collection so we can remove them + Object[] compareArray = c.toArray(); + Node pointer = null; + boolean removeSuccessful = false; + for (Object compare : compareArray) { + pointer = head; + for (int i = 0; i < size() - 1; ++i) { + if (pointer.e.equals(compare)) { + remove(pointer.e); + removeSuccessful = true; + } + pointer = pointer.r; + } + } + return removeSuccessful; + } + + @Override + public boolean retainAll(Collection c) { + if (c.contains(null) || c == null) { + throw new NullPointerException("The collection you passed to retainAll() contains a null element. Cannot continue."); + } + Node pointer = null; + boolean removeSuccessful = false; + for (int j = 0; j < c.size() - 1; ++j) { + pointer = head; + for (int i = 0; i < size(); ++i) { + if (!c.contains(pointer.e)) { + remove(pointer.e); + removeSuccessful = true; + } + pointer = pointer.r; + } + } + return removeSuccessful; + } + + @Override + public void clear() { + // head = tail = null; + + //extra, no necessary to set the link of every node + Node p = head; + while (p != tail) { + p = p.r; + p.l = null; + } + head = tail = null; + } + + @Override + public void forEach(Consumer action) { + //1. use a pointer that points to the head + //2. while the pointer has not reached the end of the queue + //consume it + Node p = head; + while (p != null) { + action.accept(p.e); + p = p.r; + } + + } + + @Override + public String toString() { + String s = "PriorityQueueASDV {"; + Node p = head; + while (p != null) { + s += p.e.toString(); + if (p != tail) { + s += ", "; + } + p = p.r; + } + + s += "}"; + return s; + } + + @Override + protected Object clone() + throws CloneNotSupportedException { + PriorityQueueASDV c = (PriorityQueueASDV) super.clone(); + return c; + } + + public static void main(String[] args) { + System.out.println("\n--> PriorityQueueASDV testing add"); + PriorityQueueASDV pq1 = new PriorityQueueASDV(); + pq1.add("Paris"); + pq1.add("Athens"); + pq1.add("London"); + pq1.add("Lafayette"); + pq1.add("Berlin"); + + System.out.println(pq1); + + System.out.println("\n--> Colllections PriorityQueue testing add"); + + PriorityQueue pq2 = new PriorityQueue(); + pq2.add("Paris"); + pq2.add("Athens"); + pq2.add("London"); + pq2.add("Lafayette"); + pq2.add("Berlin"); + + System.out.println(pq2); + + //TEST IT FULLY HERE. FOR ALL METHODS AND ALL CASES. + //Have the Jzva PriorityQueue below + System.out.println("\n--> PriorityQueueASDV testing remove(object o)"); + System.out.println("\n\tremove from front Athens"); + pq1.remove("Athens"); + pq2.remove("Athens"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\tremove from end Paris"); + pq1.remove("Paris"); + pq2.remove("Paris"); + System.out.println(pq1); + System.out.println(pq1); + + System.out.println("\n\tremove from the middle Lafayette"); + pq1.remove("Lafayette"); + pq2.remove("Lafayette"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\tadd at the end Stocholm"); + pq1.add("Stocholm"); + pq2.add("Stocholm"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\tremove from the middle London"); + pq1.remove("London"); + pq2.remove("London"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\tremove from the front Berlin"); + pq1.remove("Berlin"); + pq2.remove("Berlin"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\tremove from the front/end Stocholm"); + pq1.remove("Stocholm"); + pq2.remove("Stocholm"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\tremove from empty queue"); + pq1.remove("Stocholm"); + pq2.remove("Stocholm"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n--> PriorityQueueASDV recreate priority queues from empty"); + pq1.add("Paris"); + pq1.add("Athens"); + pq1.add("London"); + pq1.add("Lafayette"); + pq1.add("Berlin"); + pq1.add("Zurich"); + + pq2.add("Paris"); + pq2.add("Athens"); + pq2.add("London"); + pq2.add("Lafayette"); + pq2.add("Berlin"); + pq2.add("Zurich"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\n+++HERE YOU TEST ALL YOUR METHODS FULLY, and the methods of Colleciion PriorityQueue"); + + System.out.println("\n\t offer New York"); + pq1.offer("New York"); + pq2.offer("New York"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\t offer Miami"); + pq1.offer("Miami"); + pq2.offer("Miami"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\t offer null"); + try { + pq1.offer(null); + } catch (Exception e) { + System.err.println(e); + } + + try { + pq2.offer(null); + } catch (Exception e) { + System.err.println(e); + } + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\t offer ClassCastException with Object"); + try { + pq1.offer((String) new Object()); + } catch (Exception e) { + System.err.println(e); + } + + try { + pq2.offer((String) new Object()); + } catch (Exception e) { + System.err.println(e); + } + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\t poll suposed to be Athens"); + System.out.println(pq1.poll()); + System.out.println(pq2.poll()); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\t Iterator"); + Iterator it1 = pq1.iterator(); + Iterator it2 = pq2.iterator(); + + while (it1.hasNext()) { + System.out.print(it1.next() + " "); + } + + System.out.println(""); + + while (it2.hasNext()) { + System.out.print(it2.next() + " "); + } + System.out.println(""); + + System.out.println("\n\t Iterator NoSuchElementException "); + + try { + System.out.println(it1.next()); + } catch (NoSuchElementException e) { + System.err.println(e); + } + try { + System.out.println(it2.next()); + } catch (NoSuchElementException e) { + System.err.println(e); + } + + System.out.println("\n\t Iterator foreach "); + it1 = pq1.iterator(); + it2 = pq2.iterator(); + it1.forEachRemaining(new Consumer() { + @Override + public void accept(Object t) { + System.out.print(t + "*** "); + } + }); + System.out.println(""); + it2.forEachRemaining(new Consumer() { + @Override + public void accept(Object t) { + System.out.print(t + "+++ "); + } + }); + System.out.println(""); + + System.out.println("\n\t addAll Houston Chicago"); + List ar1 = Arrays.asList("Houston", "Chicago"); + pq1.addAll(ar1); + pq2.addAll(ar1); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\t clear"); + pq1.clear(); + pq2.clear(); + System.out.println(pq1); + System.out.println(pq2); + System.out.println(""); + + System.out.println("\n--> PriorityQueueASDV recreate priority queues from empty"); + pq1.add("Paris"); + pq1.add("Athens"); + pq1.add("London"); + pq1.add("Lafayette"); + pq1.add("Berlin"); + pq1.add("Zurich"); + + pq2.add("Paris"); + pq2.add("Athens"); + pq2.add("London"); + pq2.add("Lafayette"); + pq2.add("Berlin"); + pq2.add("Zurich"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("\n\t forEach"); + pq1.forEach(new Consumer() { + @Override + public void accept(Object t) { + System.out.print(t + "*** "); + } + }); + System.out.println(""); + pq2.forEach(new Consumer() { + @Override + public void accept(Object t) { + System.out.print(t + "+++ "); + } + }); + System.out.println(""); + + System.out.println("\n\t clone"); + try { + PriorityQueueASDV pq1Cloned + = (PriorityQueueASDV) pq1.clone(); + System.out.println(pq1Cloned); + pq1Cloned.add("Las Vegas"); + System.out.println(pq1Cloned); + System.out.println(pq1); + + } catch (CloneNotSupportedException e) { + System.err.println(e); + } + pq1.clear(); + pq2.clear(); + pq1.add("Paris"); + pq1.add("Athens"); + pq1.add("London"); + pq1.add("Lafayette"); + pq1.add("Berlin"); + pq1.add("Zurich"); + + pq2.add("Paris"); + pq2.add("Athens"); + pq2.add("London"); + pq2.add("Lafayette"); + pq2.add("Berlin"); + pq2.add("Zurich"); + System.out.println("----------------"); + System.out.println(pq1); + System.out.println(pq2); + + System.out.println("Attempt to remove an element."); + pq1.remove(); + pq2.remove(); + System.out.println(pq1); + System.out.println(pq2); + System.out.println("Get array of the priority queues."); + Object pqArray1[] = pq1.toArray(); + Object pqArray2[] = pq2.toArray(); + + printArrays(pqArray1); + printArrays(pqArray2); + System.out.println(); + System.out.println("----------------"); + System.out.println("Test .toArray(T[])"); + String[] pqArray3 = pq1.toArray(new String[0]); + printArrays(pqArray3); + System.out.println("----------------"); + System.out.println("Test containsAll()"); + ArrayList testArray = new ArrayList<>(); + testArray.add("Lafayette"); + testArray.add("Berlin"); + testArray.add("Zurich"); + System.out.println("Does pq1 contain Lafayette, Berlin, and Zurich? " + (pq1.containsAll(testArray) ? "yes" : "no")); + System.out.println("Does pq1 contain the contents of pq2? " + (pq1.containsAll(pq2) ? "yes" : "no")); + System.out.println("Does pq2 contain the contents of pq1? " + (pq2.containsAll(pq1) ? "yes" : "no")); + System.out.println("Adding funkytown to testArray..."); + testArray.add("Funkytown"); + System.out.println("Does pq1 contain Lafayette, Berlin, Zurich, and Funkytown? " + (pq1.containsAll(testArray) ? "yes" : "no")); + System.out.println("Test if containsAll() correctly throws a NullPointerException..."); + try { + testArray.add(null); + System.out.println("Does pq1 contain Lafayette, Berlin, Zurich, Funkytown, and null? " + (pq1.containsAll(testArray) ? "yes" : "no")); + } catch (NullPointerException ex) { + System.out.println(ex); + } + testArray.remove(null); + System.out.println("That worked! Continuing with tests..."); + System.out.println("----------------"); + System.out.println(pq1); + System.out.println(pq2); + System.out.println("Testing removeAll(Collection)..."); + System.out.println("Removing the elements in the test array..."); + pq1.removeAll(testArray); + pq2.removeAll(testArray); + System.out.println(pq1); + System.out.println(pq2); + System.out.println("----------------"); + System.out.println("Testing retainAll()..."); + ArrayList testArray2 = new ArrayList<>(); + testArray2.add("London"); + testArray2.add("Paris"); + pq1.retainAll(testArray2); + pq2.retainAll(testArray2); + System.out.println(pq1); + System.out.println(pq2); + } + + static void printArrays(Object[] arr) { + for (Object element : arr) { + System.out.print(element + ", "); + } + } + +} diff --git a/Semester 3/Assignments/lab2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab2_chloefontenot/JakartaRestConfiguration.java b/Semester 3/Assignments/lab2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab2_chloefontenot/JakartaRestConfiguration.java new file mode 100644 index 0000000..d927496 --- /dev/null +++ b/Semester 3/Assignments/lab2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab2_chloefontenot/JakartaRestConfiguration.java @@ -0,0 +1,13 @@ +package edu.slcc.asdv.chloe.lab2_chloefontenot; + +import jakarta.ws.rs.ApplicationPath; +import jakarta.ws.rs.core.Application; + +/** + * Configures Jakarta RESTful Web Services for the application. + * @author Juneau + */ +@ApplicationPath("resources") +public class JakartaRestConfiguration extends Application { + +} diff --git a/Semester 3/Assignments/lab2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab2_chloefontenot/resources/JakartaEE10Resource.java b/Semester 3/Assignments/lab2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab2_chloefontenot/resources/JakartaEE10Resource.java new file mode 100644 index 0000000..52ffd8a --- /dev/null +++ b/Semester 3/Assignments/lab2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab2_chloefontenot/resources/JakartaEE10Resource.java @@ -0,0 +1,20 @@ +package edu.slcc.asdv.chloe.lab2_chloefontenot.resources; + +import jakarta.ws.rs.GET; +import jakarta.ws.rs.Path; +import jakarta.ws.rs.core.Response; + +/** + * + * @author + */ +@Path("jakartaee10") +public class JakartaEE10Resource { + + @GET + public Response ping(){ + return Response + .ok("ping Jakarta EE") + .build(); + } +} diff --git a/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/Lab5Recursion2_CalebFontenot.java b/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/Lab5Recursion2_CalebFontenot.java new file mode 100644 index 0000000..6e6506e --- /dev/null +++ b/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/Lab5Recursion2_CalebFontenot.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package edu.slcc.asdv.chloe.lab5.recursion2_chloefontenot; + +/** + * + * @author chloe + */ +public class Lab5Recursion2_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/NestedLoopsIndexes.java b/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/NestedLoopsIndexes.java new file mode 100644 index 0000000..0fe94db --- /dev/null +++ b/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/NestedLoopsIndexes.java @@ -0,0 +1,32 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package edu.slcc.asdv.chloe.lab5.recursion2_chloefontenot; + +/** + * + * @author chloe + */ +public class NestedLoopsIndexes { + static final int ROWS = 3; + static final int COLUMNS = 5; + + public static void nestedLoopsIndexesR(int i, int j) { + if (j == COLUMNS) { + System.out.println(); + return; + } else if (i == ROWS) { + return; + } + System.out.print(i + ", " + j + " "); + nestedLoopsIndexesR(i, ++j); + if (i + 1 == j) { + nestedLoopsIndexesR(++i, 0); + } + } + public static void main(String[] args) + { + nestedLoopsIndexesR(0, 0); + } +} diff --git a/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/OccurancesOfChar.java b/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/OccurancesOfChar.java new file mode 100644 index 0000000..e950eda --- /dev/null +++ b/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/OccurancesOfChar.java @@ -0,0 +1,33 @@ +/* + * 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.chloe.lab5.recursion2_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class OccurancesOfChar { + public static void main(String[] args) + { + Scanner input = new Scanner(System.in); + System.out.print("Enter a string: "); + String s = input.nextLine(); + System.out.print("Enter a character: "); + char ch =input.nextLine().charAt(0); + int times = count(s, ch); + System.out.println(ch + " appears " + times + + (times > 1 ? " times " : " time ") + "in " + s); + } + public static int count(String str, char a) { + int result = 0; + if (str.length() > 0) { + result = count(str.substring(1), a) + + (( str.charAt(0) == a) ? 1 : 0); + } + return result; + } +} diff --git a/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/OccurencesOfSpecifiedCharacterInArray.java b/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/OccurencesOfSpecifiedCharacterInArray.java new file mode 100644 index 0000000..2beaf77 --- /dev/null +++ b/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/OccurencesOfSpecifiedCharacterInArray.java @@ -0,0 +1,36 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package edu.slcc.asdv.chloe.lab5.recursion2_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class OccurencesOfSpecifiedCharacterInArray { + public static void main(String[] args) + { + System.out.print("Enter a string: "); + Scanner input = new Scanner(System.in); + String s = input.nextLine(); + char[] items = s.toCharArray(); + + System.out.print("Enter a character: "); + char ch = input.nextLine().trim().charAt(0); + + System.out.println(ch + " appears " + count(items, ch) + " times."); + } + public static int count(char[] chars, char ch) { + return count(chars, chars.length - 1, ch); + } + public static int count(char[] chars, int high, char ch) { + if (high >= 0) { + return count(chars, high - 1, ch) + (ch == chars[high] ? 1 : 0); + } else { + return 0; + } + } +} diff --git a/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/ReverseInt.java b/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/ReverseInt.java new file mode 100644 index 0000000..c9020e1 --- /dev/null +++ b/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/ReverseInt.java @@ -0,0 +1,30 @@ +/* + * 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.chloe.lab5.recursion2_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class ReverseInt { + public static void main(String[] args) + { + Scanner input = new Scanner(System.in); + System.out.print("Enter an integer: "); + int i = input.nextInt(); + System.out.print("The reversal of " + i + " is "); + reverseDisplay(i); + System.out.println(); + } + public static void reverseDisplay(int value) { + if (value != 0) { + System.out.print(value % 10); + value = value / 10; + reverseDisplay(value); + } + } +} diff --git a/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/SelectionSortR.java b/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/SelectionSortR.java new file mode 100644 index 0000000..7eddbdd --- /dev/null +++ b/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/SelectionSortR.java @@ -0,0 +1,52 @@ +/* + * 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.chloe.lab5.recursion2_chloefontenot; + +/** + * + * @author chloe + */ +public class SelectionSortR { + + public static void selectionSortR(int[] arr) + { + selectionSortR(arr, 0, arr.length); + } + + public static void swap(int[] arr, int i, int j) + { + int temp = arr[i]; + arr[i] = arr[j]; + arr[j] = temp; + } + + public static void selectionSortR(int[] arr, int i, int n) + { + // Selection sort + int min = i; + for (int j = i + 1; j < n; ++j) { + if (arr[j] < arr[min]) { + min = j; + } + } + swap(arr, min, i); + if ( i + 1 < n) { + selectionSortR(arr, i +1, n); + } + } + + public static void main(String[] args) + { + int[] arr = { + 8, 2, 1, 1, 7, 4, -1, 50, 49 + }; + selectionSortR(arr); + + for (int i = 0; i < arr.length; ++i) { + System.out.print(arr[i] + " "); + } + System.out.println(); + } +} diff --git a/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/SumOfDigits.java b/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/SumOfDigits.java new file mode 100644 index 0000000..f8dc325 --- /dev/null +++ b/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/SumOfDigits.java @@ -0,0 +1,37 @@ +/* + * 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.chloe.lab5.recursion2_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class SumOfDigits { + + public static void main(String[] args) + { + Scanner input = new Scanner(System.in); + System.out.print("Enter an integer: "); + int i = input.nextInt(); + System.out.print("The sum of digits in " + i + + " is " + sumDigits(i)); + System.out.println(); + } + + public static long sumDigits(long n) + { + // Base case: if the number is a single digit, return it + if (n < 10) { + return n; + } else { + // Recursive case: sum the last digit and call the function on the remaining digits + long lastDigit = n % 10; + long remainingDigits = n / 10; + return lastDigit + sumDigits(remainingDigits); + } + } +} diff --git a/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/SumSeries1.java b/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/SumSeries1.java new file mode 100644 index 0000000..82387f3 --- /dev/null +++ b/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/SumSeries1.java @@ -0,0 +1,26 @@ +/* + * 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.chloe.lab5.recursion2_chloefontenot; + +/** + * + * @author chloe + */ +public class SumSeries1 { + public static void main(String[] args) + { + System.out.printf("%-10s%15s\n", "1", "m(i)"); + for (int i = 1; i <= 10; ++i) { + System.out.printf("%-10d%-15.6f\n",i, m(i)); + } + } + public static double m(int i) { + if (i == 1) { + return 1; + } else { + return m(i - 1) + 1.0 / i; + } + } +} diff --git a/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/SumSeries2.java b/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/SumSeries2.java new file mode 100644 index 0000000..c73b6aa --- /dev/null +++ b/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/SumSeries2.java @@ -0,0 +1,26 @@ +/* + * 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.chloe.lab5.recursion2_chloefontenot; + +/** + * + * @author chloe + */ +public class SumSeries2 { + public static void main(String[] args) + { + System.out.printf("%-10s%15s\n", "i", "m(i)"); + for (int i = 1; i <= 10; ++i) { + System.out.printf("%-10d%-15.6f\n",i, m(i)); + } + } + public static double m(int i) { + if (i == 1) { + return 1.0 / 3; + } else { + return m(i - 1) + (double) i / (2 * i + 1); + } + } +} diff --git a/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/UpperCaseInArray.java b/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/UpperCaseInArray.java new file mode 100644 index 0000000..8606f8d --- /dev/null +++ b/Semester 3/Assignments/lab5-recursion2_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab5/recursion2_chloefontenot/UpperCaseInArray.java @@ -0,0 +1,34 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package edu.slcc.asdv.chloe.lab5.recursion2_chloefontenot; + +import java.util.Scanner; + +/** + * + * @author chloe + */ +public class UpperCaseInArray { + public static void main(String[] args) + { + System.out.print("Enter a string: "); + Scanner input = new Scanner(System.in); + String s = input.nextLine(); + char[] items = s.toCharArray(); + System.out.println("The number of uppercase letters is " + + count(items)); + } + + public static int count(char[] chars) { + return count(chars, chars.length - 1); + } + public static int count(char[] chars, int high) { + if (high >= 0) { + return count(chars, high - 1) + (Character.isUpperCase(chars[high]) ? 1 : 0); + } else { + return 0; + } + } +} diff --git a/Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/GenericStack.java b/Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/GenericStack.java new file mode 100644 index 0000000..e2db8c0 --- /dev/null +++ b/Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/GenericStack.java @@ -0,0 +1,69 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ +package edu.slcc.asdv.chloe.lab6_generics_chloefontenot; + +import java.util.ArrayList; +import java.util.EmptyStackException; + +/** + * + * @author chloe + */ +public class GenericStack { + + private T[] elements; + ArrayList elementsList = new ArrayList(); + private int top; + static int size = 4; + + public GenericStack(int size) { + elements = (T[]) new Object[size]; + } + public GenericStack() + { + elements = (T[]) new Object[size]; + } + public boolean push (T element) { + if (top == size) { + throw new StackOverflowError(); + } + elements[top++] = element; + elementsList.add(element); + return true; + } + + public T pop() { + if (top == 0) { + throw new EmptyStackException(); + } + --top; + elementsList.remove(top); + return elements[top]; + } + + public T peek() { + if (top == 0) { + throw new EmptyStackException(); + } + return elements[top - 1]; + } + public boolean isEmpty() { + boolean returnBoolean = false; + if (top == 0) { + return true; + } + return returnBoolean; + } + + + @Override + public String toString() + { + String returnString = ""; + for (int i = top -1; i >= 0; --i) { + returnString += elements[i].toString() + ", "; + } + return returnString; + } +} diff --git a/Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/Lab6_generics_CalebFontenot.java b/Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/Lab6_generics_CalebFontenot.java new file mode 100644 index 0000000..e5de316 --- /dev/null +++ b/Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/Lab6_generics_CalebFontenot.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package edu.slcc.asdv.chloe.lab6_generics_chloefontenot; + +/** + * + * @author chloe + */ +public class Lab6_generics_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/Max.java b/Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/Max.java new file mode 100644 index 0000000..02b89da --- /dev/null +++ b/Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/Max.java @@ -0,0 +1,48 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package edu.slcc.asdv.chloe.lab6_generics_chloefontenot; + +/** + * + * @author chloe + */ +public class Max { + + public static Comparable max(Comparable o1, Comparable o2) + { + if (o1.compareTo(o2) > 0) { + return o1; + } else { + return o2; + } + } + public static > E maxSafe(E e1, E e2) { + if(e1.compareTo(e2) > 0) { + return e1; + } else { + return e2; + } + } + + public static void main(String[] args) + { + System.out.println(max(1, 2)); + try { + System.out.println(maxSafe(1, 2)); + System.out.println(maxSafe("abc", "ABC")); + System.out.println(); + //System.out.println(maxSafe(1, "two")); + + GenericStack stackUnsafe = new GenericStack(); + GenericStack stackSafe = new GenericStack(); + stackSafe.push(1); stackSafe.push(2); + System.out.println(stackSafe); + stackUnsafe.push(1); stackUnsafe.push("two"); + System.out.println("This line compiles but crashes the program " + max(1, "two")); + } catch (ClassCastException e) { + System.err.println("RAW TYPES ARE UNSAFE " + e.getMessage()) ; + } + } +} diff --git a/Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/NoWildCard.java b/Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/NoWildCard.java new file mode 100644 index 0000000..0fe4096 --- /dev/null +++ b/Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/NoWildCard.java @@ -0,0 +1,32 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package edu.slcc.asdv.chloe.lab6_generics_chloefontenot; + +/** + * + * @author chloe + */ +public class NoWildCard { + + public static double max(GenericStack stack) { + double max = Double.MIN_VALUE; + + while (!stack.isEmpty()) { + double value = stack.pop().doubleValue(); + if (value > max) { + max = value; + } + } + return max; + } + + public static void main(String[] args) { + GenericStack intStack = new GenericStack<>(); + intStack.push(1); + intStack.push(2); + intStack.push(-2); + System.out.print("The max number is " + max(intStack)); + } +} diff --git a/Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/WildCard.java b/Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/WildCard.java new file mode 100644 index 0000000..984a777 --- /dev/null +++ b/Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/WildCard.java @@ -0,0 +1,32 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package edu.slcc.asdv.chloe.lab6_generics_chloefontenot; + +/** + * + * @author chloe + */ +public class WildCard { + + public static double max(GenericStack stack) { + double max = Double.MIN_VALUE; + + while (!stack.isEmpty()) { + double value = stack.pop().doubleValue(); + if (value > max) { + max = value; + } + } + return max; + } + + public static void main(String[] args) { + GenericStack intStack = new GenericStack<>(); + intStack.push(1); + intStack.push(2); + intStack.push(-2); + System.out.print("The max number is " + max(intStack)); + } +} diff --git a/Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/WildCard2.java b/Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/WildCard2.java new file mode 100644 index 0000000..20d8cf7 --- /dev/null +++ b/Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/WildCard2.java @@ -0,0 +1,25 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package edu.slcc.asdv.chloe.lab6_generics_chloefontenot; + +/** + * + * @author chloe + */ +public class WildCard2 { + public static void print(GenericStack stack) { + while (!stack.isEmpty()) { + System.out.print(stack.pop() + " "); + } + } + public static void main(String[] args) { + GenericStack intStack = new GenericStack<>(); + intStack.push(1); + intStack.push(2); + intStack.push(-2); + + print(intStack); + } +} diff --git a/Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/WildCardWithSuper.java b/Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/WildCardWithSuper.java new file mode 100644 index 0000000..caef309 --- /dev/null +++ b/Semester 3/Assignments/lab6_generics_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/lab6_generics_chloefontenot/WildCardWithSuper.java @@ -0,0 +1,28 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package edu.slcc.asdv.chloe.lab6_generics_chloefontenot; + +/** + * + * @author chloe + */ +public class WildCardWithSuper { + public static void add(GenericStack stack1, GenericStack stack2) { + while(!stack1.isEmpty()) { + stack2.push(stack1.pop()); + } + } + + public static void main(String[] args) { + GenericStack stack1 = new GenericStack<>(); + GenericStack stack2 = new GenericStack<>(); + stack2.push("one"); + stack2.push(2); + stack1.push("one"); + + add(stack1, stack2); + WildCard2.print(stack2); + } +} diff --git a/Semester 3/Exams/ProgrammingExam2_ChloeFontenot/src/main/java/com/chloefontenot/programmingexam2_chloefontenot/ProgrammingExam2_CalebFontenot.java b/Semester 3/Exams/ProgrammingExam2_ChloeFontenot/src/main/java/com/chloefontenot/programmingexam2_chloefontenot/ProgrammingExam2_CalebFontenot.java new file mode 100644 index 0000000..9d7eaa5 --- /dev/null +++ b/Semester 3/Exams/ProgrammingExam2_ChloeFontenot/src/main/java/com/chloefontenot/programmingexam2_chloefontenot/ProgrammingExam2_CalebFontenot.java @@ -0,0 +1,144 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package com.chloefontenot.programmingexam2_chloefontenot; + +/** + * + * @author chloe + */ + +/** + * + * @author ar114 + * @param + */ +public class ProgrammingExam2_ChloeFontenot { + + Node head; + Node tail; + + class Node { + + T t; + Node l; + Node r; + } + + public T removeAt(int pos) { + if (pos < 0 || pos > size() - 1) { + throw new IndexOutOfBoundsException(); + } + + //list is empty + if (size() == 0) { + throw new RuntimeException("The list empty."); + } + T returnT = null; + + if (pos == 0)//remove at 0 + { + Node pointer = head.r; + returnT = (T) head.t; + pointer.l = null; + head = pointer; + } else if (pos == (size() - 1))//remove at end + { + Node pointer = tail.l.l; + returnT = (T) tail.t; + pointer.r = null; + tail = pointer; + } else//remove in the middle + { + // Iterate to the element position + Node pointer = head; + for (int i = 0; i < pos - 1; ++i) { + pointer = pointer.r; + } + returnT = (T) pointer.r.t; + pointer.r = pointer.r.r; + pointer.l = pointer.r; + + + } + + return returnT; + } + + public void clear() { + head = tail = null; + } + + public void addAt(T t, int pos) { + if (pos < 0 || pos > size()) { + throw new IndexOutOfBoundsException(); + } + Node newNode = new Node(); + newNode.t = t; + if (head == null)//list is empty + { + head = tail = newNode; + } else if (pos == 0)//add at the front + { + newNode.r = head; + head.l = newNode; + head = newNode; + } else if (pos == size())//add at the end + { + newNode.l = tail; + tail.r = newNode; + tail = newNode; + } else//middle + { + Node p = head; + for (int i = 0; i < pos - 1; ++i) { + p = p.r; + } + newNode.l = p; + newNode.r = p.r; + p.r.l = newNode; + p.r = newNode; + } + } + + public int size() { + Node p = head; + int count = 0; + while (p != null) { + count++; + p = p.r; + } + return count; + } + + @Override + public String toString() { + String s = ""; + Node p = head; + while (p != null) { + s += p.t.toString() + " "; + p = p.r; + } + return s; + } + + public static void main(String[] args) { + ProgrammingExam2_ChloeFontenot list = new ProgrammingExam2_ChloeFontenot(); + + list.addAt(20, 0); + list.addAt(10, 0); + list.addAt(40, 2); + list.addAt(30, 2); + list.addAt(50, 4); + System.out.println(list); + System.out.println(list.removeAt(0)); + System.out.println(list); + System.out.println(list.removeAt(2)); + System.out.println(list); + + System.out.println(list.removeAt(2)); + System.out.println(list.toString()); + } + +} diff --git a/Semester 3/MP4_Generics_ChloeFontenot/src/main/java/com/chloefontenot/mp4_generics_chloefontenot/ArrayListASDV.java b/Semester 3/MP4_Generics_ChloeFontenot/src/main/java/com/chloefontenot/mp4_generics_chloefontenot/ArrayListASDV.java new file mode 100644 index 0000000..f643d21 --- /dev/null +++ b/Semester 3/MP4_Generics_ChloeFontenot/src/main/java/com/chloefontenot/mp4_generics_chloefontenot/ArrayListASDV.java @@ -0,0 +1,879 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp4_generics_chloefontenot; + +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.function.Consumer; + +/** + * + * @author chloe + */ +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; + + } + + /** + * 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(); + } + + 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 + * + */ + @Override + public boolean contains(Object o) + { + + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + + } + + /** + * 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 + ) + { + + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + + } + + /** + * 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() + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + + } + + /** + * 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 + ) + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + + } + + /** + * 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 + ) + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + + } + + /** + * 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()) + */ + @Override + 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"); + } else { + E tempO = this.list[index], temp; + this.list[index] = element; + if (index != this.index) { + for (int i = index + 1; i < this.index; i++) { + temp = this.list[i]; + this.list[i] = tempO; + tempO = temp; + } + } + + //this.list[++this.index] = tempO; + } + } + + /** + * 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()) + */ + @Override + public E remove(int index) + { + E r = this.list[index]; + this.list[index] = null; + if (index == 0) { + return r; + } + E temp, tempPre = this.list[this.index - 1]; + for (int i = this.index - 1; index >= i; i--) { + temp = this.list[i - 1]; + this.list[i - 1] = tempPre; + tempPre = temp; + } + this.index--; + return r; + + } + + /** + * 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 + ) + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + + } + + /** + * 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) + { + ListIterator iterator = listIterator(size()); + while (iterator.hasPrevious()) { + int indexOf = iterator.previousIndex(); + Object current = iterator.previous(); + if (current.equals(o)) { + return indexOf; + } + } + 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 + ) + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + + } + + /** + * 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() + { + return new IteratorASDV().iterator(); + //return new Iterator < E >(this); + } + + /** + * 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 = 0; + + /** + * 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() + { + if (this.index == this.list.length) { + + } + } + + /** + * 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 > this.list.length) { + throw new NoSuchElementException(); + } + return this.list[index++]; + } + + @Override + public boolean hasPrevious() + { + return index > 0; + } + + @Override + public E previous() + { + return this.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 == size() ? size() : 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) + { + while (hasNext()) { + if (action == null) { + throw new NullPointerException("Action is NULL! YOU ARE A FOOL!"); + } else { + 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) + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + + } + + @Override + public boolean addAll(Collection c) + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + + } + + @Override + public boolean addAll(int index, Collection c + ) + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + + } + + /** + * 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) + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + + } + + /** + * 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 + ) + { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + + } + + public static void main(String[] args) + throws ClassNotFoundException, InterruptedException + { + ArrayList aaa = new ArrayList(); + + 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) { + 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 lastndexOf()"); + 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---------------------------------------"); + 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/MP4_Generics_ChloeFontenot/src/main/java/com/chloefontenot/mp4_generics_chloefontenot/IteratorASDV.java b/Semester 3/MP4_Generics_ChloeFontenot/src/main/java/com/chloefontenot/mp4_generics_chloefontenot/IteratorASDV.java new file mode 100644 index 0000000..9f5fee2 --- /dev/null +++ b/Semester 3/MP4_Generics_ChloeFontenot/src/main/java/com/chloefontenot/mp4_generics_chloefontenot/IteratorASDV.java @@ -0,0 +1,62 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp4_generics_chloefontenot; + +import java.util.Iterator; +import java.util.function.Consumer; + +/** + * + * @author chloe + */ +public class IteratorASDV { + E[] list = (E[]) new Object[3]; + int i; + public void add (E e) { + list[i++] = e; + } + + public IteratorASDV iterator() implements Iterator{ + Iterator it = new Iterator() + { + int index = 0; + + @Override + public boolean hasNext() + { + if (index == IteratorASDV.this.list.length) { + return false; + } + return true; + } + + @Override + public E next() + { + return IteratorASDV.this.list[index++]; + } + + @Override + public void forEachRemaining(Consumer action) + { + Iterator.super.forEachRemaining(action); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/OverriddenMethodBody + } + + }; + return (IteratorASDV) it; + }; + public static void main(String[] args) + { + IteratorASDV ti = new IteratorASDV(); + ti.add(1); + ti.add(2); + ti.add(3); + Iterator it = (Iterator) ti.iterator(); + while (it.hasNext()) { + System.out.println(it.next()); + } + } +} + diff --git a/Semester 3/MP4_Generics_ChloeFontenot/src/main/java/com/chloefontenot/mp4_generics_chloefontenot/MP4_Generics_CalebFontenot.java b/Semester 3/MP4_Generics_ChloeFontenot/src/main/java/com/chloefontenot/mp4_generics_chloefontenot/MP4_Generics_CalebFontenot.java new file mode 100644 index 0000000..e9e0953 --- /dev/null +++ b/Semester 3/MP4_Generics_ChloeFontenot/src/main/java/com/chloefontenot/mp4_generics_chloefontenot/MP4_Generics_CalebFontenot.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package com.chloefontenot.mp4_generics_chloefontenot; + +/** + * + * @author chloe + */ +public class MP4_Generics_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 4/Assignments/Hashing_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/hashing_chloefontenot/MapASDV.java b/Semester 4/Assignments/Hashing_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/hashing_chloefontenot/MapASDV.java new file mode 100644 index 0000000..6e6d662 --- /dev/null +++ b/Semester 4/Assignments/Hashing_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/hashing_chloefontenot/MapASDV.java @@ -0,0 +1,791 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package edu.slcc.asdv.chloe.hashing_chloefontenot; + +/** + * + * @author chloe + */ +import asdv.ListASDV; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.function.BiConsumer;//needed in putAll + +public class MapASDV implements Map, Cloneable +{ + + private int capacity = 4; + private double loadFactor = 0.75; + private ArrayList>> map = new ArrayList>>(); + + private Set sharedKeySet = new SharedSet(); + private Set> sharedEntrySet = new SharedSet>(); + private Collection sharedValuesCollection = new SharedCollection(); + + private class SharedCollection extends ArrayList + { + + public boolean addValue(V v) + { + return this.add(v); + } + + @Override + public boolean remove(Object o) + { + + //> The parameter is key not entry if we are here + //>>remove value) and key) from the map + return MapASDV.this.removeFirstValue(o); + + //>>remove key from shared values set + //return super.remove(o); + } + + /** + * Removes one value from the collection. This method is meant to be + * called from out class. The overridden remove(Object o) of this inner + * class, calls the remove of the outer class(MapASDV), and the remove + * of the outer class, calls remove(V v, boolean callFromOuterClass) + * instead of remove(Object o) to avoid Stack Overflow when remover of + * inner calls remove of outer and vice versa. + * + * @param o - the key + * @param callFromOuterClass - dummy variable. + * @return true if the key was removed from the Set + */ + public boolean remove(V v, boolean callFromOuterClass) + { + //remove key from shared keys set + boolean b = super.remove(v); + return b; + + } + + @Override + public Object clone() + { + return super.clone(); + } + + @Override + public void clear() + { + super.clear(); + } + } + + private class SharedSet extends HashSet + { + + @Override + public boolean add(E e) + { + throw new UnsupportedOperationException("Not supported...."); + } + + @Override + public boolean removeAll(Collection c) + { + throw new UnsupportedOperationException("Not supported...."); + } + + /** + * Adds an EntryASDV to the set. It is private and cannot be used by the + * user of the Set. It is used from the MapASDV to add EntriesASDV to + * the SharedSet. Without this method we wouldn't be able to create a + * Set of keys or a Set of entries to give to the user via methods + * keySet() and entrySet() of this Map + * + * @param e EntryASDV + * @return true if the entry was added false otherwise + */ + private boolean addEntry(E e) + { + return super.add(e); + } + + @Override + public boolean remove(Object o) + { + + //>if parameter oo is EntryASDV call auxiliary method removeEntry + if (o instanceof EntryASDV) + { + return removeEntry((EntryASDV) o); + } + + //> The parameter is key not entry if we are here + //>>remove key from the map + MapASDV.this.remove(o); + //>>remove key from shared keys set + return super.remove(o); + } + + /** + * Removes the entry for the shared set + * + * @param entry the entry to be removed + * @return true if the entry was removed, false otherwise + */ + private boolean removeEntry(EntryASDV entry) + { + + MapASDV.this.remove(entry.getKey()); + return super.remove(entry); + } + + /** + * Removes the key from the set. This method is meant to be called from + * out class. The overridden remove(Object o) of this inner class calls + * the remove of the out class, and the remove of the outer class calls + * remove(K o, boolean callFromOuterClass) instead of remove(Object o) + * to avoid Stack Overflow when remover of inner calls remove of outer + * and vice versa. + * + * @param o - the key + * @param callFromOuterClass - dummy variable. + * @return true if the key was removed from the Set + */ + public boolean remove(E o, boolean callFromOuterClass) + { + + //remove key from shared keys set + return super.remove(o); + } + + @Override + public Object clone() + { + return super.clone(); + } + + @Override + public void clear() + { + super.clear(); + } + + } + + public MapASDV() + { + for (int i = 0; i < capacity; ++i) + { + map.add(new ListASDV>()); + } + } + + /** + * Double the size of the Map and rehashes the entries of the Map + */ + private void doubleTheSizeOfTheMapAndRehash() + { + capacity *= 2; + //>create a new arrayList of ListsASDV + ArrayList>> newMap = new ArrayList>>(); + + //>Add at every enetry of the arrayList a new ASDVList + for (int i = 0; i < capacity; ++i) + { + newMap.add(new ListASDV>()); + } + + //>for the size of the OLD arrayList + for (int i = 0; i < map.size(); ++i)//array list + { + //>> get The ASDVlist at i + ListASDV> list = map.get(i); + + //>>for the size() of the ASDVlist + for (int j = 0; j < list.size(); ++j) + { + ///>>>hash and put in the the new array + int index = hash( list.get(j).getKey().hashCode() ); + newMap.get(index).add(list.get(j)); + + } + } + map = newMap; + } + + class EntryASDV implements Entry, Comparable + { + + K key; + V value; + + public EntryASDV(K key, V value) + { + this.key = key; + this.value = value; + } + + @Override + public K getKey() + { + return key; + } + + @Override + public V getValue() + { + return value; + } + + @Override + public V setValue(V value) + { + V oldValue = this.value; + this.value = value; + return oldValue; + } + + @Override + public String toString() + { + return "EntryASDV{" + "key=" + key + ", value=" + value + '}'; + } + + @Override + public boolean equals(Object obj) + { + if (this == obj) + { + return true; + } + if (obj == null) + { + return false; + } + if (getClass() != obj.getClass()) + { + return false; + } + final EntryASDV other = (EntryASDV) obj; + if (!Objects.equals(this.key, other.key)) + { + return false; + } + return true; + } + + /** + * + * @param o + * @return throws IllegalArgumentException if parameter class is not K + */ + @Override + public int compareTo(K o) + { + if (getClass() != o.getClass()) + { + throw new IllegalArgumentException("ellegal parameter " + o); + } + return ((Comparable) key).compareTo(o); + } + + } + + @Override + public int size() + { + return this.keySet().size(); + } + + @Override + public boolean isEmpty() + { + throw new UnsupportedOperationException("Not supported...."); + + } + + @Override + public boolean containsKey(Object key) + { + throw new UnsupportedOperationException("Not supported yet...."); + + } + + /** + * Return an entry of the map + * + * @param key the key of the entry to be returned + * @return the entry, or null if the key is not in the map + */ + private EntryASDV getEntryForKey(Object key) + { + for (ListASDV> list : map) + { + Iterator> it = list.iterator(); + while (it.hasNext()) + { + EntryASDV entry = it.next(); + if (key.equals(entry.getKey())) + { + return entry; + } + } + } + return null; + } + + /** + * Returns the index of the given key + * + * @param key a key of the map + * @return the index of a key in the map or -1, if the key is not in the map + */ + private int getIndexForKey(Object key) + { + for (int i = 0; i < map.size(); ++i) + { + Iterator> it = map.get(i).iterator(); + while (it.hasNext()) + { + EntryASDV entry = it.next(); + if (key.equals(entry.getKey())) + { + return i; + } + } + } + return -1; + } + + /** + * Returns true if this map maps one or more keys to the specified value. + * More formally, returns true if and only if this map contains at least one + * mapping to a value v such that (value==null ? v==null : value.equals(v)). + * This operation will probably require time linear in the map size for most + * implementations of the Map interface. + * + * Parameters: value - value whose presence in this map is to be tested + * Returns: true if this map maps one or more keys to the specified value + * Throws: ClassCastException - if the value is of an inappropriate type for + * this map (optional) NullPointerException - if the specified value is null + * and this map does not permit null values (optional) + * + * @param value - value whose presence in this map is to be tested + * @return true if this map maps one or more keys to the specified value + * @throws NullPointerException - if the specified value is null and this + * map does not permit null values (optional) + */ + @Override + public boolean containsValue(Object value) + { + throw new UnsupportedOperationException("Not supported yet...."); + + } + + /** + * Returns the value to which the specified key is mapped, or null if this + * map contains no mapping for the key. + * + * More formally, if this map contains a mapping from a key k to a value v + * such that (key==null ? k==null : key.equals(k)), then this method returns + * v; otherwise it returns null. (There can be at most one such mapping.) + * + * If this map permits null values, then a return value of null does not + * necessarily indicate that the map contains no mapping for the key; it's + * also possible that the map explicitly maps the key to null. The + * containsKey operation may be used to distinguish these two cases. + * + * @param key - the key whose associated value is to be returned + * @return the value to which the specified key is mapped, or null if this + * map contains no mapping for the key + * @throws NullPointerException - if the specified key is null and this map + * does not permit null keys (optional) + */ + @Override + public V get(Object key) + { + throw new UnsupportedOperationException("Not supported yet...."); + + } + + /** + * Associates the specified value with the specified key in this map + * (optional operation). If the map previously contained a mapping for the + * key, the old value is replaced by the specified value. (A map m is said + * to contain a mapping for a key k if and only if m.containsKey(k) would + * return true.) + * + * @param key - key with which the specified value is to be associated + * @param value - value to be associated with the specified key + * @return the previous value associated with key, or null if there was no + * mapping for key. (A null return can also indicate that the map previously + * associated null with key, if the implementation supports null values.) + * @throws NullPointerException - if specified key or value is null and this + * map does not permit null keys + */ + @Override + public V put(K key, V value) + { + + if (key == null || value == null) + { + throw new NullPointerException("parm(s) null"); + } + + //>if contains the key, replace the key's value + EntryASDV entry = getEntryForKey(key); + if (entry != null) + { + V oldValue = entry.value; + entry.value = value; + + return oldValue; + } + ///>>hash and put in the array + int code = this.hash(key.hashCode()); + int index = hash(code); + + ListASDV> list = map.get(index); + EntryASDV e = new EntryASDV(key, value); + list.add(e); + + //>>add the key to the shared keys-set + ((SharedSet) this.sharedKeySet).addEntry(key); + ((SharedSet>) this.sharedEntrySet).addEntry(e); + + //>>get the value of this entry + V v = list.get(list.size() - 1).getValue(); + + //>> add value to the value collection + ((SharedCollection) this.sharedValuesCollection).addValue(v); + + //>> if reach 75% capacity double the size + if ((double) this.size() / capacity >= 0.75) + { + this.doubleTheSizeOfTheMapAndRehash(); + } + + //>>return the value of Entry just added + return v; + } + + int hash(int keyHashCode) + { + int h = hashHash(keyHashCode); + return Math.abs(h % capacity - 1); + } + + /** + * Removes the first entry with the given values. + * + * @param value - the value to be removed + * @return true if removed, false otherwise + * @throws NullPointerException if the value is null + */ + private boolean removeFirstValue(Object value) + { + throw new UnsupportedOperationException("Not supported yet...."); + + } + + /** + * Ensure hash code is evenly distributed + * + * @param h - hash code + * @return evenly distributed hash code + */ + private static int hashHash(int h) + { + h ^= (h >>> 20) ^ (h >>> 12); + return h ^ (h >>> 7) ^ (h >>> 4); + } + + /** + * Removes the mapping for a key from this map if it is present (optional + * operation). More formally, if this map contains a mapping from key k to + * value v such that (key==null ? k==null : key.equals(k)), that mapping is + * removed. (The map can contain at most one such mapping.) + * + * @param key - key whose mapping is to be removed from the map + * @return the previous value associated with key, or null if there was no + * mapping for key. + * @throws NullPointerException - if the specified key is null and this map + * does not permit null keys + */ + @Override + public V remove(Object key) + { + throw new UnsupportedOperationException("Not supported yet...."); + + } + + /** + * Copies all of the mappings from the specified map to this map (optional + * operation). The effect of this call is equivalent to that of calling + * put(k, v) on this map once for each mapping from key k to value v in the + * specified map. The behavior of this operation is undefined if the + * specified map is modified while the operation is in progress. + * + * @param m - mappings to be stored in this map + * @throws NullPointerException - if the specified map is null, or if this + * map does not permit null keys or values, and the specified map contains + * null keys + */ + @Override + public void putAll(Map m) + { + if (m == null) + { + throw new NullPointerException("null parameter"); + } + + BiConsumer consumeEachEntry = new BiConsumer() + { + MapASDV mapForConsumer = MapASDV.this; + + @Override + public void accept(K k, V v) + { + mapForConsumer.put(k, v); + } + }; + + m.forEach(consumeEachEntry); + } + + + /** + * Removes all of the mappings from this map (optional operation). The map + * will be empty after this call returns. Any shared sets are also cleared. + */ + @Override + public void clear() + { + throw new UnsupportedOperationException("Not supported yet...."); + + } + + /** + * Returns a Set view of the keys contained in this map. The set is backed + * by the map, so changes to the map are reflected in the set, and + * vice-versa. If the map is modified while an iteration over the set is in + * progress (except through the iterator's own remove operation), the + * results of the iteration are undefined. The set supports element removal, + * which removes the corresponding mapping from the map, via the + * Iterator.remove, Set.remove, removeAll, retainAll, and clear operations. + * It does not support the add or addAll operations. + * + * @return a set view of the keys contained in this map + */ + @Override + public Set keySet() + { + + return this.sharedKeySet; + } + + /** + * Returns a Collection view of the values contained in this map. The + * collection is backed by the map, so changes to the map are reflected in + * the collection, and vice-versa. If the map is modified while an iteration + * over the collection is in progress (except through the iterator's own + * remove operation), the results of the iteration are undefined. The + * collection supports element removal, which removes the corresponding + * mapping from the map, via the Iterator.remove, Collection.remove, + * removeAll, retainAll and clear operations. It does not support the add or + * addAll operations. + * + * @return + */ + @Override + public Collection values() + { + return sharedValuesCollection; + } + + /** + * Returns a Set view of the mappings contained in this map. The set is + * backed by the map, so changes to the map are reflected in the set, and + * vice-versa. If the map is modified while an iteration over the set is in + * progress (except through the iterator's own remove operation, or through + * the setValue operation on a map entry returned by the iterator) the + * results of the iteration are undefined. The set supports element removal, + * which removes the corresponding mapping from the map, via the + * Iterator.remove, Set.remove, removeAll, retainAll and clear operations. + * It does not support the add or addAll operations. + * + * + * @return a set view of the mappings contained in this map + */ + @Override + public Set> entrySet() + { + return this.sharedEntrySet; + } + + @Override + public String toString() + { + String s = "[ "; + for (int i = 0; i < capacity; ++i) + { + s += map.get(i).toString() + "\n"; + } + s += " ]"; + + return s; + } + + /** + * Created a deep copy of the MapASDV + * + * @return the deep copy of the map + */ + @Override + public Object clone() + { + /* + MapASDV clonedMap = new MapASDV(); + + //clonedMap.putAll(this); + + for (ListASDV< EntryASDV> list : this.map) + { + ListASDV< EntryASDV> l = (ListASDV< EntryASDV>) list.clone(); + clonedMap.map.add(l); + } + return clonedMap; + */ + + MapASDV clonedMap = new MapASDV(); + clonedMap.putAll(this); + return clonedMap; + } + + public static void main(String[] args) + { + + MapASDV map = new MapASDV(); + System.out.println("---------------------------testing put(K, V)"); + map.put("ann", 20); + map.put("coco", 25); + System.out.println(map); + mapASDV.MapASDV clonedMap = ( mapASDV.MapASDV) map.clone(); + + System.out.println("\n\n---------------------------testing double-the-size-and-rehash by reaching 0.75 load factor with another put(K, V)"); + map.put("Jonathan", 30); + System.out.println(map); + map.put("Jonhathan", 45); + System.out.println(map); + map.put("Alexander", 33); + System.out.println(map); + + System.out.println("\n\n---------------------------testing putAll(Map)"); + Map anotherJavaMap = new HashMap(); + anotherJavaMap.put("lion king", 45); + anotherJavaMap.put("HYENA", 6); + map.putAll(anotherJavaMap); + System.out.println(map); + + + System.out.println("\n\n---------------------------testing containsKey"); + System.out.println(map.containsKey("Alexander")); + System.out.println(map.containsKey("alexander")); + + System.out.println("\n\n---------------------------testing containsValue"); + System.out.println(map.containsValue(33)); + System.out.println(map.containsValue(34)); + + System.out.println("\n\n---------------------------testing getEntryForKey"); + Entry e = map.getEntryForKey("Alexander"); + System.out.println( map.getEntryForKey("Alexander")); + System.out.println( map.getEntryForKey("Alex")); + + System.out.println("\n\n---------------------------testing get"); + System.out.println(map.get( "Alexander") ); + System.out.println(map.get( "Alex") ); + try{ map.get( null);}catch (NullPointerException ex ){System.out.println(ex.getMessage());} + + System.out.println("\n\n---------------------------testing getIndexForKey"); + System.out.println(map.getIndexForKey("Alexander")); + System.out.println(map.getIndexForKey("Alex")); + + System.out.println("\n\n---------------------------testing isEmpty"); + System.out.println( map.isEmpty()); + + + System.out.println("\n\n---------------------------testing size"); + System.out.println( map.size()); + System.out.println( map); + + System.out.println("\n\n---------------------------testing entrySet()"); + Set> entries = map.entrySet(); + System.out.println( entries); + + System.out.println("\n\n---------------------------testing keySet()"); + Set keys = map.keySet(); + System.out.println( keys ); + + System.out.println("\n\n---------------------------testing values()"); + Collection values = map.values(); + System.out.println( values); + + System.out.println("\n\n---------------------------testing remove( K) coco 25"); + map.remove("coco"); + System.out.println(map); + System.out.println(entries); + System.out.println(keys); + System.out.println(values); + + System.out.println("\n\n---------------------------testing Entry-Collection remove "); + entries.remove( e); + System.out.println(map); + System.out.println(entries); + System.out.println(keys); + System.out.println(values); + + + System.out.println("\n\n---------------------------testing Set Keys remove "); + keys.remove( "ann"); + System.out.println(map); + System.out.println(entries); + System.out.println(keys); + System.out.println(values); + + + System.out.println("\n\n---------------------------testing Set Values remove "); + values.remove( 45); + System.out.println(map); + System.out.println(entries); + System.out.println(keys); + System.out.println(values); + + System.out.println("\n\n---------------------------testing clear "); + map.clear(); + System.out.println(map); + System.out.println(entries); + System.out.println(keys); + + System.out.println("\n\n---------------------------testing add of sets and collections "); + try{ keys.add( "a");}catch (Exception ex ){System.out.println(ex.getMessage());} + try{ values.add( 33);}catch (Exception ex ){System.out.println(ex.getMessage());} + try{ entries.add( e);}catch (Exception ex ){System.out.println(ex.getMessage());} + + + + System.out.println("\n\n---------------------------testing clone"); + System.out.println( clonedMap); + + System.out.println("---------------------------testing put(K, V) AGAIN"); + map.put("Nicholas", 100); + map.put("a", 200); + map.put("b", -20); + System.out.println( map); + + } + +} diff --git a/Semester 4/Assignments/MP1_ManyToMany_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp1_manytomany_chloefontenot/ManyToMany.java b/Semester 4/Assignments/MP1_ManyToMany_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp1_manytomany_chloefontenot/ManyToMany.java new file mode 100644 index 0000000..a5813bc --- /dev/null +++ b/Semester 4/Assignments/MP1_ManyToMany_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp1_manytomany_chloefontenot/ManyToMany.java @@ -0,0 +1,114 @@ +/* + * 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.chloe.mp1_manytomany_chloefontenot; + +/** + * + * @author chloe + */ +import java.util.List; +import java.util.Set; + +/** + * + * @author A. V. Markou + * @param + * @param + */ +public interface ManyToMany +{ + /** + * Creates a Many to Many relationship between the parentLeft and the + * childrenRight. Example for ( Many1 a, Many2 1, 2, 3) it creates --> (a 1) + * ( a 2 ) ( a 3 ) and ( 1, a ), ( 2, a ), ( 3, a). No duplicate values of + * Many2 are allowed. + * + * @param parentLeft - exactly one Many1 object. + * @param childrenRight - one or more Many2 objects. + * @return the previous value associated with Many1, or null if there was no + * Many1 with the same "key". + * @throws ClassCastException - if the class of the specified Many1, or + * Many2 or value prevents it from being stored in this map( i,e Many1 is + * String and you pass an object) + * @throws NullPointerException - if the specified Many1 or Many2 is null + * and ManyToMany does not permit nulls as values. + * @throw IllegalArgumentException - if a duplicate exists in childrenRight + * list ( s1 --> p1,p2,p2 is not allowed). + * @return the previous value associated with parentLeft, or null if there + * was no childrenRight for parentLeft. + */ + List add(Many1 parentLeft, Many2... childrenRight); + + /** + * Returns the List of all left children of the parentRight. + * + * @param parentRight a parent at the RHS of the many to many relationship. + * @return the List of all left children of the parentRight. + * @throw IllegalArgumentException if the value of parameter parentRight + * does not exist in the RHS of the many to many relationship. + */ + List getChildrenLeft(Many2 parentRight); + + /** + * Returns the List of all right children of the parentLeft. + * + * @param parentLeft a parent at the LHS of the many to many relationship. + * @return the List of all right children of the parentLeft. + * @throws IllegalArgumentException if the value of parameter parentLeft + * does not exist on the LHS of the many to many relationship. + */ + List getChildrenRight(Many1 parentLeft); + + /** + * Returns a set of the Many1 elements that exist on the LHS of the many to + * many relationship. + * + * @return Set of Many1 + */ + Set getParentsLeft(); + + /** + * Returns a set of the Many2 elements that exist on the RHS of the many to + * many relationship. + * + * @return Set of Many2 + */ + Set getParentsRight(); + + /** + * Removes the many1 parameter from the LHS of the many relationship AND all + * its corresponding values that exist in the RHS of the many to many + * relationship. For example given: ( LHS e1: p1, p2 e2: p2, p3 RHS: p1: e1 + * p2: e1, e2 p3: e2 after removing e1 from the LHS will results into: ( LHS + * e2: p2, p3 RHS: p2: e2 p3: e2 + * + * @param many1 the unique element on the LHS to be removed. + * @throws NullPointerException if parameter many1 is null. + * @return true if the removal occurred, false if many1 does not exist in + * the LHS of the many to many relationship. + */ + boolean removeLeft(Many1 many1); + + /** + * Removes the many1 parameter from the RHS of the many relationship AND all + * its corresponding values that exist in the LHS of the many to many + * relationship. For example given: LHS e2: p2, p3 RHS: p2: e2 p3: e2 after + * removing p2 from the RHS will results into: LHS e2: p3 RHS p3: e2 + * + * + * @param many2 the unique element on the LHS to be removed. + * @throws NullPointerException if parameter many1 is null. + * @return true if the removal occurred, false if many1 does not exist in + * the LHS of the many to many relationship. + */ + boolean removeRight(Many2 many2); + + /** + * Clears all. + * + */ + void clear(); +} + diff --git a/Semester 4/Assignments/MP1_ManyToMany_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp1_manytomany_chloefontenot/ManyToManyFactory.java b/Semester 4/Assignments/MP1_ManyToMany_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp1_manytomany_chloefontenot/ManyToManyFactory.java new file mode 100644 index 0000000..18d891b --- /dev/null +++ b/Semester 4/Assignments/MP1_ManyToMany_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/mp1_manytomany_chloefontenot/ManyToManyFactory.java @@ -0,0 +1,233 @@ +/* + * 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.chloe.mp1_manytomany_chloefontenot; + +/** + * + * @author chloe + */ +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + +/** + * + * @author asdv5 + */ +public class ManyToManyFactory { + + public static //generic types to be used in the method + ManyToMany< Many1, Many2>//return type + createManyToMany() { + return new ManyToMany() { + private HashSet parents = new HashSet<>(); + + private Map left = new HashMap<>(); + private Map right = new HashMap<>(); + + @Override + public String toString() { + return "{" + "left=" + left + ", right=" + right + '}'; + } + + /** + * Creates a Many to Many relationship between the parentLeft and the childrenRight. Example for ( Many1 a, Many2 1, 2, 3) it creates --> (a 1) ( a 2 ) ( a 3 ) and ( 1, a ), ( 2, a ), ( 3, a). No duplicate values of Many2 are allowed. + * + * @param parentLeft - exactly one Many1 object. + * @param childrenRight - one or more Many2 objects. + * @return the previous value associated with Many1, or null if there was no Many1 with the same "key". + * @throws ClassCastException - if the class of the specified Many1, or Many2 or value prevents it from being stored in this map( i,e Many1 is String and you pass an object) + * @throws NullPointerException - if the specified Many1 or Many2 is null and ManyToMany does not permit nulls as values. + * @throw IllegalArgumentException - if a duplicate exists in childrenRight list ( s1 --> p1,p2,p2 is not allowed). + * @return the previous value associated with parentLeft, or null if there was no childrenRight for parentLeft. + */ + @Override + public List add(Many1 parentLeft, Many2... childrenRight) { + HashSet verifyUnique = new HashSet<>(); + List returnList = new ArrayList<>(); + + // Check for exceptions + if (!childrenRight.equals(parentLeft.getClass())) { + //throw new ClassCastException(); + } + if (parentLeft == null || childrenRight == null) { + throw new NullPointerException(); + } + // Try to add all elements from childrenRight into HashSet. If we're unable to, through an IllegalArgumentException, assuming HashSet doesn't throw one already. + verifyUnique.addAll(Arrays.asList(childrenRight)); + if (left.size() > 0 && childrenRight.length > 0) { + for (Object e : left.values()) { + returnList.add((Many2) e); + } + //returnList.addAll(() left.values()); + } + // Keep track of the parents so we can manipulate the RHS + parents.add(parentLeft); + // Handle LHS + //for (Many2 e : childrenRight) { + left.put(parentLeft, new ArrayList(Arrays.asList(childrenRight))); + //} + //Handle RHS + /* + for (Many1 e: parents) { + + right.put(, e ); + } + */ + if (returnList.size() == 0) { + return null; + } + return returnList; + } + + /** + * Returns the List of all left children of the parentRight. + * + * @param parentRight a parent at the RHS of the many to many relationship. + * @return the List of all left children of the parentRight. + * @throw IllegalArgumentException if the value of parameter parentRight does not exist in the RHS of the many to many relationship. + */ + @Override + public List getChildrenLeft(Many2 parentRight) { + List returnList = new ArrayList(); + for (Entry ee : left.entrySet()) { + System.out.println(ee.getKey() + ", " + parentRight); + if (ee.getKey().equals(parentRight)) { + returnList.add((Many1) ee.getValue()); + } + } + if (returnList.size() > 0) { + return null; + } + return returnList; + } + + /** + * Returns the List of all right children of the parentLeft. + * + * @param parentLeft a parent at the LHS of the many to many relationship. + * @return the List of all right children of the parentLeft. + * @throws IllegalArgumentException if the value of parameter parentLeft does not exist on the LHS of the many to many relationship. + */ + @Override + public List getChildrenRight(Many1 parentLeft) { + List returnList = new ArrayList<>(); + for (Entry ee : right.entrySet()) { + if (ee.getKey() == parentLeft) { + returnList.add((Many2) ee.getValue()); + } + } + if (returnList.size() > 0) { + return null; + } + return returnList; + } + + /** + * Returns a set of the Many1 elements that exist on the LHS of the many to many relationship. + * + * @return Set of Many1 + */ + @Override + public Set getParentsLeft() { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public Set getParentsRight() { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public boolean removeLeft(Many1 many1) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public boolean removeRight(Many2 many2) { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + + @Override + public void clear() { + throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody + } + }; + } + + public static void main(String[] args) throws InterruptedException { + ManyToMany mm = ManyToManyFactory.createManyToMany(); + //mm.add(1, 1);///will not compile, we have Many1, Many2 as String + System.out.println("add(e1, p1, p2)returns: " + mm.add("e1", "p1", "p2")); + System.out.println("add(e2, p2, p3)returns: " + mm.add("e2", "p2", "p3")); + //System.out.println("getParentsLeft returns: " + mm.getParentsLeft()); + //System.out.println("getParentsRight returns: " + mm.getParentsRight()); + System.out.println("getChildrenLeft(p1) returns: " + mm.getChildrenLeft("p2")); + System.out.println("getChildrenLeft(p2) returns: " + mm.getChildrenLeft("p3")); + System.out.println("getChildrenRight(e1) returns: " + mm.getChildrenRight("e1")); + System.out.println("getChildrenRight(e1) returns: " + mm.getChildrenRight("e2")); + System.out.println("-----------------------------------------------"); + System.out.println("The internal hash maps of ManyToMany after insertions: " + mm); + + System.out.println("----------AFTER REMOVAL of e1 LEFT----------------------------------------"); + System.out.println("removeLeft(e1) returns: " + mm.removeLeft("e1")); + System.out.println("getParentsLeft returns: " + mm.getParentsLeft()); + System.out.println("getParentsRight returns: " + mm.getParentsRight()); + System.out.println("getChildrenRight(e2) returns: " + mm.getChildrenRight("e2")); + System.out.println("getChildrenLeft(p2) returns: " + mm.getChildrenLeft("p2")); + System.out.println("getChildrenLeft(p3) returns: " + mm.getChildrenLeft("p3")); + System.out.println("The internal hash maps of ManyToMany after removal LEFT: " + mm); + + System.out.println("\n----------AFTER REMOVAL of p2 RIGHT----------------------------------------"); + System.out.println("removeLeft(p2) returns: " + mm.removeRight("p2")); + System.out.println("getParentsLeft returns: " + mm.getParentsLeft()); + System.out.println("getParentsRight returns: " + mm.getParentsRight()); + System.out.println("getChildrenRight(e2) returns: " + mm.getChildrenRight("e2")); + System.out.println("getChildrenLeft(p3) returns: " + mm.getChildrenLeft("p3")); + System.out.println("--------------------------------------------------"); + System.out.println("mm.removeLeft(e1) returns: " + mm.removeLeft("e1")); + + System.out.println("The internal hash maps of ManyToMany after removal RIGHT: " + mm); + Thread.sleep(5000, 0); + + System.out.println("---------------CATCHING EXCEPTIONS -----------------------------------"); + try { + mm.getChildrenRight("e10");//e10 dos not exist + } catch (RuntimeException e) { + System.err.println("getChildrenRight for e10 throws exception:" + e); + } + try { + System.out.println(mm.add("e6", new String[]{ + "value1", null + })); + } catch (RuntimeException e) { + System.err.println("add(e6, new String[]{null } ) throws exception: " + e); + } + try { + System.out.println(mm.add(null, "p1")); + } catch (RuntimeException e) { + System.err.println("add(null, p1)returns throws exception: " + e); + } + try { + System.out.println(mm.getChildrenLeft("p1")); + } catch (RuntimeException e) { + System.err.println("getChildrenRight(p1) throws exception: " + e); + } + try { + mm.add((String) new Object(), (String) new Object()); + } catch (RuntimeException e) { + System.err.println("add((String) new Object(), (String) new Object()) throws exception: " + e); + } + mm.clear(); + System.out.println("-----------------------------------------------"); + System.out.println("The internal hash maps of ManyToMany after clear: " + mm); + + } +} diff --git a/Semester 4/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/MP2_CalebFontenot.java b/Semester 4/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/MP2_CalebFontenot.java new file mode 100644 index 0000000..d981608 --- /dev/null +++ b/Semester 4/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/MP2_CalebFontenot.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package com.chloefontenot.mp2_chloefontenot; + +/** + * + * @author chloe + */ +public class MP2_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 4/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/Matrices.java b/Semester 4/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/Matrices.java new file mode 100644 index 0000000..d874474 --- /dev/null +++ b/Semester 4/Assignments/MP2_ChloeFontenot/src/main/java/com/chloefontenot/mp2_chloefontenot/Matrices.java @@ -0,0 +1,142 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template + */ +package com.chloefontenot.mp2_chloefontenot; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.RecursiveTask; + +/** + * + * @author chloe + */ +public class Matrices { + + public static void main(String[] args) { + Matrices.multiplyParallel(); + } + + public static ArrayList> createRandomMatrix(int rows, int columns) { + ArrayList> matrix = new ArrayList>(rows); + for (int i = 0; i < rows; ++i) { + ArrayList row = new ArrayList(); + for (int j = 0; j < columns; ++j) { + row.add(new BigInteger(Integer.toString(1 + (int) (Math.random() * 9)))); + } + matrix.add(row); + } + return matrix; + } + + public static void multiplyParallel() { + /* + ArrayList> A = new ArrayList<>(); + ArrayList row1 = new ArrayList<>(); + row1.add(new BigInteger("6")); + row1.add(new BigInteger("1")); + ArrayList row2 = new ArrayList<>(); + row2.add(new BigInteger("7")); + row2.add(new BigInteger("2")); + A.add(row1); + A.add(row2); + + ArrayList> B = new ArrayList<>(); + row1 = new ArrayList(); + row1.add(new BigInteger("4")); + row1.add(new BigInteger("1")); + row1.add(new BigInteger("2")); + row2 = new ArrayList(); + row2.add(new BigInteger("1")); + row2.add(new BigInteger("9")); + row2.add(new BigInteger("5")); + B.add(row1); + B.add(row2); + */ + ArrayList> A = Matrices.createRandomMatrix(2, 2); + ArrayList> B = Matrices.createRandomMatrix(2, 3); + + RecursiveTask>> rt + = new Matrices.MatricesMultiplication(0, A.size() - 1, A, B); + ForkJoinPool pool = new ForkJoinPool(); + ArrayList> mul = pool.invoke(rt); + + System.out.println("MATRIX A"); + printMatrix(A); + System.out.println("\nMATRIX B"); + printMatrix(B); + System.out.println("\nMATRIX AxB"); + printMatrix(mul); + } + + private static void printMatrix(ArrayList> matrix) { + for (int i = 0; i < matrix.size(); ++i) { + System.out.println(matrix.get(i)); + } + } + + static class MatricesMultiplication extends RecursiveTask>> { + + ArrayList> A; + ArrayList> B; + ArrayList> AxB; + final int HOW_MANY_ROWS_IN_PARALLEL = 3;// threshold + int startIndex; + int endIndex; + + public MatricesMultiplication(int startIndex, int endIndex, ArrayList> A, ArrayList> B) { + this.startIndex = startIndex; + this.endIndex = endIndex; + this.A = A; + this.B = B; + + } + + @Override + protected ArrayList> compute() { + // Base case: if the number of rows in A is less than or equal to the threshold, + // perform matrix multiplication sequentially + if (endIndex - startIndex + 1 <= HOW_MANY_ROWS_IN_PARALLEL) { + ArrayList> result = new ArrayList<>(); + for (int i = startIndex; i <= endIndex; i++) { + ArrayList rowResult = new ArrayList<>(); + for (int j = 0; j < B.get(0).size(); j++) { + BigInteger sum = BigInteger.ZERO; + for (int k = 0; k < A.get(0).size(); k++) { + sum = sum.add(A.get(i).get(k).multiply(B.get(k).get(j))); + } + rowResult.add(sum); + } + result.add(rowResult); + } + return result; + } else { + // Split the task into smaller subtasks + int middle = (startIndex + endIndex) / 2; + MatricesMultiplication leftTask = new MatricesMultiplication(startIndex, middle, A, B); + MatricesMultiplication rightTask = new MatricesMultiplication(middle + 1, endIndex, A, B); + + // Fork the subtasks + leftTask.fork(); + ArrayList> rightResult = rightTask.compute(); + + // Join the results of the subtasks + ArrayList> leftResult = leftTask.join(); + + // Merge the results + ArrayList> result = new ArrayList<>(); + for (int i = 0; i < leftResult.size(); i++) { + result.add(new ArrayList<>(leftResult.get(i))); + } + for (int i = 0; i < rightResult.size(); i++) { + result.add(new ArrayList<>(rightResult.get(i))); + } + + return result; + } + } + } + +} diff --git a/Semester 4/Assignments/Multithreading_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/multithreading_chloefontenot/FlashText.java b/Semester 4/Assignments/Multithreading_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/multithreading_chloefontenot/FlashText.java new file mode 100644 index 0000000..a574621 --- /dev/null +++ b/Semester 4/Assignments/Multithreading_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/multithreading_chloefontenot/FlashText.java @@ -0,0 +1,86 @@ +/* + * 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.chloe.multithreading_chloefontenot; + +/** + * + * @author chloe + */ +import javafx.application.Application; +import javafx.application.Platform; +import javafx.scene.Scene; +import javafx.scene.control.Label; +import javafx.scene.layout.StackPane; +import javafx.stage.Stage; + +public class FlashText extends Application +{ + private String text = ""; + @Override // Override the start method in the Application class + + public void start(Stage primaryStage) + { + StackPane pane = new StackPane(); + Label lblText = new Label("Programming is fun"); + pane.getChildren().add(lblText); + + Thread t1 = new Thread( + new Runnable() + { + public void run() + { + try + { + while (true) + { + if (lblText.getText().trim().length() == 0) + text = "Welcome"; + else + text = ""; + + + + Platform.runLater( + new Runnable() + { + @Override + public void run() + { + lblText.setText(text); + } + }); + +/* + + Thread t2 =new Thread( new Runnable() { + @Override + public void run() + { + lblText.setText(text); + } + }); + */ + Thread.sleep(300); + } + } + catch (InterruptedException ex) + { + } + } + }); + t1.start(); + + // Create a scene and place it in the stage + Scene scene = new Scene(pane, 200, 50); + primaryStage.setTitle("FlashText"); // Set the stage title + primaryStage.setScene(scene); // Place the scene in the stage + primaryStage.show(); // Display the stage + } + + public static void main(String[] args) + { + launch(args); + } +} \ No newline at end of file diff --git a/Semester 4/Assignments/Multithreading_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/multithreading_chloefontenot/PrintChar.java b/Semester 4/Assignments/Multithreading_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/multithreading_chloefontenot/PrintChar.java new file mode 100644 index 0000000..476aeb1 --- /dev/null +++ b/Semester 4/Assignments/Multithreading_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/multithreading_chloefontenot/PrintChar.java @@ -0,0 +1,59 @@ +/* + * 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.chloe.multithreading_chloefontenot; + +/** + * + * @author chloe + */ +public class PrintChar implements Runnable{ + + private char charToPrint; + private int times; + + public PrintChar(char charToPrint, int times) + { + this.charToPrint = charToPrint; + this.times = times; + } + + + @Override + public void run() + { + for (int i = 0; i < times; ++i) { + System.out.println(charToPrint); + } + } + + public static void main(String[] args) + { + for (int i = 0; i < 1000; ++i) { + System.out.println("lmao"); + } + } +} + +class PrintNum implements Runnable { + private int lastNum; + + public PrintNum(int lastNum) + { + this.lastNum = lastNum; + } + + public void run() + { + for (int i = 1; i <= lastNum; ++i) { + System.out.print(" " + i); + Thread.yield(); + if (i % 10 == 0) { + System.out.println(); + } + } + } + + +} diff --git a/Semester 4/Assignments/Multithreading_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/multithreading_chloefontenot/RunFlash.java b/Semester 4/Assignments/Multithreading_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/multithreading_chloefontenot/RunFlash.java new file mode 100644 index 0000000..72c8f64 --- /dev/null +++ b/Semester 4/Assignments/Multithreading_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/multithreading_chloefontenot/RunFlash.java @@ -0,0 +1,15 @@ +/* + * 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.chloe.multithreading_chloefontenot; + +/** + * + * @author chloe + */ +public class RunFlash { + public static void main(String[] args) { + FlashText.main(args); + } +} diff --git a/Semester 4/Assignments/Multithreading_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/multithreading_chloefontenot/Threads.java b/Semester 4/Assignments/Multithreading_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/multithreading_chloefontenot/Threads.java new file mode 100644 index 0000000..df64204 --- /dev/null +++ b/Semester 4/Assignments/Multithreading_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/multithreading_chloefontenot/Threads.java @@ -0,0 +1,29 @@ +/* + * 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.chloe.multithreading_chloefontenot; + +/** + * + * @author chloe + */ +public class Threads { + public static void main(String[] args) + { + // Create tasks + Runnable printA = new PrintChar('a', 100); + Runnable printB = new PrintChar('b', 100); + Runnable print100 = new PrintNum(100); + + // Create threads + Thread thread1 = new Thread(printA); + Thread thread2 = new Thread(printB); + Thread thread3 = new Thread(print100); + + // Start threads + thread1.start(); + thread2.start(); + thread3.start(); + } +} diff --git a/Semester 4/Assignments/Multithreading_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/multithreading_chloefontenot/forkbomb.java b/Semester 4/Assignments/Multithreading_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/multithreading_chloefontenot/forkbomb.java new file mode 100644 index 0000000..2a6af55 --- /dev/null +++ b/Semester 4/Assignments/Multithreading_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/multithreading_chloefontenot/forkbomb.java @@ -0,0 +1,20 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package edu.slcc.asdv.chloe.multithreading_chloefontenot; + +import java.io.IOException; + +/** + * + * @author chloe + */ +public class forkbomb +{ + public static void main(String[] args) throws IOException + { + Runtime.getRuntime().exec(new String[]{"java", "-cp", System.getProperty("java.class.path"), "forkbomb"}); + } +} + \ No newline at end of file diff --git a/Semester 4/Assignments/ProjectTrees_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/projecttrees_chloefontenot/ProjectTrees_CalebFontenot.java b/Semester 4/Assignments/ProjectTrees_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/projecttrees_chloefontenot/ProjectTrees_CalebFontenot.java new file mode 100644 index 0000000..998d73a --- /dev/null +++ b/Semester 4/Assignments/ProjectTrees_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/projecttrees_chloefontenot/ProjectTrees_CalebFontenot.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package edu.slcc.asdv.chloe.projecttrees_chloefontenot; + +/** + * + * @author chloe + */ +public class ProjectTrees_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 4/Assignments/ProjectTrees_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/projecttrees_chloefontenot/TreeASDV.java b/Semester 4/Assignments/ProjectTrees_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/projecttrees_chloefontenot/TreeASDV.java new file mode 100644 index 0000000..cb4dd6d --- /dev/null +++ b/Semester 4/Assignments/ProjectTrees_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/projecttrees_chloefontenot/TreeASDV.java @@ -0,0 +1,374 @@ +/* + * 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.chloe.projecttrees_chloefontenot; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.ListIterator; +import java.util.Queue; +import java.util.Stack; + +/** + * + * @author chloe + * @param + */ +public class TreeASDV implements Cloneable { + + private Node root; + + class Node { + + T data; + Node leftChild; + Node rightChild; + } + + @Override + public Object clone() + { + System.out.println("Cloning..."); + TreeASDV clone = new TreeASDV(); + ArrayList oldData = this.getBreadthFirstArray(); + for (int i = 0; i < oldData.size(); ++i) { + //System.out.println(oldData.get(i)); + clone.insert(oldData.get(i)); + } + return clone; + } + + public boolean insert(T t) + { + Node newNode = new Node<>(); + newNode.data = t; + + if (root == null) { + root = newNode; + return true; + } + + Node current = root; + Node parent = null; + + while (current != null) { + parent = current; + if (t.compareTo(current.data) >= 0) { + current = current.rightChild; + } else { + current = current.leftChild; + } + } + + // At this point, 'parent' is the node where the new node should be inserted as a child + if (t.compareTo(parent.data) >= 0) { + parent.rightChild = newNode; + } else { + parent.leftChild = newNode; + } + + return true; + } + + private void inOrder(Node p) + { + if (p == null) { + return; + } + + inOrder(p.leftChild); + System.out.print(p.data + " "); + inOrder(p.rightChild); + } + + public Node findNode(T t) + { + Node currentNode = root; + while (currentNode != null) { + if (t.compareTo(currentNode.data) == 0) { + return currentNode; + } else if (t.compareTo(currentNode.data) > 0) { + currentNode = currentNode.rightChild; + } else { + currentNode = currentNode.leftChild; + } + } + return null; + } + +public boolean remove(T t) { + // Initialize parent and current nodes for traversal + Node parent = null; + Node current = root; + + // Search for the node to be removed + while (current != null && !current.data.equals(t)) { + parent = current; + if (t.compareTo(current.data) > 0) { + current = current.rightChild; + } else { + current = current.leftChild; + } + } + + // If node not found, return false + if (current == null) { + return false; + } + + // Case 1: Node with no children + if (current.leftChild == null && current.rightChild == null) { + if (current == root) { + root = null; // Removing root node + } else if (parent.leftChild == current) { + parent.leftChild = null; // Removing a left child + } else { + parent.rightChild = null; // Removing a right child + } + } // Case 2: Node with one child + else if (current.leftChild == null || current.rightChild == null) { + Node child = (current.leftChild != null) ? current.leftChild : current.rightChild; + if (current == root) { + root = child; // Replace root with its child + } else if (parent.leftChild == current) { + parent.leftChild = child; // Replace parent's left child with the node's child + } else { + parent.rightChild = child; // Replace parent's right child with the node's child + } + } // Case 3: Node with two children + else { + Node successorParent = current; + Node successor = current.rightChild; + while (successor.leftChild != null) { + successorParent = successor; + successor = successor.leftChild; + } + current.data = successor.data; // Replace data with successor's data + if (successorParent == current) { + successorParent.rightChild = successor.rightChild; + } else { + successorParent.leftChild = successor.rightChild; + } + } + + return true; +} + + +// Helper method to find in-order successor of a node + private Node getSuccessor(Node node) + { + Node current = node.rightChild; + Node successorParent = node; + Node successor = node; + + // Find the leftmost node in the right subtree (in-order successor) + while (current != null) { + successorParent = successor; + successor = current; + current = current.leftChild; + } + + // If the successor is not the right child of the node to be removed, + // adjust the successor's parent's leftChild reference + if (successor != node.rightChild) { + successorParent.leftChild = successor.rightChild; + successor.rightChild = node.rightChild; + } + + return successor; + } + + // Inorder ListIterator + public Iterator listIterator() + { + return new InorderIterator(); + } + + private class InorderIterator implements Iterator { + + private Stack> stack; + + public InorderIterator() + { + stack = new Stack<>(); + pushLeft(root); + } + + private void pushLeft(Node node) + { + while (node != null) { + stack.push(node); + node = node.leftChild; + } + } + + @Override + public boolean hasNext() + { + return !stack.isEmpty(); + } + + @Override + public T next() + { + if (!hasNext()) { + throw new java.util.NoSuchElementException(); + } + Node current = stack.pop(); + pushLeft(current.rightChild); + return current.data; + } + + @Override + public void remove() + { + throw new UnsupportedOperationException(); + } + } + + public ArrayList getBreadthFirstArray() + { + ArrayList returnArray = new ArrayList(); + if (root == null) { + return returnArray; + } + Queue> queue = new LinkedList<>(); + + queue.offer(root); + + while (!queue.isEmpty()) { + Node current = queue.poll(); + returnArray.add(current.data); + + if (current.leftChild != null) { + queue.offer(current.leftChild); + } + if (current.rightChild != null) { + queue.offer(current.rightChild); + } + } + return returnArray; + } + + public void breadthFirstTraversal() + { + if (root == null) { + return; + } + + Queue> queue = new LinkedList<>(); + queue.offer(root); + + while (!queue.isEmpty()) { + Node current = queue.poll(); + System.out.print(current.data + " "); + + if (current.leftChild != null) { + queue.offer(current.leftChild); + } + if (current.rightChild != null) { + queue.offer(current.rightChild); + } + } + } + + @Override + public boolean equals(Object obj) { + return this.getBreadthFirstArray().equals(((TreeASDV) obj).getBreadthFirstArray()); + } + + public int height() + { + return calculateHeight(root); + } + + private int calculateHeight(Node node) + { + if (node == null) { + return 0; + } + + int leftHeight = calculateHeight(node.leftChild); + int rightHeight = calculateHeight(node.rightChild); + + return 1 + Math.max(leftHeight, rightHeight); + } + + public boolean isFullBST() + { + int height = height(); + int nodeCount = countNodes(root); + return nodeCount == (1 << height) - 1; // Formula for full binary tree + } + + private int countNodes(Node node) + { + if (node == null) { + return 0; + } + return 1 + countNodes(node.leftChild) + countNodes(node.rightChild); + } + + public void inOrder() + { + if (root == null) { + return; + } + + Stack> stack = new Stack<>(); + Node current = root; + + while (current != null || !stack.isEmpty()) { + while (current != null) { + stack.push(current); + current = current.leftChild; + } + current = stack.pop(); + System.out.print(current.data + " "); + current = current.rightChild; + } + } + + public static void main(String[] args) throws CloneNotSupportedException + { + TreeASDV tree = new TreeASDV<>(); + // Insert some elements into the tree + tree.insert(5); + tree.insert(3); + tree.insert(7); + tree.insert(2); + tree.insert(4); + tree.insert(6); + tree.insert(8); + + // Test breadth-first traversal + System.out.println("Breadth-First Traversal:"); + tree.breadthFirstTraversal(); + System.out.println(); + + // Test height calculation + System.out.println("Height of the tree: " + tree.height()); + + // Test if the tree is a full binary tree + System.out.println("Is the tree a full binary tree? " + tree.isFullBST()); + + // Test inorder traversal without recursion + System.out.println("Inorder Traversal without Recursion:"); + tree.inOrder(); + System.out.println(); + System.out.println("array list from breadth traversal"); + System.out.println(tree.getBreadthFirstArray()); + System.out.println("Cloned Tree:"); + TreeASDV clonedTree = (TreeASDV) tree.clone(); + clonedTree.breadthFirstTraversal(); + System.out.println(); + System.out.println("Does the original tree and the clone tree equal? " + (tree.equals(clonedTree) ? "yes" : "no") ); + tree.insert(3000000); + System.out.println("Does the original tree and the clone tree equal? " + (tree.equals(clonedTree) ? "yes" : "no") ); + tree.remove(5); + tree.breadthFirstTraversal(); + } +} diff --git a/Semester 4/Assignments/Threads_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/threads_chloefontenot/Threads_CalebFontenot.java b/Semester 4/Assignments/Threads_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/threads_chloefontenot/Threads_CalebFontenot.java new file mode 100644 index 0000000..3ea1dcd --- /dev/null +++ b/Semester 4/Assignments/Threads_ChloeFontenot/src/main/java/edu/slcc/asdv/chloe/threads_chloefontenot/Threads_CalebFontenot.java @@ -0,0 +1,16 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + */ + +package edu.slcc.asdv.chloe.threads_chloefontenot; + +/** + * + * @author chloe + */ +public class Threads_ChloeFontenot { + + public static void main(String[] args) { + System.out.println("Hello World!"); + } +} diff --git a/Semester 4/Assignments/Threads_ChloeFontenot/target/classes/edu/slcc/asdv/chloe/threads_chloefontenot/Threads_CalebFontenot.class b/Semester 4/Assignments/Threads_ChloeFontenot/target/classes/edu/slcc/asdv/chloe/threads_chloefontenot/Threads_CalebFontenot.class new file mode 100644 index 0000000000000000000000000000000000000000..9b85bbf645bdf5ded864a850ea1754296e1f766d GIT binary patch literal 651 zcmX^0Z`VEs1_lQPB`yXg24;2!79Ivx1~x_pfvm)`ME#t^ymWp4q^#8B5=I6#o6Nk- z5<5l)W)00SP6iGJPId+^9tLg(9u(!lmBl5gxr_|V`K2X{45B_@gEI5=1Bx>9N`gy@ zQWJBnIT-jD8F)NWb8_+(!t;xAQWUuu1Q-O_8H9Kkgc(E_8HBOuVq{=10GW}K$H*Y6 z0WlZsz~GXi%)E4K%`kQbF-8Xa)Ra>F;+*7U{lwywGX3O?ocvV%l8mC%#FXNAFfT1X zuOu}uzeGO-D(VbU;|3LFWMFa5Pf2BD;P=VQOZ6+wO-d~aNleN~Wn>WY$xlwq2}>-> z1o5GQEF~G4#f%J&J`~z(&B(x#o0yr$$RMT>jm>wA3@nL7>BWo;!dRpk8MuP;ON)|I z-7-NgmBQ*ZJy57JC^CpLFfo7t69XeCwiy^1#2FYE^cff#7#SECShcn@Fm7aEU|?d9 zU|?Wi0}FC9NHQ=m@POH@3{niz3=9mM3^EL|P|fBHAj23KI5#n{3-NAa;71q$N?8mH ad<+~6{78myGRQH=GcYhPGAMwpQUn0<_nhhg literal 0 HcmV?d00001