// Arup Guha
// 2/18/2026
// Used in larger example showing HAS-A relationship.

import java.util.*;

public class Book {

	// Instance variables.
	private String title;
	private int numPages;
	private int pagesRead;
	private int year;
	
	// Creates a new Book object with title myTitle, myNumPages number of
	// pages which was published in myYear. None of it has been read.
	public Book(String myTitle, int myNumPages, int myYear) {
		title = myTitle;
		numPages = myNumPages;
		pagesRead = 0;
		year = myYear;
	}
	
	// Returns a string representation of this Book.
	public String toString() {
		return title+" "+year+" Pages "+numPages+" read so far "+pagesRead;
	}
	
	// Returns the number of pages left in this Book to read.
	public int pagesLeft() {
	
		// Note: this. is optional here.
		return this.numPages - this.pagesRead;
	}
	
	// Returns the number of pages read this time.
	public int read(int amtRead) {
		
		// This is what we'll return.
		int retVal = Math.min(amtRead, pagesLeft());
		
		// Read it!
		pagesRead += retVal;
		
		// Return how many we read.
		return retVal;
	}
	
}