@Test public void testUser() { User u = new User(NAME, FIRSTNAME); assertNotNull("u should not be null", u); String n = u.getName(); String f = u.getFirstName(); assertEquals(NAME, n); assertEquals(FIRSTNAME, f); List<Rental> rentals = u.getRentals(); assertNotNull("rentals list should be empty, not null", rentals); assertEquals(0, rentals.size()); }
public User(String aName, String aFirstName) { if (aName != null) { if ((aName.length() == 0) || (aName.length() > 40)) { throw new MovieRentalException("invalid name value"); } } else { throw new NullPointerException("invalid name value"); } checkIfFirstNameValid(aFirstName); this.name = aName; this.firstName = aFirstName; }
User implements IUser { public User(String aName, String aFirstName) { if (aName != null) { if ((aName.length() == 0) || (aName.length() > 40)) { throw new MovieRentalException("invalid name value"); } } else { throw new NullPointerException("invalid name value"); } checkIfFirstNameValid(aFirstName); this.name = aName; this.firstName = aFirstName; } }
User implements IUser { public User(String aName, String aFirstName) { if (aName != null) { if ((aName.length() == 0) || (aName.length() > 40)) { throw new MovieRentalException("invalid name value"); } } else { throw new NullPointerException("invalid name value"); } checkIfFirstNameValid(aFirstName); this.name = aName; this.firstName = aFirstName; } User(String aName, String aFirstName); }
User implements IUser { public User(String aName, String aFirstName) { if (aName != null) { if ((aName.length() == 0) || (aName.length() > 40)) { throw new MovieRentalException("invalid name value"); } } else { throw new NullPointerException("invalid name value"); } checkIfFirstNameValid(aFirstName); this.name = aName; this.firstName = aFirstName; } User(String aName, String aFirstName); int getId(); void setId(int anID); List<Rental> getRentals(); void setRentals(List<Rental> someRentals); String getName(); void setName(String aName); String getFirstName(); void setFirstName(String aFirstName); Calendar getBirthdate(); double getCharge(); @Override boolean equals(Object o); @Override int hashCode(); boolean hasRentals(); int addRental(Rental rental); }
User implements IUser { public User(String aName, String aFirstName) { if (aName != null) { if ((aName.length() == 0) || (aName.length() > 40)) { throw new MovieRentalException("invalid name value"); } } else { throw new NullPointerException("invalid name value"); } checkIfFirstNameValid(aFirstName); this.name = aName; this.firstName = aFirstName; } User(String aName, String aFirstName); int getId(); void setId(int anID); List<Rental> getRentals(); void setRentals(List<Rental> someRentals); String getName(); void setName(String aName); String getFirstName(); void setFirstName(String aFirstName); Calendar getBirthdate(); double getCharge(); @Override boolean equals(Object o); @Override int hashCode(); boolean hasRentals(); int addRental(Rental rental);  }