Skip to content

Instantly share code, notes, and snippets.

@jasongorman
Created April 10, 2021 07:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasongorman/c7828930f8afda97c34bf14db3afb431 to your computer and use it in GitHub Desktop.
Save jasongorman/c7828930f8afda97c34bf14db3afb431 to your computer and use it in GitHub Desktop.
public class Movie {
private final String title;
private int availableCopies = 1;
private List<Member> onLoanTo = new ArrayList<>();
public Movie(String title){
this.title = title;
}
public void borrowCopy(Member member){
availableCopies -= 1;
onLoanTo.add(member);
}
public void returnCopy(Member member){
availableCopies++;
onLoanTo.remove(member);
}
public String getTitle() {
return title;
}
public int getAvailableCopies() {
return availableCopies;
}
public Boolean isOnLoanTo(Member member) {
return onLoanTo.contains(member);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment