Question

Please do it in JAVA!!! Thank you. Directions below Array Reverse :Step 1. In the reverse...

Please do it in JAVA!!! Thank you. Directions below

Array Reverse :Step 1. In the reverse method of AList, implement your algorithm from the pre-lab exercises. Iteration is needed. Checkpoint: Compile and run ArrayListExtensionsTest. The checkReverse tests should pass. If not, debug and retest.

Array Cycle :Step 2. In the cycle method of AList, implement your algorithm from the pre-lab exercises. This method needs some form of iteration, but it may not be explicit. It can use the private methods of the AList class to avoid an explicit loop in the cycle method. Either way is acceptable. Checkpoint: : Compile and run ArrayListExtensionsTest. All tests should pass. If not, debug and retest.

------AList Skele--------

https://codeshare.io/GAJ4gE <---- I put Alist here cause it was too long to post

--------ArrayListExtensionsTest-------

https://codeshare.io/5Nb6jm <-------ArrayListExtensionsTest.java CODE TO RUN IT

0 0
Add a comment Improve this question Transcribed image text
Answer #1
/** Reverse the order of items in a list.
*/
public void reverse()
{
    if(initialized) {
        for (int i = 1; i <= numberOfEntries/2; i++) {
            T temp =  list[i];
            list[i] = list[numberOfEntries +1 - i];
            list[numberOfEntries +1 - i] = temp;
        }
    }
}


/** Cycle the first item to the end of the list.
*/
public void cycle()
{
    if(initialized) {
        if(numberOfEntries < 2) {
            return;
        }
        T first = list[1];
        for (int i = 1; i < numberOfEntries; i++) {
            list[i] = list[i+1];
        }
        list[numberOfEntries] = first;
    }  
}

Please upvote, as i have given the exact answer as asked in question. Still in case of any concerns in code, let me know in comments. Thanks!

Add a comment
Know the answer?
Add Answer to:
Please do it in JAVA!!! Thank you. Directions below Array Reverse :Step 1. In the reverse...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Do it in Java: Directions Linked Reverse Step 1. In the reverse method of LList, implement...

    Do it in Java: Directions Linked Reverse Step 1. In the reverse method of LList, implement your algorithm from the pre-lab exercises. Iteration is needed. Checkpoint: Compile and run LinkedListExtensionsTest. The checkReverse tests should pass. If not, debug and retest. Linked Cycle Step 2. In the cycle method of LList, implement your algorithm from the pre-lab exercises. Final checkpoint: Compile and run LinkedListExtensionsTest. All tests should pass. If not, debug and retest. -----LList Skele Code------ https://codeshare.io/5QqeOe <----LList Code -------LinkedListExtensionsTest code-----...

  • Directions: Follow the instructions below to explore sorting objects using boxes below. You will sort the...

    Directions: Follow the instructions below to explore sorting objects using boxes below. You will sort the boxes by the largest volume. Copy and Paste the Box method below into BlueJ public class Box { private double length, height, depth;    public Box( double length, double height, double depth ) { this.length = length; this.height = height; this.depth = depth; }    public double volume() { return length*height*depth; } // compare this Box to another Box int compareTo( Box other )...

  • Write a JAVA program to solve a sudoku! Given a partially filled 9×9 2D array ‘grid[9][9]’,...

    Write a JAVA program to solve a sudoku! Given a partially filled 9×9 2D array ‘grid[9][9]’, the goal is to assign digits (from 1 to 9) to the empty cells so that every row, column, and subgrid of size 3×3 contains exactly one instance of the digits from 1 to 9. I have posted 3 input files: sudoku1.txt, sudoku2.txt and sudoku3.txt Problem Analysis & Design - Think about how you will need to solve this problem. You should do an...

  • java This lab is intended to give you practice creating a class with a constructor method,...

    java This lab is intended to give you practice creating a class with a constructor method, accessor methods, mutator methods, equals method , toString method and a equals method. In this lab you need to create two separate classes, one Student class and other Lab10 class. You need to define your instance variables, accessor methods, mutator methods, constructor, toString method and equals method in Student class. You need to create objects in Lab10 class which will have your main method...

  • The language is java if you coukd shiwnstep by step on how to get each section

    the language is java if you coukd shiwnstep by step on how to get each section ebapps/blackboard/execute/content/file?cmd-view&content jid _975287 1&course id:_693311 Lab 3 Directions (linked lists) Program #1 1. Show PolynomialADT interface 2. Create the PolyNodeClass with the following methods: default constructor, . overloaded constructor, copy constructor, setCoefficient, setExponent, setNext, getCoefficient, getExponent, getNext 3. Create the PolynomialDataStrucClass with the following methods: defaut constructor, overloaded constructor, copy constructor, isEmpty. setFirstNode. getfirstNode,addPolyNodeFirst (PolyNode is created and set to the end of polynomial),...

  • Copy the following java codes and compile //// HighArray.java //// HighArrayApp.java Study carefully the design and...

    Copy the following java codes and compile //// HighArray.java //// HighArrayApp.java Study carefully the design and implementation HighArray class and note the attributes and its methods.    Create findAll method which uses linear search algorithm to return all number of occurrences of specified element. /** * find an element from array and returns all number of occurrences of the specified element, returns 0 if the element does not exit. * * @param foundElement   Element to be found */ int findAll(int...

  • For this lab you will write a Java program that plays the dice game High-Low. In...

    For this lab you will write a Java program that plays the dice game High-Low. In this game a player places a bet on whether the sum of two dice will come up High (totaling 8 or higher), Low (totaling 6 or less) or Sevens (totaling exactly 7). If the player wins, they receive a payout based on the schedule given in the table below: Choice Payout ------ ------ High 1 x Wager Low 1 x Wager Sevens 4 x...

  • Lab 6 Instructions Objectives: • Executing and experimenting with programs that handle array related topics such...

    Lab 6 Instructions Objectives: • Executing and experimenting with programs that handle array related topics such as declaration, initialization, storing, retrieving, and processing elements. • Effectively manipulating and using ArrayList objects. • Becoming familiar with the use of arrays as method arguments and how array elements are passed to and returned from the called method. • Mastering the use of various debugging tools available on the Eclipse IDU. Important: EVERY one of the following Activities MUST be in a separate...

  • Java Program Note: no break statements or switch staements High, Low, Sevens For this lab you...

    Java Program Note: no break statements or switch staements High, Low, Sevens For this lab you will write a Java program that plays the dice game High-Low. In this game a player places a bet on whether the sum of two dice will come up High (totaling 8 or higher), Low (totaling 6 or less) or Sevens (totaling exactly 7). If the player wins, they receive a payout based on the schedule given in the table below: Choice Payout ------...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT