Skip to content

Commit

Permalink
final
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim L authored and Tim L committed Jul 8, 2024
1 parent 1487d07 commit e912562
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class ArrayUtils {
*/
public static Integer getNumberOfOccurrences(Object[] objectArray, Object objectToCount) {
int numOfOcc = 0;
for (int i = 0; i < objectArray.length; i++){
if (objectToCount == objectArray[i]){
for (int i = 0; i < objectArray.length; i++) {
if (objectToCount == objectArray[i]) {
numOfOcc++;
}
}
Expand Down Expand Up @@ -83,19 +83,17 @@ public static Object getLeastCommon(Object[] objectArray) {
* given two arrays `objectArray` and `objectArrayToAdd`, return an array containing all elements in `objectArray` and `objectArrayToAdd`
*/
public static Object[] mergeArrays(Object[] objectArray, Object[] objectArrayToAdd) {
List list = new ArrayList<>(Arrays.asList(objectArray));
list.addAll(Arrays.asList(objectArrayToAdd));
Object[] c = list.toArray();
return c;
// Object[] thirdArray = new Object[objectArray.length + objectArrayToAdd.length];
// int index = objectArray.length;
//
// for (int i = 0; i < objectArray.length; i++){
// thirdArray[i] = objectArray[i];
// }
// for (int i = 0; i < objectArrayToAdd.length; i++){
// thirdArray[i + index] = objectArrayToAdd[i];
// }
// return null;
Object[] newArray = new Object[objectArray.length + objectArrayToAdd.length];
int i = 0;

for (Object each : objectArray) {
newArray[i++] = each;
}
for (Object each : objectArrayToAdd) {
newArray[i++] = each;
}

return null;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,7 @@ public class MultiplesDeleter {
* given an array of integers, named `ints` return an identical array with evens removed
*/
public Integer[] deleteEvens(Integer[] ints) {
// int a = 0;
// for(int i = 0; i < ints.length; i++){
// if (ints[i] % 2 != 0){
// a++;
// }
// }
// int[] result = new int[a];
// int count = 0;
// for (int i = 0; i < ints.length; i++){
// if (ints[i] % 2 != 0){
// result[count] = ints[i];
// count++;
// }
// }
// return result;

return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public PetOwner(String name, Pet... pets) {
* @param pet pet to be added to the composite collection of Pets
*/
public void addPet(Pet pet) {
Cat cat = new Cat("Jim", 2);
Dog dog = new Dog("George", 1);

}

Expand Down Expand Up @@ -69,6 +71,7 @@ public Integer getNumberOfPets() {
* @return the name property of the Pet
*/
public String getName() {

return null;
}

Expand Down

0 comments on commit e912562

Please sign in to comment.