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

  Update your website to include a simple web form

Update your website to include a simple web form as discussed in your design document. Use JavaScript to validate the form contents and display the results of that validation to the user in a popup window

  1 write a recursive instance method called

1 write a recursive instance method called countconnectedpipesint row int col. the method must not contain any loops

  A listener for the click events of a button

What happens if you fail to register an object as a listener for the click events of a button?

  Write a class encapsulating the concept of student

Prepare a client class to test all the methods in your class. Make sure to add comments. Comments should be included in the program to explain your calculations and program.

  Write a computer program to automatically analyze data

For this assignment, you have been asked to write a computer program to automatically analyze some of the data collected by some experiments. Data analysis in scientific research is a complicated endeavor, so we will simplify our task by just calc..

  Question hierarchy of section

Add a class AnyCorrectChoiceQuestion to the question hierarchy of Section 9.1 that allows multiple correct choices. The respondent should provide any one of the cor- rect choices. The answer string should contain all of the correct choices, separa..

  Write a java program that plays the game of craps

Write a Java program that plays the game of Craps using the rules stated above so that it simulates a game without human input

  Create an interface called player

Create an interface called Player. The interface has an abstract method called play() that shows a message describing the meaning of "play" to the class.

  Create two separate java codes resulting in the same output

I need to create two separate Java codes resulting in the same output (one using Apache Commons library and one using the standard Java methods). The program should count all people with the same last name and then change the last name to Doe.

  Implement a fishlake simulation similar to the previous

implement a fishlake simulation similar to the previous assignment. you will then make adjustments to accommodate class

  Determine the average amount of time people spend waiting

Determine the average amount of time people spend waiting for tables -  The fancy new French restaurant La Food is very popular for its authentic cuisine

  The game of pig

Write a program that allows a single player to practice the game (that is, there will be no opponent, just a single player). Play 5 turns in the game to get a total score for the player. Refer to the sample output below for a detailed example.

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