Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

if this one could be done Asap in python langugae This problem has 2 parts. Please be sure and label your answers part1 and part2

if this one could be done Asap in python langugae image text in transcribed
image text in transcribed
This problem has 2 parts. Please be sure and label your answers part1 and part2 "Part 1 (15 pts): We need a class called LibraryBook. Library Book objects have 3 instance variables as follows: 1. title is a string which contains the title of the library book. 2. numAvailable is an integer representing the number of copies of the book! that are available to be checked out 3. holds is the number of holds put on the library book. A hold means that no copies of the book are available to check out but someone wants to get on a waitlist for a copy as soon as it is available. The LibraryBook constructor will be passed two parameters, the book's title and the number of copies initially purchased for the library. The constructor should initialize all three attributes (holds will be set to 0). LibraryBook will have 3 methods: 1. checkout - expects no parameters and returns a Boolean. The method checks to see if at least one copy of the book is available to check out. If so, the method subtracts one from the number available and returns True. If there are no available copies of the book, checkout returns False. 2. checkin-expects no parameters and returns a Boolean. This method checks to see if there is a hold on the book (if holds is greater than 0). If so it decreases the holds by one and returns False. If there are no holds (holds equals O) on the book, this method increases by 1 the number of copies of the book available to be checked out and returns True. placeHold-expects no parameters and returns a Boolean. This method checks to see if there are any copies of the book available for check out. If there are no copies of the book available, the method adds one to holds and returns True. If there is a copy available, the method returns False decreases the holds by one and returns False. If there are no holds (holds equals 0) on the book, this method increases by 1 the number of copies of the book available to be checked out and returns True. 3. placeHold-expects no parameters and returns a Boolean. This method checks to see if there are any copies of the book available for check out. If there are no copies of the book available, the method adds one to holds and returns True. If there is a copy available, the method returns False. Write the LibraryBook class. Part 2 (15 points): Assume we have a Library Controller program which imports the Library Book class that you just created, with the three methods described. 1. Write a snippet of code that creates 2 LibraryBook objects. The first is book1 and has the title "Sam I Am". The second is book2 and has the title "Yertle the Turtle" 2. Write a few lines of code that will check out a copy of "Yertle the Turtle" and print fulfilled if the book is available for check out and unfulfilled if the book is not available for check out. Assume you do not know whether a copy is available and you have to write the code to check. 3. Write a few line of code that will place a hold on a copy of "Sam I Am". If the hold is successfully placed, print hold successful, otherwise print a copy is available for check out

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Theory And Applications 27th Australasian Database Conference Adc 20 Sydney Nsw September 28 29 20 Proceedings Lncs 9877

Authors: Muhammad Aamir Cheema ,Wenjie Zhang ,Lijun Chang

1st Edition

3319469215, 978-3319469218

Students also viewed these Databases questions

Question

Check the required conditions for Exercise 16.12.

Answered: 1 week ago