Write a method which reverses the order of items

Assignment Help JAVA Programming
Reference no: EM131219929

As we have discussed in class, section 4.1 of our text develops a List ADT and then offers two different implementations of it in the classes AList and LList.

The ADT is defined in a Java interface file List.java, and both AList and LList implement all the required methods of this interface. As a result, either implementation can be used, and while their internal methods and means of storing data differ, both give identical behavior.

During a recent class meeting, we wrote a class that created either an AList or LList object, used a few methods such as insert and remove, and printed it out. We saw that these features all worked correctly for both AList and LList objects; our code simply called the methods defined in the List interface and they worked.

For this assignment, you will write a new class and create three methods that take one (or two) List objects and perform operations on them using only the public List methods. Here are the three methods to write:

1 Write a method static void swap (List<Integer> l) which interchanges the current element in the list and the one following it. (First make it work in the normal case; then, if you still have time, make sure it handles special cases, such as: the list is empty; the list has only one element; current is at the end of the list

2 Write a method static void reverse (List<Integer> l) which reverses the order of items stored in the list. Again, make sure it works for any special cases you can think of.

3 Write a method static List mergeLists (List<Integer> l1, List<Integer> l2) which takes two sorted Lists as input, producing a new List containing all the elements of both lists, also sorted. The new list is the return value for the method.

In your test class's main method, write a series of statements to create several AList and/or LList objects (of type <Integer>) and put some data into them by calling the List append and/or insert methods. Use the lists you build as parameters to test each of your three methods and show that they work.

Test each of your three methods with a minimum of three different test inputs. Show that your methods work for various test cases such as the examples given above. Make sure your program prints the 'before' and 'after' lists for each of your tests.

Finally, copy the output of your program to a '.txt' or '.doc' file. Don't forget to put your name at the top of the document.

Attachment:- Assignment.rar

Reference no: EM131219929

Questions Cloud

How do nations differ in hrm : How do nations differ in HRM? What are the major national context characteristics that affect IHRM?
Identify the major business and financial risks : Identify the major business and financial risks such as interest rate risk, foreign exchange risk, credit, commodity, and operational risks. How do organizations measures risk and what global initiatives exist in financial risk management?
What data integrity and security issues do you foresee : The combined practice wants to implement wireless notepads for the physicians and staff to make changes directly to a patient's records. What data integrity and security issues do you foresee?
How much was new company net income or net loss : Assume that new Towne Company reported the following summarized data at September 30, 2016. Accounts appear in no particular order; dollar amounts are in millions.  Prepare the trial balance of New Towne at September 30, 2016. List the accounts in th..
Write a method which reverses the order of items : Write a method static void reverse (List l) which reverses the order of items stored in the list. Again, make sure it works for any special cases you can think of - write a series of statements to create several AList and/or LList objects (of typ..
Function of a particular set of circumstances : Almost all business situations are both complex a unique and are a function of a particular set of circumstances and individuals in which multiple realities exist that cannot be reduced to the sum of its parts (Saunders, Lewis and Thornhill 2012)...
Accounts payable-service revenue-cash-cost of goods sold : The Marchetti Soup Company entered into the following transactions during the month of June: (1) purchased inventory on account for $180,000 (assume Marchetti uses a perpetual inventory system); T-accounts: Accounts recievable, Accounts payable, Serv..
Complete slide presentation for the board of directors : Prepare a complete slide presentation for the Board of Directors (BOD) outlining the justification for implementing an improved Accounting and Control (AC) function describing activities, applications, justification and benefits of implementing an..
Are there conflicts of interest in the given deal : Are there conflicts of interest in this deal? If yes, will they help or hurt the deal? Are there real potential synergies in this merger? Will this deal create value for the shareholders of Tesla?Is the deal rightly priced?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd