Skip to content

Instantly share code, notes, and snippets.

@jasongorman

jasongorman/Movie.java Secret

Created Apr 10, 2021
Embed
What would you like to do?
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