Solution to be fixed import javautil class Show public Str

Solution to be fixed -

import java.util.*;

class Show {
public String title;

public Show(String title) {
this.title = title;
}
  
public int hashCode() {
return title.hashCode();
}
public boolean equals(Object other) {
(other instanceof Show) && this.title == ((Show) other).title;
}
}
  
class Shows {
public static Show findOldestLeastAired(Show[] shows) {
// code goes here
}
}

Test Fixtures-

import org.junit.Test;
import static org.junit.Assert.*;
import java.util.Arrays;

// Feel free to add your own test cases
public class ShowsTests {
@Test
public void testReturnsOldestLeastAired() {
Show a = new Show(\"a\");
Show b = new Show(\"b\");
Show c = new Show(\"c\");
Show a_rerun = new Show(\"a\");
assertEquals(b, Shows.findOldestLeastAired(new Show[] { a,b,c,a_rerun }));
}
  
@Test
public void testRerunSameNumberTimes() {
Show a = new Show(\"a\");
Show b = new Show(\"b\");
Show b_rerun = new Show(\"b\");
Show a_rerun = new Show(\"a\");
assertEquals(new Show(\"b\"), Shows.findOldestLeastAired(new Show[] { a,b,b_rerun,a_rerun }));
}
  
@Test
public void testNoShows() {
assertEquals(null, Shows.findOldestLeastAired(new Show[] {}));
}
}

Instructions -

Unfortunately due to the tiny budget, the station hasn\'t been able to buy new content in ages and your previous function has been run a ridiculous number of times. So many that they\'ve now re-aired every show in the catalog. Write a function that takes the same previous list of shows and returns the show that has been aired the fewest times. If multiple shows have been aired the same minimal number of times, we want the show where the MOST RECENT AIRING WAS THE LONGEST TIME AGO.

Solution

1.a,b,c hassh code is return and its instance

2.a,b hash code return and check old instances

3.

Solution to be fixed - import java.util.*; class Show { public String title; public Show(String title) { this.title = title; } public int hashCode() { return ti
Solution to be fixed - import java.util.*; class Show { public String title; public Show(String title) { this.title = title; } public int hashCode() { return ti

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site