On this page:
Problem 1: Books and abstraction
Problem 2:   Problem Solving Practice

Lab 4: Working with Abstract Classes, Problem Solving

Exam 1 prep: Before beginning the lab problems, please do the Hourglass tutorial at https://hourglass.khoury.northeastern.edu/. This will allow you to become familiar with the tool we will use for Exam 1 on the 22nd. Please use Firefox for accessing Hourglass.

Goals: The goals of this lab are to learn how to design and use abstract classes, and to solve problems with the use of accumulators.

Submission: Submit your solutions to Problem 1 in handins before leaving lab. This is due by the end of your lab and is graded on effort and good design.

Problem 1: Books and abstraction


Submission: You will submit your solution to this problem in handins. To earn full credit on this, your solution must be well-designed and a good attempt.

The following class diagram represents a library system that records the books that have been borrowed. There are three kinds of books: regular books, reference books, and audio books.

Reference books can be taken out for just two days, while other kinds of books may be borrowed for two weeks. The overdue fees are 10 cents per day for reference books and regular books, and 20 cents per day for audio books.

Audio books and regular books have both authors and titles; reference books only have titles.

The day when the book is taken out and the day due are counted as days since the library opened on New Year’s Day in 2001. So, for example, an audio book taken out recently would be recorded as taken out on the day 8568 with due date on the day 8582.

               | IBook |
                  / \
       |                  |                  |
+---------------+  +---------------+  +---------------+
| Book          |  | RefBook       |  | AudioBook     |
+---------------+  +---------------+  +---------------+
| String title  |  | String title  |  | String title  |
| String author |  | int dayTaken  |  | String author |
| int dayTaken  |  +---------------+  | int dayTaken  |
+---------------+                     +---------------+

For all methods, think carefully whether they should be designed being implemented solely in the abstract class, implemented solely in the concrete classes, or implemented in the abstract class and then overridden in some of the concrete classes.

Problem 2: Problem Solving Practice

The rest of the lab will be dedicated to strengthening problem solving skills, in particular the use of accumulators. It will require you to create new classes as well as determine what helper methods would be appropriate.