Вы находитесь на странице: 1из 2

The one where we learn about lists and testing.

1) Describe some jUnit tests youd write for Song.getStatistics() from the first project. Just as a reminder heres the specifications for it:

getStatistics
public double[] getStatistics()

Calculates basic statistics about this current song and returns it in an array of integers. The order of the calculations should be: 1. Average number of plays on each station that carries it, 0 if song is never played 2. Total number of plays across all stations 3. Station that plays this specific song most often, -1 if the song is played the same number of times across all stations 4. Maximum number of plays on one station 5. Station that plays this specific song the least -1 if the song is played the same number of times across all stations 6. Minimum number of plays on any one station If the song is never played, the average in (0) should be set to 0. For all calculations except for the average, we can count stations that do not carry this song. That is the maximum and minimum number of plays can be 0. If multiple stations play this song the same number of times, use the station with the lowest station id for (2) and (4). If no stations play this song, (2) and (4) should be set to -1 since our station ids are zero-based. Returns: An array of basic song statistics

2) Write a method that deletes the smallest element of a Linked List of integers

3) What do I do?
public static int mystery(Node start){ int c = 0; int j = 1; Node i = start; while(i.next != null){ if(( j+2) >= 3 && (j + 2) % 3 == 0){ c += i.val; i.next = i.next.next; } j++; i = i.next; } return c; }

Write junit tests for me that show where I break.

Вам также может понравиться