2023 Description The problem domain is that of runners doing 100 meter sprints Each runner | Assignment Collections

Computer Science 2023 Description

2023 Description The problem domain is that of runners doing 100 meter sprints Each runner | Assignment Collections

 Description

The problem domain is that of runners doing 100 meter sprints. Each runner has a lane number and runs 100 meters three times. The lane number, name of the runner, and the times are kept as instance variables of Performance class. Later, we are required to operate on an array of Performance objects read from a file.

 

You are provided a template that you should use as a starting point.

 

Your first task is to complete the Performance class such that it passes the tests in PerformanceTest. Requirements for all methods to be completed are provided as javadoc comments above the method headers.

 

The list of methods you need to complete are:

void setTimes(double[] t) (validation scenario explained as javadoc comment).

IMPORTANT NOTE: this is the most critical method of the assignment and if you don’t implement this correctly, none of the other methods will pass the tests, even if their implementations are correct.

 

parameterized constructor with values for each instance variable passed

double averageTime()

double bestTime()

boolean equals(Performance other) int

compareTo(Performance other)

 

One method we’d like to highlight is compareTo(Performance other). We’d like to compare two Performance objects p1 and p2. The comparison criteria is the average times. We CANNOT compare the two objects as, if ( p1 > p2 )

 

Hence we create a methods compareTo(Performance other that returns:

1 if average time of p1 is more than average time of p2, and thus performance p1 is more than performance p2, or p1 > p2 (informally).

-1 if average time of p1 is less than average time of p2, and thus performance p1 is less than performance p2, or p1 > p2 (informally).

0 if average time of p1 and that of p2 are equal, and thus both performances are equal, or p1 == p2 (informally).

 

We then use this method to compare p1 and p2 as follows,

if ( p1.compareTo( p2 ) == 1)     // to check p1 > p2

// or

if ( p1.compareTo( p2 ) == -1)     // to check p1 < p2

// or

if ( p1.compareTo( p2 ) == 0)     // to check p1 == p2

// or

if ( p1.compareTo( p2 ) != -1)     // to check p1 >= p2

//or

if ( p1.compareTo( p2 ) != 1)     // to check p1 <= p2

//or

if ( p1.compareTo( p2 ) != 0)     // to check p1 != p2

 

 

The compareTo method will be useful for completing the second task.

 

The second task is to complete the PerformanceArrayService class that contains the following class methods operating on array passed to them,

public static int linearSearch(Performance[] performances, String name): Returns the in-dex of the last occurrence of an athlete with the same name as the passed String name, in a case insensitive manner. Thus, if you are searching for “Anne Frank” and the name of the last athlete is “anne frank”, it should be considered a match and the index of the last athlete must be returned.

 

public static int binarySearch(Performance[] performances, double time): Assuming that the array passed to the method is sorted in ascending order, apply binary search algorithm discussed in weeks 3, 5, and 6. Return -1 if array is null. Further requirements are provided as javadoc comments above the method header.

IMPORTANT NOTE: Notice that we are reading data from sortedData.txt in the test for binary search. Therefore, you do not need to worry about implementing sort to complete binary search.

 

public static void sort(Performance[] performances): Sort the array passed in ascending order, where the order is based on compareTo method from Performance class. Do nothing if the array is null. You are free to use any algorithm you wish. You cannot use any built-in Java method to finish this task.

 

 

Advanced Task

This task constitutes for the top 16% of the assignment 2 marks and thus is fairly advanced. The problem is that instead of each athlete having a two-token name (givenName lastName), they may have names with different number of tokens. Some examples are:

 Madonna

Euclid of Alexandria

M K Gandhi

Bender Bending Rodriguez

 

Also, it’s possible that different athletes have different number of cracks at the 100 meter sprints. They may make zero or more attempts. You are required to write a file reading client, along the lines of Reader.java that reads such uneven records. A sample of such a file is provided in advancedData.txt. You will notice that the number of attempts made by each runner vary between 0 and 3 in this sample file. Note that you will need to throw FileNotFoundException from the getPerformances method. The throws declaration has already been added in the template.

 Testing

Note that we may use different test data. So do not hard-code your program to the test data provided.

 

 

 

We give our students 100% satisfaction with their assignments, which is one of the most important reasons students prefer us to other helpers. Our professional group and planners have more than ten years of rich experience. The only reason is that we have successfully helped more than 100000 students with their assignments on our inception days. Our expert group has more than 2200 professionals in different topics, and that is not all; we get more than 300 jobs every day more than 90% of the assignment get the conversion for payment.

Place Order Now

#write essay #research paper #blog writing #article writing #academic writer #reflective paper #essay pro #types of essays #write my essay #reflective essay #paper writer #essay writing service #essay writer free #essay helper #write my paper #assignment writer #write my essay for me #write an essay for me #uk essay #thesis writer #dissertation writing services #writing a research paper #academic essay #dissertation help #easy essay #do my essay #paper writing service #buy essay #essay writing help #essay service #dissertation writing #online essay writer #write my paper for me #types of essay writing #essay writing website #write my essay for free #reflective report #type my essay #thesis writing services #write paper for me #research paper writing service #essay paper #professional essay writers #write my essay online #essay help online #write my research paper #dissertation writing help #websites that write papers for you for free #write my essay for me cheap #pay someone to write my paper #pay someone to write my research paper #Essaywriting #Academicwriting #Assignmenthelp #Nursingassignment #Nursinghomework #Psychologyassignment #Physicsassignment #Philosophyassignment #Religionassignment #History #Writing #writingtips #Students #universityassignment #onlinewriting #savvyessaywriters #onlineprowriters #assignmentcollection #excelsiorwriters #writinghub #study #exclusivewritings #myassignmentgeek #expertwriters #art #transcription #grammer #college #highschool #StudentsHelpingStudents #studentshirt #StudentShoe #StudentShoes #studentshoponline #studentshopping #studentshouse #StudentShoutout #studentshowcase2017 #StudentsHub #studentsieuczy #StudentsIn #studentsinberlin #studentsinbusiness #StudentsInDubai #studentsininternational