### Question:
Movie { @Override public int hashCode() { final int prime = 31; int result = prime + id; result = prime * result + ((releaseDate == null) ? 0 : releaseDate.hashCode()); result = prime * result + ((title == null) ? 0 : title.hashCode()); return result; } protected  Movie();  Movie(String aTitle, PriceCategory aPriceCategory);  Movie(String aTitle, Date aReleaseDate, PriceCategory aPriceCategory); PriceCategory getPriceCategory(); void setPriceCategory(PriceCategory aPriceCategory); String getTitle(); void setTitle(String aTitle); Date getReleaseDate(); void setReleaseDate(Date aReleaseDate); boolean isRented(); void setRented(boolean isRented); int getId(); void setId(int anId); @Override int hashCode(); @Override boolean equals(Object obj);  }### Answer:
@Test public void testHashCode() throws InterruptedException { Date d = new Date(Calendar.getInstance().getTimeInMillis()); PriceCategory pc = RegularPriceCategory.getInstance(); Movie x = new Movie(); Movie y = new Movie("A", d, pc); Movie z = new Movie("A", d, pc); int h = x.hashCode(); assertEquals(h, x.hashCode()); h = y.hashCode(); assertEquals(h, y.hashCode()); h = y.hashCode(); assertEquals(h, z.hashCode()); z.setRented(true); assertEquals(h, z.hashCode()); z = new Movie("A", d, pc); z.setPriceCategory(ChildrenPriceCategory.getInstance()); assertEquals(h, z.hashCode()); z = new Movie("B", d, pc); assertFalse(h == z.hashCode()); Thread.sleep(10); z = new Movie("A", new Date(Calendar.getInstance().getTimeInMillis()), pc); assertFalse(h == z.hashCode()); z = new Movie("A", d, pc); z.setId(42); assertFalse(h == z.hashCode()); }