//Name: Maryam shaheen //ID: 1140427 //Comp231 Assignment#2 import java.util.*;//importing everything in java public class Library {// the beginning of the Movie Class ArrayList movies = new ArrayList(); //defining an ArrayList not an array because the question didn't give us the size of the array public Library() {// an no-argument constructor for the Library Class }// the end of the constructor public void addMovie(Movie m) {// a method that adds a movie m to the array of Movies movies.add(m);// adding m }// the end of the method public void borrowMovie(int m) {// a method to borrow a movie if (movies.get(m).available) {// if statement checks weather the movie selected is available or not System.out.println("The movie number "+m+" is borrowed");// if yes prints that the movie is borrowed movies.get(m).available = false;//changes the value of available to false because the movie is borrowed now } // the end of the if statement else if (movies.get(m).available == false)// if not available then System.out.println("The movie number "+m+" is not avaliable"); //print statement says that the movie is not available so it can't be borrowed }// the end of the method public void returnMovie(int m) {// a method to return the movie movies.get(m).available = true;// changes the value of available to true because the movie returned now }// the end of the method public void printAvailableMovies() {// a method to print available Movies in the array of Movies for (int i = 0; i < movies.size(); i++) {// for loop for checking the array if (movies.get(i).available) {// if statement that checks if the movie in is available in a specific index System.out.println("movie number "+(i+1)+":"); System.out.println(movies.get(i).toString());// if the movie is available then print the movie } // the end of the if statement } // the end of the for loop }// the end of the method }// the end of the Library Class