You are working at the checkout counter of a library and want to write a program
ID: 3648018 • Letter: Y
Question
You are working at the checkout counter of a library and want to write a program that will print out information about the items a borrower has just checked out. The borrower can borrow at least the following items: best selling book, children's book, and videos. They can also try to checkout reference books, but should receive a message that says the reference materials are for use within the library. You are to print out a receipt for borrowers telling them the name of their type of book, and how many days they can borrow the item for. Children's books can be borrowed for 20 days, videos can be borrowed for 3 days, reference materials for 0 days, and best sellers for 10 days. After an item is borrowed it should be marked as unavailable. Every item has a title. Books and videos have a category and children's books have an additional descriptor called reading level. Each type of book should be an extension of a base class that has attributes for the title, the number of borrowing days, and whether the book is available.Explanation / Answer
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 import java.util.*; import java.io.*; public class Books { String title; int checkoutDays; int bookAvailability; String readingLevel, category; public Books() { title=""; checkoutDays = 0; bookAvailability = 0; } boolean canBorrow() { return false; } void displayreceipt() { System.out.println("Book is unavailable"); } } class ReferenceBook extends Books { ReferenceBook() { super(); title= ("World Reference"); checkoutDays=0; } boolean canBorrow() { return false; } void refMaterial() { System.out.println("Book is for use in library only"); } } class BestSeller extends Books { String fiction; BestSeller() { super(); title= ("Mystic River"); checkoutDays=10; category= fiction; } boolean canBorrow() { return true; } void displayreceipt() { System.out.println("Book Name" + title + "Days allowed: " + checkoutDays); } } class ChildrensBooks extends Books { String easy, fiction; ChildrensBooks() { super(); title= ("Animal Farm"); checkoutDays=20; category= fiction; readingLevel= easy; } boolean canBorrow() { return true; } void displayreceipt() { System.out.println("Book Name" + title + "Days allowed: " + checkoutDays); } } class Videos extends Books { String learning; Videos() { super(); title= (""); checkoutDays = 3; category= learning; } boolean canBorrow() { return true; } void displayreceipt() { System.out.println("Video Name" + title + "Days allowed: " + checkoutDays); } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.