A public library keeps track of the books that it owns. Each book has a title, an author, a year of publication, and a number of times it has been borrowed.
You will design several classes to help manage the books in the library. You may assume that no two books have the exact same title and author combination.
Book
ClassborrowBook()
method that increments timesBorrowedtoString()
returns: "Title by Author (Year), Borrowed X times"Library
ClassArrayList<Book>
collectionaddBook(Book b)
adds a bookgetMostBorrowed()
returns book with highest borrow countfindBooksByAuthor(String author)
returns all books by that authorborrow(String title, String author)
finds and borrows a bookAdd getBorrowStats()
method to Library
:
Map<String, Integer> getBorrowStats()
Returns total times borrowed per author.
Write printBooksByPopularity()
that prints all books in descending borrow count using toString()
.
You may use a custom Comparator
or implement Comparable
.
A school system tracks students and their grades. Each student has a name, a list of test scores, and a method for calculating their average.
Student
ClassaddScore(int score)
adds a scoregetAverage()
returns the average scoretoString()
returns "Name: [scores], Average: avg"Gradebook
ClassArrayList<Student>
addStudent(Student s)
adds a studentgetTopStudent()
returns student with highest averagegetClassAverage()
returns overall average score of all studentsfindStudent(String name)
returns the Student
object with the given nameAdd a method printGradeReport()
to Gradebook
that prints each student's name, scores, and average in a formatted report.