Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement this method / * * Purpose: get the number of times a new highest score * in the list of competitors is found *

Implement this method /*
* Purpose: get the number of times a new highest score
* in the list of competitors is found
* Parameters: List cList - the list of competitors
* Returns: int - the number times a new highest score is
* found when traversing from left to right
* through the list of competitors
*
*/
public static int numberTimesRecordBroken(List cList){ These are the tests public static void testNumberTimesRecordBroken(){
System.out.println("
Testing numberTimesRecordBroken...");
Competitor c1= new Competitor("Ali",37); // new record
Competitor c2= new Competitor("Sam",18);
Competitor c3= new Competitor("Lee",49); // new record
Competitor c4= new Competitor("Jo",53); // new record
Competitor c5= new Competitor("Dani",41);
Competitor c6= new Competitor("Zee",52);
Competitor c7= new Competitor("Ola",75); // new record
Competitor c8= new Competitor("Mary",24);
Competitor c9= new Competitor("Theo",72);
Competitor c10= new Competitor("Ali",91); // new record
Competitor c11= new Competitor("Tay",80);
Competitor c12= new Competitor("Luis",88);
Competitor[] arr1={c1};
Competitor[] arr2={c1, c4, c3, c2};
Competitor[] arr3={c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12};
List list1= new ArrayList(arr1);
List list2= new ArrayList(arr2);
List list3= new ArrayList(arr3);
int result =0;
int expected =0;
result = A4Exercises.numberTimesRecordBroken(list1);
expected =1;
displayResults(result==expected, "numberTimesRecordBroken(list1)");
result = A4Exercises.numberTimesRecordBroken(list2);
expected =2;
displayResults(result==expected, "numberTimesRecordBroken(list2)");
result = A4Exercises.numberTimesRecordBroken(list3);
expected =5;
displayResults(result==expected, "numberTimesRecordBroken(list3)");

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions