This lab is to test your understanding of a Pairs project and sorting method discussed during...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
This lab is to test your understanding of a Pairs project and sorting method discussed during last week's lectures. The sorting method from the lectures used an array with a type parameter. Given the following Pairable Interface, ComparablePair class, and Tester class, implement a sort method in the Test class that sorts ComparablePair objects. public interface Pairable { public T get First (); public T getSecond(); } public class ComparablePair implements Pairable , Comparable { private T first; private T second; public ComparablePair (T firstItem, T secondItem) { first firstItem; second secondItem; } @Override public T getFirst () { return first; } @Override public T get Second () { return second; } @Override public String toString () { return "(" + first + ", } + second + ")"; @Override public int compareTo (ComparablePair 0) { int first Comparison = this.getFirst().compareTo (o.getFirst()); int secondComparison = this.getSecond ().compareTo (o.getSecond ()); return first Comparison != 0 ? first Comparison secondComparison; import java.util.ArrayList; public class Tester { public static void main (String[] args) { ArrayList listOfStringPairs = new ArrayList (); listOfStringPairs.add (new ComparablePair ("Irene Johnson", "Sandra James")); listOfStringPairs.add(new ComparablePair ("Janet Brown", "Jose Richardson")); listOfString Pairs.add(new ComparablePair ("Norma Powell", "Russell Ramirez")); listofString Pairs.add(new ComparablePair ("Walter Bell", "Kelly Phillips")); listOfStringPairs.add(new ComparablePair ("Norma Powell", "Joe White")); sort (listOfStringPairs); for (ComparablePair stringPair listOfString Pairs) { System.out.println (stringPair); } } // Implement a sort method. public static void sort ( // Your code here. } ) { This lab is to test your understanding of a Pairs project and sorting method discussed during last week's lectures. The sorting method from the lectures used an array with a type parameter. Given the following Pairable Interface, ComparablePair class, and Tester class, implement a sort method in the Test class that sorts ComparablePair objects. public interface Pairable { public T get First (); public T getSecond(); } public class ComparablePair implements Pairable , Comparable { private T first; private T second; public ComparablePair (T firstItem, T secondItem) { first firstItem; second secondItem; } @Override public T getFirst () { return first; } @Override public T get Second () { return second; } @Override public String toString () { return "(" + first + ", } + second + ")"; @Override public int compareTo (ComparablePair 0) { int first Comparison = this.getFirst().compareTo (o.getFirst()); int secondComparison = this.getSecond ().compareTo (o.getSecond ()); return first Comparison != 0 ? first Comparison secondComparison; import java.util.ArrayList; public class Tester { public static void main (String[] args) { ArrayList listOfStringPairs = new ArrayList (); listOfStringPairs.add (new ComparablePair ("Irene Johnson", "Sandra James")); listOfStringPairs.add(new ComparablePair ("Janet Brown", "Jose Richardson")); listOfString Pairs.add(new ComparablePair ("Norma Powell", "Russell Ramirez")); listofString Pairs.add(new ComparablePair ("Walter Bell", "Kelly Phillips")); listOfStringPairs.add(new ComparablePair ("Norma Powell", "Joe White")); sort (listOfStringPairs); for (ComparablePair stringPair listOfString Pairs) { System.out.println (stringPair); } } // Implement a sort method. public static void sort ( // Your code here. } ) {
Expert Answer:
Answer rating: 100% (QA)
The correct answer option is to implement the sort method in the Tester class that sorts the Compara... View the full answer
Related Book For
Concepts in Enterprise Resource Planning
ISBN: 978-1111820398
4th edition
Authors: Ellen Monk, Bret Wagner
Posted Date:
Students also viewed these operating system questions
-
Would you make any changes to the Federal tax policy related to this area of the IRC ? If so , what would you change and why? How would these changes help rectify the disparate outcomes by race?
-
31. A review of Byte's job worksheets show thal tlele ait ulo for the period of June 28-30 32. The expense for depreciation follows: Building - $245.00 Computer Equipment- $3,050.00 Office Equipment-...
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
The acquisition committee of KE plc is considering making takeover bids for two competitors, Scot plc, a listed company, and Ring Ltd. Summarised financial data is given below for these companies....
-
Distinguish between FHA and conventional mortgages.
-
Reconsider the previous exercise on the Stroop effect. a. There was one point in the scatterplot that was a clear outlier. One of the researchers great aunt, who was 87 years old, took 100.60 seconds...
-
Compute budgeted factory-overhead rates and apply them to production, using appropriate cost drivers.
-
Write the audit approach section like the cases in the chapter. Hide the Loss under the Goodwill Gulwest Industries, a public company, decided to discontinue its unprofitable line of business of...
-
The image is an example of which type(s) of symmetry? A. Both rotational and reflectional B. Reflectional C. Neither rotational nor reflectional D. Rotational
-
A swim club has the following daily attendance records for 13 weeks from the previous summer (see table); it thinks the figures would provide accurate estimates for the upcoming summer. Develop a...
-
What information should the auditor include in a notification of parties other than the client about the postaudit discovery of facts when he or she has been (a) able (b) unable to make a...
-
Are 3D-printed products as good as those manufactured traditionally?
-
a. Indicate the form and timing of the auditor's communication with the audit committee on the conduct of the audit, b. What matters should be included in the communication?
-
If you had an old machine for which there were no longer any repair parts being made, how would you go about using a 3D printer to solve that problem?
-
What are the effects on a report on reportable conditions when the auditor separately identifies and describes material weaknesses?
-
calkaelea inc. has no debt outstanding and a total market value of 81,000 earnings before interest and taxes , EBIT are projected to be 9,800 if economic conditions are normal. if there is strong...
-
The text defined intrinsic value as the value of an asset given a hypothetically complete understanding of the assets investment characteristics. Discuss why hypothetically is included in the...
-
Suppose you are a manager of Fitters Accounting and Finance department. What human resources information do you think you would need to effectively manage your Accounting and Finance employees?
-
Using the Internet, research your states regulations for employing teenagers - such as minimum age of employment. Do the same for a neighboring state. Are the two state regulations the same? Why...
-
What are potential sources of risk in Fitters supply chain? How should Fitter prepare to minimize these risks? Research this topic on the Internet, and use examples to support your reasoning.
-
Study the format of the analysis of variances in Exhibit 12-12. Suppose production is 156,000 units. Also assume the following: Other data are as shown in Exhibit 12-12. Prepare an analysis of...
-
The following questions are based on the data contained in Exhibit 12-9. 1. Suppose actual production and sales were 8,000 units instead of 7,000 units. (a) Compute the sales-volume variance. Is the...
-
Belfair Kayak Company makes molded plastic kayaks. Standards costs for an entry-level whitewater kayak are: Direct materials, 60 kilograms @ $5.50 per kilogram Direct labour, 1.5 hours $16 per hour...
Study smarter with the SolutionInn App