Time limeliace ispeaker below is already compiled and given in byte code tomat, mus you can use IL
import java.util.List;
public interface ISpeaker {
public int f1(List<Speaker> t);
public void f2(List<Speaker> t);
public void f3(List<Speaker> t);
}
Write a class MySpeaker, which implements the interface ISpeaker. The class MySpeaker implements methods f1, f2 and f3 in ISpeaker as below (you can add other functions in MySpeaker class):
f1: Count and return the number of speakers with power > 10.
f2: Sort the first 5 elements in the list ascendingly (other elements are unchanged).
f3: Check if in the list there are at least 2 elements having minimum power then remove the second one (thus if only one element with minimum power then do nothing).
When running, the program will add some data to the list. Sample output might look something like:
Add how many elements: 0
Add how many elements: 0
Enter TC(1-f1;2-f2;3-f3): 1
Enter TC(1-fl;2-f2;3-f3): 2
The list before running f2:
(A,6) (B,9) (C,2) (D,29) (E,22) (F,19) (G,12) (H,5)
The list before running f1:
OUTPUT:(C,2) (A,6) (B,9) (E,22) (D,29) (F,19) (G,12) (H,5)
Zoom
+ 100%
Close