Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can I get this in python with the given information below. Given information Problem Statement: Library Search Application Design and implement a simple interactive library

Can I get this in python with the given information below.

image text in transcribed

image text in transcribed

image text in transcribed

Given information

image text in transcribed

Problem Statement: Library Search Application Design and implement a simple interactive library search application for users. In addition to building the library repository, the program should be able to search a particular item (book or magazine) from the library. The purpose of this lab is to gain experience in python's class, methods and inheritance features, and exception handling. Program Design: 1. (Inheritance) Before starting of the program draw a general outline of your code. Think about it from the operational perspective: a. What should be the base class? Hint: Think about a Libraryltem class. i. What are the methods and attributes that are common among all the classes? b. What should be your sub classes? Can you identify the IS-A relationships? Hint: Different types of items since they have some additional information apart from the common attributes. i. What are the methods and attributes needed to properly define a subclass? ii. How to use the __init_method of the superclass? C. How to design the search options for the user? Hint: Remember how we extended a list class while designing our Contact manager class by adding a search method? (Lecture 7: Extending built-ins Ex3_contact_list_inheritance.py). You can desing a Catalog class as simiar to that which contains a search method. 2. Based on the information from the step 1, write the class definition and methods. 3. Start the input file processing and create the objects to build the library repository. 4. Design the main menu structure as provided in the sample 1/0. 5. (Exception handling) You must implement two exception handling classes. a. Invaliditem: One for when an item is not found (Invaliditem). b. InvalidOption: When the user inputs a wrong option (i.e. Not 1 or 2). You will need to use a try-except in your menu to make use of these exception classes. You may refer to LA5 for more help on how to do this. Input file specification: Here is a sample example of the input file, (an input file named library.txt is attached with the assignment). book, Girl with no name, Novel,S1234,978-1605985459,Deborah Rai magazine, Time, News,S245, Vol15-22,MAR-21 book,Journey to the moon, Fiction,S789,971-1605985190, Ashley Howler book, The calculating stars, Fiction, S123,978-0765378385, Mary Kowal magazine, Mason Spirit, George Mason University, S8291, Vol45, Issues 2021 Each line contains a record of an item. There are two types of items: book and magazine. The book information is arranged in following order (separated by comma): Item type, Title, Genre of the book, Stack no to locate the book in library (starts with S), ISBN number, Author The magazine information is arranged in the following manner: Item type, Title, Genre of the magazine, Stack no to locate the book in library (starts with S), Volume no, Issue All the items have some common information: Item type, title, genre, stack no. A book has ISBN and author information whereas the magazine has volume and issue number. Program Output and Behavior Specification: 1. Once the program has read in the data file, it should build an all_items list that contain all Libraryltem objects. The all_items list is a Catalog object. Catalog class needs to implement a search method. 2. User menu can be defined inside a simple main function. User has two options: 1. Search or 2. Exit the application. Your program should raise InvalidOption if user hits anything other than 1 or 2. 3. Search provides used to either search a book or magazine item. The program raises an Invaliditem exception if the item is not found. 4. Two sample runs provided below. Sample 1 is shown with no exception and sample 2 is shown with exceptions. Sample 1/0: Sample 1/0 (no exception) Sample 1/0 (with exception) Welcome to library main menu: Library database loaded....... 1. Search 2. Exit Enter choice (1-2):1 Enter item type (book/magazine): book Enter the title of the item: Girl with no name ------- Item Information ------- Girl with no name Deborah Rai 978-1605985459 Deborah Rai S1234 Welcome to library main menu: Library database loaded....... 1. Search 2. Exit Enter choice (1-2): 3 Invalid option. Returning to main menu. 1. Search 2. Exit Enter choice (1-2): 1 Enter item type (book/magazine):book Enter the title of the item: Girl with names Sorry. This item does not exist. 1. Search 2. Exit Enter choice (1-2): 1 Enter item type (book/magazine):dvd Enter the title of the item: Lost planet Sorry. This item does not exist. 1. Search 2. Exit Enter choice (1-2):2 Exiting the database... 1. Search 2. Exit Enter choice (1-2): 1 Enter item type (book/magazine).magazine Enter the title of the item: Time ------- Item Information ------- Time Vol15-22 MAR-21 S245 1. Search 2. Exit Enter choice (1-2): 2 Exiting the database... #define InvalidItem Exception class class InvalidItem (Exception): #your code here #defing Invalidoption Exception class #define a Catalog class and a serach method #define a LibraryItem class #define a Book, Magazine class #define a main function Clef main(): #read file information and create book/magazine object with open (file_name) as f: for line in f: #find the item type if item_type == 'book': #create a book object #once object creation is done #setup a user menu using try-except block #if item not found raise and InvalidItem exception #if choice not l or 2, then raise Invalidoption Problem Statement: Library Search Application Design and implement a simple interactive library search application for users. In addition to building the library repository, the program should be able to search a particular item (book or magazine) from the library. The purpose of this lab is to gain experience in python's class, methods and inheritance features, and exception handling. Program Design: 1. (Inheritance) Before starting of the program draw a general outline of your code. Think about it from the operational perspective: a. What should be the base class? Hint: Think about a Libraryltem class. i. What are the methods and attributes that are common among all the classes? b. What should be your sub classes? Can you identify the IS-A relationships? Hint: Different types of items since they have some additional information apart from the common attributes. i. What are the methods and attributes needed to properly define a subclass? ii. How to use the __init_method of the superclass? C. How to design the search options for the user? Hint: Remember how we extended a list class while designing our Contact manager class by adding a search method? (Lecture 7: Extending built-ins Ex3_contact_list_inheritance.py). You can desing a Catalog class as simiar to that which contains a search method. 2. Based on the information from the step 1, write the class definition and methods. 3. Start the input file processing and create the objects to build the library repository. 4. Design the main menu structure as provided in the sample 1/0. 5. (Exception handling) You must implement two exception handling classes. a. Invaliditem: One for when an item is not found (Invaliditem). b. InvalidOption: When the user inputs a wrong option (i.e. Not 1 or 2). You will need to use a try-except in your menu to make use of these exception classes. You may refer to LA5 for more help on how to do this. Input file specification: Here is a sample example of the input file, (an input file named library.txt is attached with the assignment). book, Girl with no name, Novel,S1234,978-1605985459,Deborah Rai magazine, Time, News,S245, Vol15-22,MAR-21 book,Journey to the moon, Fiction,S789,971-1605985190, Ashley Howler book, The calculating stars, Fiction, S123,978-0765378385, Mary Kowal magazine, Mason Spirit, George Mason University, S8291, Vol45, Issues 2021 Each line contains a record of an item. There are two types of items: book and magazine. The book information is arranged in following order (separated by comma): Item type, Title, Genre of the book, Stack no to locate the book in library (starts with S), ISBN number, Author The magazine information is arranged in the following manner: Item type, Title, Genre of the magazine, Stack no to locate the book in library (starts with S), Volume no, Issue All the items have some common information: Item type, title, genre, stack no. A book has ISBN and author information whereas the magazine has volume and issue number. Program Output and Behavior Specification: 1. Once the program has read in the data file, it should build an all_items list that contain all Libraryltem objects. The all_items list is a Catalog object. Catalog class needs to implement a search method. 2. User menu can be defined inside a simple main function. User has two options: 1. Search or 2. Exit the application. Your program should raise InvalidOption if user hits anything other than 1 or 2. 3. Search provides used to either search a book or magazine item. The program raises an Invaliditem exception if the item is not found. 4. Two sample runs provided below. Sample 1 is shown with no exception and sample 2 is shown with exceptions. Sample 1/0: Sample 1/0 (no exception) Sample 1/0 (with exception) Welcome to library main menu: Library database loaded....... 1. Search 2. Exit Enter choice (1-2):1 Enter item type (book/magazine): book Enter the title of the item: Girl with no name ------- Item Information ------- Girl with no name Deborah Rai 978-1605985459 Deborah Rai S1234 Welcome to library main menu: Library database loaded....... 1. Search 2. Exit Enter choice (1-2): 3 Invalid option. Returning to main menu. 1. Search 2. Exit Enter choice (1-2): 1 Enter item type (book/magazine):book Enter the title of the item: Girl with names Sorry. This item does not exist. 1. Search 2. Exit Enter choice (1-2): 1 Enter item type (book/magazine):dvd Enter the title of the item: Lost planet Sorry. This item does not exist. 1. Search 2. Exit Enter choice (1-2):2 Exiting the database... 1. Search 2. Exit Enter choice (1-2): 1 Enter item type (book/magazine).magazine Enter the title of the item: Time ------- Item Information ------- Time Vol15-22 MAR-21 S245 1. Search 2. Exit Enter choice (1-2): 2 Exiting the database... #define InvalidItem Exception class class InvalidItem (Exception): #your code here #defing Invalidoption Exception class #define a Catalog class and a serach method #define a LibraryItem class #define a Book, Magazine class #define a main function Clef main(): #read file information and create book/magazine object with open (file_name) as f: for line in f: #find the item type if item_type == 'book': #create a book object #once object creation is done #setup a user menu using try-except block #if item not found raise and InvalidItem exception #if choice not l or 2, then raise Invalidoption

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

More Books

Students also viewed these Databases questions

Question

=+60-3 Describe the four components of emotional intelligence.

Answered: 1 week ago