Programming Homework Help

Programming Homework Help. convert arraylist to array

Remember to use the array’s length and the currentSize attribute that you keep track of.

Requirements:

  • Identify the index of the element to remove
  • Remove it by moving all the elements below it up by 1
  • Move nulls to the last element moved up
  • Adjust currentSize

Tips for Remove from an array:

  • Call int I = searchMethod
  • If searchMethod returns a -1, tell user “Not Found”
  • Else
  • Loop: for I = searchIndex; I < currentSize
    ; i++
  • Move nulls to myArray[currentSize – 1]
  • currentSize –

myArray[i] = myArray[i+1];

After the loop is over:

Add logic

  • ask user for the data & store in variables
  • Create a new BFF object
  • If currentSize < array length

Add BFF object to array at currentSize
myArray[currentSize] = myBFFObj;
currentSize++
4.)else

Double array size and move everything into new temp array using a LOOP
originalArray = tempArray;

Add BFF object to array at currentSize
currentSize++

Int[] myAges = new int[10];

BestFriend[] myBFFs;

In constructor of Helper:

myBFFs = new BestFriend[5];

currentSize = 0;

code to change:

public void removeFriend(){

String first;

String last;

String nickName;

System.out.println(“Enter first name you wish to remove”);

first = keyboard.nextLine();

System.out.println(“Enter last name you wish to remove”);

last = keyboard.nextLine();

System.out.println(“Enter nickname you wish to remove”);

nickName = keyboard.nextLine();

BestFriend removeBFF = new BestFriend(first, last, nickName);

if (myBffs.contains(removeBFF))

{

myBffs.remove(0); // gets the index of object that user wants to remove

System.out.println(“Friend was succesfully removed!”);

}

else if (!myBffs.contains(removeBFF))

{

System.out.println(“Friend does not exist”);

}

}

Programming Homework Help

 
"Our Prices Start at $11.99. As Our First Client, Use Coupon Code GET15 to claim 15% Discount This Month!!"