Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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 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 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 l1, List 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 ) 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

Java, Programming

  • Category:- Java
  • Reference No.:- M91975874

Have any Question?


Related Questions in Java

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

Assignment - java program using array of objectsobjectives

Assignment - JAVA Program using array of objects Objectives - This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details - For this assignment, you are required to develop a Menu ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As