[solved]-Need Help Lab Uses Generics Java Three Steps Lab Step One Generic Findmax Implementation C Q39080112
I need help with a lab that uses generics in Java. There arethree steps of the lab:
STEP ONE: Generic findMax implementation
Consider the code, below, that calculates the maximum value inan array of integers. Implement a single method that will allow theuser to find the maximum value of an array of Integers, Doubles,and other Numbers. Name your method findMaxLab08Step01 and show itsuse in your driver/main method over different data types.
![SAMPLE DEMONSTRATION CODE: -- - - - - - - - - — —- - - - - - public static Integer findMax (int[] inputArray) { i int maxV =](https://media.cheggcdn.com/media/b28/s1024x298/b2804c49-495d-4c61-b588-e8ae42097525/phpEXW09M.png)
STEP TWO: Implementing Comperable
Create a method called findMaxLab08Step02() that will find themaximum of any array of Comperable objects. In your driver class,show that your method works on at least two different types ofComperable objects including an example that uses type Integer andan example that uses a non-Number Comparable object that youdefine/create yourself.
STEP THREE: Implementing Sequence Data Type
Implement and create code that demonstrates/tests the Sequenceclass. The Sequence class will support the creation of a genericsequence of items. The items can be of any data type. A sequence isa simple object that allows a user to add items to the end of thesequence and retrieve an item or a subsequence of items. Yourconcrete implementation must use an array as the underlying datatype, not an ArrayList or other pre-generated library solution. Youmay not use any API constructs that perform the functionality ofSequence.



Thanks for any help and a correct answer will get a thumbsup!
SAMPLE DEMONSTRATION CODE: — – – – – – – – – — —- – – – – – public static Integer findMax (int[] inputArray) { i int maxV = inputArray[ 0] ; for (int element : inputArray) { if (element > maxV) { maxV = element; } // end-if } // end-for return maxV; // end-method L – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – — — — — — — — — — —- The minimum set of public operations for a Sequence includes: (You are permitted to add helper methods as needed) ———————————————- 1+Sequence (int capacity) // Constructs a sequence with a fixed maximum size (capacity) +void add (Item item) // Adds item to the end of the sequence. Generates a // RuntimeException if called on a full Sequence. +Item get (int pos) // Retrieve an item at position pos. +Sequence get Sequence (int pos, int len) // Retrieve a portion of a sequence // beginning at position pos for a length of len. L – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – —————- — — — — —- ————- — – +int getCount(); // Returns the count of items in the sequence +int getCapacity(); // Returns the capacity of the sequence i+boolean equals (Sequence seq); // Returns true if this sequence and seq is // the same size and contain the same items in // the same order. +Item findMax (); // Returns the largest item in Item[ ] i+void print(); // Prints [itemi, item2, …, itemn] 11 Add other private methods as needed. L – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – SAMPLE DEMONSTRATION/DRIVER CODE: TON/DRIVER CODE:_——————– Sequence<String> sl = new Sequence (10); // One example of many… sl.add(“a”); sl.add(“c”); isl.add(“b”); s1.add(“s”); s1.add(“a”): s1.add(“”); s1.add(“b”); // Sequence sl contains the strings “a”, “c”, “b”, “s”, “a”, “c”, “b” String item = sl.get (3); Sequence<String> s2 = sl.getSequence (4,3); Sequence<String> s3 = $1.getSequence (0,3); Sequence<String> s4 = 1.getSequence (1,3); System.out.println( s2.equals(S3)); System.out.println( sl.equals (2) ); s2.print(); // returns “S” // returns “a”, “c”, “b” // returns “a”, “c”, “b” // returns “c”, “b”, “S” // displays true // displays false // prints [a, c, b ] Show transcribed image text SAMPLE DEMONSTRATION CODE: — – – – – – – – – — —- – – – – – public static Integer findMax (int[] inputArray) { i int maxV = inputArray[ 0] ; for (int element : inputArray) { if (element > maxV) { maxV = element; } // end-if } // end-for return maxV; // end-method L – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – — — — — — — — — — —-
The minimum set of public operations for a Sequence includes: (You are permitted to add helper methods as needed) ———————————————- 1+Sequence (int capacity) // Constructs a sequence with a fixed maximum size (capacity) +void add (Item item) // Adds item to the end of the sequence. Generates a // RuntimeException if called on a full Sequence. +Item get (int pos) // Retrieve an item at position pos. +Sequence get Sequence (int pos, int len) // Retrieve a portion of a sequence // beginning at position pos for a length of len. L – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
—————- — — — — —- ————- — – +int getCount(); // Returns the count of items in the sequence +int getCapacity(); // Returns the capacity of the sequence i+boolean equals (Sequence seq); // Returns true if this sequence and seq is // the same size and contain the same items in // the same order. +Item findMax (); // Returns the largest item in Item[ ] i+void print(); // Prints [itemi, item2, …, itemn] 11 Add other private methods as needed. L – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – – –
SAMPLE DEMONSTRATION/DRIVER CODE: TON/DRIVER CODE:_——————– Sequence sl = new Sequence (10); // One example of many… sl.add(“a”); sl.add(“c”); isl.add(“b”); s1.add(“s”); s1.add(“a”): s1.add(“”); s1.add(“b”); // Sequence sl contains the strings “a”, “c”, “b”, “s”, “a”, “c”, “b” String item = sl.get (3); Sequence s2 = sl.getSequence (4,3); Sequence s3 = $1.getSequence (0,3); Sequence s4 = 1.getSequence (1,3); System.out.println( s2.equals(S3)); System.out.println( sl.equals (2) ); s2.print(); // returns “S” // returns “a”, “c”, “b” // returns “a”, “c”, “b” // returns “c”, “b”, “S” // displays true // displays false // prints [a, c, b ]
Expert Answer
Answer to I need help with a lab that uses generics in Java. There are three steps of the lab: STEP ONE: Generic findMax implement… . . .
OR

