Diablo Valley College Static Generic Method Java Project

P18.1 Write a static generic method PairUtil.minmax that computes the minimum and maximum elements of an array of type T and returns a pair containing the minimum and maximum value. Require that the array elements implement the Measurable interface.

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

public interface Measurable{ /** Computes the measure of the object. @return the measure */ double getMeasure();}

In class P18_1, test your method by providing an Array of Measurable elements and returning a

Pair containing min and max values.

Example:

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

Measurable (3)Measurable (5.5)Measurable (99.0)Measurable (1)

Output:

(1.0, 99.0)

P18.4 Make the Measurable interface into a generic class. Provide a static method that returns the largest element of an ArrayList, provided that the elements are instances of Measurable. Be sure to return a value of type T.

In class P18_4, supply a test case by instantiating Measurable elements, add them to an

ArrayList and return the largest element.

Example:Measurable (3)Measurable (6)Measurable (9)Output:Largest Element: 9

E22.7 Write a program WordCount that counts the words in one or more files. Start a new thread for each file. Also, the last active thread also prints a combined count. Use locks to protect the combined word count and a counter of active threads.For example, if you call

➢ java WordCount report.txt address.txt Homework.java

then the program might print

address.txt: 1052Homework.java: 445report.txt: 2099Combined Count: 3596

Still stressed from student homework?
Get quality assistance from academic writers!

Order your essay today and save 25% with the discount code LAVENDER