程序代写代做 html C data structure Lab 3

Lab 3

Madam Irma Pince is the Librarian for the Hogwarts School of Witchcraft & Wizardry.
You are being asked to code a library inventory system to support the various functions/duties of the librarian.

The Hogwarts librarian has many duties, including:
Paperwork:
• Establishing library rules, regulations, policies and procedures.
• Preparing the library due date sheets and maintaining overdue records.
• Prepare and manage the library budgets, circulation files, statistics and inventories.
• Classify, and catalogue library books in order to properly making them ready for checkout.
Practical work:
• Monitoring the Library, as well as keeping it organised, clean and neat.
• Assisting students and staff members in finding the desired reading material.
• Implementing and enforcing library rules, regulations, policies and procedures.
• Placing spells on the books aimed at protecting them from mistreatment or theft.
• Checking the authenticity of the written permissions slips for the Restricted Section.
• Making sure all students have left the library by 8:00 pm, at which time the library closes.
• Overseeing the Study Hall and helping students with academic research and/or homework.
• Undertaking any other reasonable duty at the request of the Headmaster/Headmistress of Hogwarts.
Within the school, each student is assigned to a House(“Gryffindor”, “Hufflepuff”, “Slytherin”, “Ravenclaw”).
Each school year, each house is competition to score the most House points to win the House Cup.
Whenever a student fails to turn in a book, the librarian will put a curse on the book, and deduct House
points from the House the student belongs to. The library system must report the penalties earned by
each school. To facilitate this, the library maintains the following structures:

Provided Library Structures(structures.py):
Library Structures are defined in the file named “structures.py”.
Book
• title: str
• author: str
• subject: str
• section: Non-Restricted, Restricted(Requires a pass code)
Book = namedtuple(‘Book’, ‘title author date subject section’)
curses = Book(“Curses and Counter-Curses”, “Vindictus Viridian”, “1703”, “Curses”, “Restricted”)
Checkout Record Stores information about a book that has been checked out
• book: Book
• member: Student
• due date: datetime.date
Checkout = namedtuple(‘Record’, ‘book member due_date’)
curse_checkout = Checkout(curses, harry_potter, datetime.date(year=1991, month=9, day=3))
Student Record Stores information about a student/library member
• name: string
• checkedoutbooks: [Book]
• house: “Gryffindor”, “Hufflepuff”, “Slytherin”, “Ravenclaw”
• penalty: Penalty
Student = namedtuple(‘Student’, ‘name checked_out_books house penalty’)
harry_potter = Student(“Harry Potter”, [curses], “Gryffindor”, no_penalty)
Penalties
• curse: str
• point_deduction: int
Penalty = namedtuple(‘Penalty’, ‘curse point_deduction’)
one_day_penalty = Penalty(“Ear-Shrivelling”, 10)

# Define Container of the total outstanding point balance of every house
house_balance = {“Gryffindor”: 0, “Hufflepuff”: 0, “Ravenclaw”: 0, “Slytherin”: 0}

Provided Simulation Code(main.py & functions.py):
Code to run through menus & call functions based on user input has already been provided.
To DEBUG: Call the print_current_status() function to view the contents of library_collection, library_members, and library_checkouts. Another recommendation is to install another IDE such as PyCharm that will allow you to code using multiple files.
The code in Functions.py is divided into four main sets of functions.
• BOOK FUNCTIONS
• PENALTY FUNCTIONS
• STUDENT FUNCTIONS
• REPORT FUNCTIONS
• The function def & docstrings that you are required to implement are listed at the bottom of this description.
Recommended Order of Development: TO DO
Test cases have been ordered to guide you in the recommended order of function development.
However, you’re welcome to develop functions in any order that suits you best.
Description & function implementation details are in each function’s docstring.
View details in functions.py
###########################################################################
# BOOK FUNCTIONS
###########################################################################
def add_book() -> None:
“”” Create & add a new book to the library_collection. “””
def checkout_books() -> None:
“”” Search for & check out books from the library. “””
def checkout_book(book: Book, student: Student) -> None:
“”” Check out a book from the library. “””
def return_books() -> None:
“”” Return books. “””
def return_book(book: Book) -> None:
“”” Return a book. “””
def remove_books() -> None:
“”” Remove books. “””
def remove_book(book: Book) -> None:
“”” Remove a book from the Library. “””
def find_books(for_checkout=False) -> [Book]:
“”” Find & return books that match search criteria. “””
###########################################################################
# PENALTY FUNCTIONS
###########################################################################
def calculate_penalty(due_date: datetime) -> Penalty:
“”” Return the penalty based on how late the book is. “””
def update_students() -> None:
“”” Update the penalty/curse of library members. “””
def update_houses() -> None:
“”” Update the point balance of the Houses of Hogwarts. “””
def administer_penalties() -> None:
“”” Update the Library records to reflect penalties. “””
###########################################################################
# STUDENT FUNCTIONS
###########################################################################
def find_student(print_title=True) -> Student:
“”” Find a student that matches search criteria. “””
def add_student() -> None:
“”” Add a new member to library_members. “””
def remove_student() -> None:
“”” Remove a student from the Library. “””
###########################################################################
# REPORT FUNCTIONS
###########################################################################
def book_search_report() -> None:
“”” Find and print all books meeting search criteria. “””
def checkout_report() -> None:
“”” List checked out books, their current borrower, and their current curse. “””
def house_penalty_report() -> None:
“”” List the current outstanding point balance of every house in Hogwarts. “””
def due_today_report() -> None:
“”” List all books with the current_date as the deadline. “””

File1 function.py

#Add import statement here

###########################################################################
# BOOK FUNCTIONS
###########################################################################

def add_book() -> None:
“””
Create & add a new book to the library_collection.

Prompt user for field values of new book.
Create a new book object.
Add the new book to the library_collection.
“””
print_function_title(“*”, “ADD BOOK”)

def checkout_books() -> None:
“””
Search for & check out books from the library.

1) Get book details & find_books meeting requirements.
2) Get student details & find_student checking out the books.
3) Verify pass code for restricted books.
4) Call checkout with results from 1) & 2)
“””
print_function_title(“*”, ” CHECKOUT BOOKS “)

def checkout_book(book: Book, student: Student) -> None:
“””
Check out a book from the library.

Create a Checkout object. The due date is 7 days after the current date.
Update both the library checkouts & student record.
“””
pass

def return_books() -> None:
“””
Return books.

Find the books to be returned.
Return each book found.
“””
print_function_title(“*”, ” RETURN BOOKS “)

def return_book(book: Book) -> None:
“””
Return a book.

Remove the book from library_checkouts
Remove the book from a Student Record.
“””
pass

def remove_books() -> None:
“””
Remove books.

Find the books to be removed.
Remove each book found.
“””
print_function_title(“*”, ” REMOVE BOOKS “)

def remove_book(book: Book) -> None:
“””
Remove a book from the Library.

Remove the book from the library_collection.
Remove the book entry from library_checkouts.
Remove the book entry from library_members.
“””
pass

def find_books(for_checkout=False) -> [Book]:
“””
Find & return books that match search criteria.

for_checkout: if True, do not return books that are in library_checkouts

Use get_arg_values with book_fields to develop search values.
Find and return books that meet ALL of the search criteria.
If the user leaves all fields blank, return all books(unless for_checkout is True).
:return: a list of books that meet the search criteria
“””
search_values =get_arg_values(book_fields)

###########################################################################
# PENALTY FUNCTIONS
###########################################################################
def calculate_penalty(due_date: datetime) -> Penalty:
“””
Return the penalty based on how late the book is.

library_penalties start 8 days after a book is checked out.
On day 12 80 points are removed from the member’s house and
the book is forcibly returned.

NOTE: See https://docs.python.org/3/library/datetime.html#datetime.datetime
for performing date calculations.
“””

def update_students() -> None:
“””
Update the penalty/curse of library members.

Calculate the penalty for each book checked out.
Update the penalty fields for both the library_checkouts & library_members.
Any books that have been overdue for 5 days, must be returned immediately.
See Test 4. TASK 3 for an example of a forced return
“””
pass

def update_houses() -> None:
“””
Update the point balance of the Houses of Hogwarts.

Deduct penalty points from each house for each member’s penalty.
“””
pass

def administer_penalties() -> None:
“””
Update the Library records to reflect penalties.

Update Student records & House penalties.
This function is called at the start of each day(in main.py), to reflect penalties from the previous day.
“””
pass

###########################################################################
# STUDENT FUNCTIONS
###########################################################################
def find_student(print_title=True) -> Student:
“””
Find a student that matches search criteria.

Use get_arg_values with student_fields to develop search values.
Find and return a student that meets ALL of the search criteria.

:return: a student based on user-defined search parameters.
None if the student cannot be found.
“””
if print_title:
print_function_title(“*”, ” FIND STUDENT “)

search_args = get_arg_values(student_fields)

def add_student() -> None:
“””
Add a new member to library_members.

1) Get a student’s name, house, & create a Student object
2) Add the student to library_members
“””
print_function_title(“*”, ” ADD STUDENT “)

def remove_student() -> None:
“””
Remove a student from the Library.

Remove the student from library_members.
Remove any library_checkouts corresponding to the student.
“””
print_function_title(“*”, ” REMOVE STUDENT “)

###########################################################################
# REPORT FUNCTIONS
###########################################################################

def book_search_report() -> None:
“””
Find and print all books meeting search criteria
“””
print_function_title(“*”, ” BOOK SEARCH REPORT “)
print(‘{}’.format(‘-‘ * SCREEN_WIDTH))
# Add code here.
print(“\n\n”)

def checkout_report() -> None:
“””
List checked out books, their current borrower, and their current curse.

Report of books checked out needs to be listed each school name sorted alphabetically,
and each student name sorted alphabetically, and each book title sorted alphabetically.
“””
print_function_title(“*”, ” CURRENT CHECKOUT REPORT “, current_date.strftime(“%A %d, %B %Y”))
print_function_title(” “, “Book Title”, “Student Name”, “Curse”)
print(‘-‘*SCREEN_WIDTH)
format_string = “{title:<33}{name:^18}{curse:>13}”
# Add code here.
print(“\n\n”)

def house_penalty_report() -> None:
“””List the current outstanding point balance of every house in Hogwarts.”””
print_function_title(“*”, ” HOUSE PENALTY REPORT “, current_date.strftime(“%A %d, %B %Y”))
print_function_title(” “, “School”, “Points”)
format_string = ‘{school:^{width}}{points:^{width}}’
width = SCREEN_WIDTH // 2
print(‘-‘*SCREEN_WIDTH)
# Add code here.
print(“\n\n”)

def due_today_report() -> None:
“””
List all books with the current_date as the deadline.

Hint: use book_to_string() to format each book for printing
“””
print_function_title(“*”, ” DUE TODAY REPORT “, current_date.strftime(“%A %d, %B %Y”))
print_function_title(” “, “Book Title”, “Student Name”)
format_string = ‘{title:^{width}}{name:^{width}}’
width = SCREEN_WIDTH // 2
print(‘-‘*SCREEN_WIDTH)
# Add code here.
print(“\n\n”)

###########################################################################
# MENU, PRINT & SEARCH FIELD FUNCTIONS
###########################################################################

def get_arg_values(search_fields) -> {}:
“””Prompt the user for input & return a dictionary of values.”””
print(“Type the value for each field. ”
“To leave a field blank, just press Enter.”)
args = {}
for parameter in search_fields:
value = input(search_fields[parameter]+”: \n”)
if value != ”:
args[search_fields[parameter]] = value
print(“\n\n”)
return args

def print_welcome_msg() -> None:
“””Welcome message for the current date.”””
print(“{title:~^{width}}\n{date:^{width}}\n{sep}”.format(title=”WELCOME TO THE HOGWARTS LIBRARY MANAGEMENT SYSTEM”,
sep=’-‘*SCREEN_WIDTH,
date=current_date.strftime(“%A %d, %B %Y”),
width = SCREEN_WIDTH))

def print_student_menu_response() -> None:
“””Print & Call the student menu function corresponding to the users’ command.”””
command = print_menu_response(student_menu)
if command != ‘E’:
student_menu[1][command][1]()

def print_report_menu_response() -> None:
“””Print & Call the report menu function corresponding to the users’ command.”””
command = print_menu_response(report_menu)
if command != ‘E’:
report_menu[1][command][1]()

def print_book_menu_response() -> None:
“””Print & Call the book menu function corresponding to the users’ command.”””
command = print_menu_response(book_menu)
if command != ‘E’:
book_menu[1][command][1]()

def print_menu_response(menu) -> None:
“””Print menu and validate user response.”””
menu_string = “{title:{fill}^{width}}\n”.format(title = menu[0], fill=’*’, width = SCREEN_WIDTH) +\
‘\n’.join([” {} – {}”.format(cmd, msg[0]) for (cmd, msg) in menu[1].items()]) +\
“\n\nEnter Command: \n”
response = input(menu_string)

while response not in menu[1]:
response = input(“Enter Command: \n”)

print()
return response

def print_function_title(fill, *args):
width = SCREEN_WIDTH//len(args)
title = ”.join([‘{:{fill}^{width}}’.format(arg, width=width, fill=fill) for arg in args])
print(title)

def print_current_status() -> None:
“””Print the contents of the three main library structures.”””
print(“~~~ LIBRARY COLLECTION ~~~”)
print(library_collection)
print(“~~~ LIBRARY MEMBERS ~~~”)
print(library_members)
print(“~~~ LIBRARY CHECKOUTS ~~~”)
print(library_checkouts)

def book_to_string(book: Book) -> str:
“””Create & return a string containing Book information.”””
return “Title: {}\nAuthor: {}\nDate: {}\nSubject: {}\nSection: {}”.format(book.title, book.author, book.date, book.subject, book.section)

# Menus & Commands
book_fields = {‘T’: “Title”,
‘A’: “Author”,
‘D’: “Date”,
‘S’: “Subject”}

student_fields = {‘N’: “Student Name”,
‘H’: “Student House”}

report_menu = (“REPORT MENU”,
{‘S’: (“Search for Books”, book_search_report),
‘H’: (“House Balance Report”, house_penalty_report),
‘D’: (“Due Today Report”, due_today_report),
‘C’: (“Checkout Report”, checkout_report),
‘E’: (“Exit Report Menu”, None)})

student_menu = (“STUDENT MANAGEMENT MENU”,
{‘A’: (“Add a Student”, add_student),
‘R’: (“Remove a Student”, remove_student),
‘E’: (“Exit Student Menu”, None)})

book_menu = (“BOOK MENU”,
{‘A’: (“Add a Book”, add_book),
‘C’: (“Checkout Books”, checkout_books),
‘D’: (“Delete Books”, remove_books),
‘R’: (“Return Books”, return_books),
‘E’: (“Exit Book Menu”, None)})

main_menu = (“MAIN MENU”,
{‘B’: (“Book Menu”, print_book_menu_response),
‘R’: (“Report Menu”, print_report_menu_response),
‘S’: (“Student Management Menu”, print_student_menu_response),
‘Q’: (“Quit”, None)})

File 2 function.py(所有的function写这里)

def checkout_books() -> None:
“””
Search for & check out books from the library.

1) Get book details & find_books meeting requirements.
2) Get student details & find_student checking out the books.
3) Verify pass code for restricted books.
4) Call checkout with results from 1) & 2)
“””
print_function_title(“*”, ” CHECKOUT BOOKS “)

def checkout_book(book: Book, student: Student) -> None:
“””
Check out a book from the library.

Create a Checkout object. The due date is 7 days after the current date.
Update both the library checkouts & student record.
“””
pass

def return_books() -> None:
“””
Return books.

Find the books to be returned.
Return each book found.
“””
print_function_title(“*”, ” RETURN BOOKS “)

def return_book(book: Book) -> None:
“””
Return a book.

Remove the book from library_checkouts
Remove the book from a Student Record.
“””
pass

def remove_books() -> None:
“””
Remove books.

Find the books to be removed.
Remove each book found.
“””
print_function_title(“*”, ” REMOVE BOOKS “)

def remove_book(book: Book) -> None:
“””
Remove a book from the Library.

Remove the book from the library_collection.
Remove the book entry from library_checkouts.
Remove the book entry from library_members.
“””
pass

def find_books(for_checkout=False) -> [Book]:
“””
Find & return books that match search criteria.

for_checkout: if True, do not return books that are in library_checkouts

Use get_arg_values with book_fields to develop search values.
Find and return books that meet ALL of the search criteria.
If the user leaves all fields blank, return all books(unless for_checkout is True).
:return: a list of books that meet the search criteria
“””
search_values =get_arg_values(book_fields)

###########################################################################
# PENALTY FUNCTIONS
###########################################################################
def calculate_penalty(due_date: datetime) -> Penalty:
“””
Return the penalty based on how late the book is.

library_penalties start 8 days after a book is checked out.
On day 12 80 points are removed from the member’s house and
the book is forcibly returned.

NOTE: See https://docs.python.org/3/library/datetime.html#datetime.datetime
for performing date calculations.
“””

def update_students() -> None:
“””
Update the penalty/curse of library members.

Calculate the penalty for each book checked out.
Update the penalty fields for both the library_checkouts & library_members.
Any books that have been overdue for 5 days, must be returned immediately.
See Test 4. TASK 3 for an example of a forced return
“””
pass

def update_houses() -> None:
“””
Update the point balance of the Houses of Hogwarts.

Deduct penalty points from each house for each member’s penalty.
“””
pass

def administer_penalties() -> None:
“””
Update the Library records to reflect penalties.

Update Student records & House penalties.
This function is called at the start of each day(in main.py), to reflect penalties from the previous day.
“””
pass

###########################################################################
# STUDENT FUNCTIONS
###########################################################################
def find_student(print_title=True) -> Student:
“””
Find a student that matches search criteria.

Use get_arg_values with student_fields to develop search values.
Find and return a student that meets ALL of the search criteria.

:return: a student based on user-defined search parameters.
None if the student cannot be found.
“””
if print_title:
print_function_title(“*”, ” FIND STUDENT “)

search_args = get_arg_values(student_fields)

def add_student() -> None:
“””
Add a new member to library_members.

1) Get a student’s name, house, & create a Student object
2) Add the student to library_members
“””
print_function_title(“*”, ” ADD STUDENT “)

def remove_student() -> None:
“””
Remove a student from the Library.

Remove the student from library_members.
Remove any library_checkouts corresponding to the student.
“””
print_function_title(“*”, ” REMOVE STUDENT “)

###########################################################################
# REPORT FUNCTIONS
###########################################################################

def book_search_report() -> None:
“””
Find and print all books meeting search criteria
“””
print_function_title(“*”, ” BOOK SEARCH REPORT “)
print(‘{}’.format(‘-‘ * SCREEN_WIDTH))
# Add code here.
print(“\n\n”)

def checkout_report() -> None:
“””
List checked out books, their current borrower, and their current curse.

Report of books checked out needs to be listed each school name sorted alphabetically,
and each student name sorted alphabetically, and each book title sorted alphabetically.
“””
print_function_title(“*”, ” CURRENT CHECKOUT REPORT “, current_date.strftime(“%A %d, %B %Y”))
print_function_title(” “, “Book Title”, “Student Name”, “Curse”)
print(‘-‘*SCREEN_WIDTH)
format_string = “{title:<33}{name:^18}{curse:>13}”
# Add code here.
print(“\n\n”)

def house_penalty_report() -> None:
“””List the current outstanding point balance of every house in Hogwarts.”””
print_function_title(“*”, ” HOUSE PENALTY REPORT “, current_date.strftime(“%A %d, %B %Y”))
print_function_title(” “, “School”, “Points”)
format_string = ‘{school:^{width}}{points:^{width}}’
width = SCREEN_WIDTH // 2
print(‘-‘*SCREEN_WIDTH)
# Add code here.
print(“\n\n”)

def due_today_report() -> None:
“””
List all books with the current_date as the deadline.

Hint: use book_to_string() to format each book for printing
“””
print_function_title(“*”, ” DUE TODAY REPORT “, current_date.strftime(“%A %d, %B %Y”))
print_function_title(” “, “Book Title”, “Student Name”)
format_string = ‘{title:^{width}}{name:^{width}}’
width = SCREEN_WIDTH // 2
print(‘-‘*SCREEN_WIDTH)
# Add code here.
print(“\n\n”)

###########################################################################
# MENU, PRINT & SEARCH FIELD FUNCTIONS
###########################################################################

def get_arg_values(search_fields) -> {}:
“””Prompt the user for input & return a dictionary of values.”””
print(“Type the value for each field. ”
“To leave a field blank, just press Enter.”)
args = {}
for parameter in search_fields:
value = input(search_fields[parameter]+”: \n”)
if value != ”:
args[search_fields[parameter]] = value
print(“\n\n”)
return args

def print_welcome_msg() -> None:
“””Welcome message for the current date.”””
print(“{title:~^{width}}\n{date:^{width}}\n{sep}”.format(title=”WELCOME TO THE HOGWARTS LIBRARY MANAGEMENT SYSTEM”,
sep=’-‘*SCREEN_WIDTH,
date=current_date.strftime(“%A %d, %B %Y”),
width = SCREEN_WIDTH))

def print_student_menu_response() -> None:
“””Print & Call the student menu function corresponding to the users’ command.”””
command = print_menu_response(student_menu)
if command != ‘E’:
student_menu[1][command][1]()

def print_report_menu_response() -> None:
“””Print & Call the report menu function corresponding to the users’ command.”””
command = print_menu_response(report_menu)
if command != ‘E’:
report_menu[1][command][1]()

def print_book_menu_response() -> None:
“””Print & Call the book menu function corresponding to the users’ command.”””
command = print_menu_response(book_menu)
if command != ‘E’:
book_menu[1][command][1]()

def print_menu_response(menu) -> None:
“””Print menu and validate user response.”””
menu_string = “{title:{fill}^{width}}\n”.format(title = menu[0], fill=’*’, width = SCREEN_WIDTH) +\
‘\n’.join([” {} – {}”.format(cmd, msg[0]) for (cmd, msg) in menu[1].items()]) +\
“\n\nEnter Command: \n”
response = input(menu_string)

while response not in menu[1]:
response = input(“Enter Command: \n”)

print()
return response

def print_function_title(fill, *args):
width = SCREEN_WIDTH//len(args)
title = ”.join([‘{:{fill}^{width}}’.format(arg, width=width, fill=fill) for arg in args])
print(title)

def print_current_status() -> None:
“””Print the contents of the three main library structures.”””
print(“~~~ LIBRARY COLLECTION ~~~”)
print(library_collection)
print(“~~~ LIBRARY MEMBERS ~~~”)
print(library_members)
print(“~~~ LIBRARY CHECKOUTS ~~~”)
print(library_checkouts)

def book_to_string(book: Book) -> str:
“””Create & return a string containing Book information.”””
return “Title: {}\nAuthor: {}\nDate: {}\nSubject: {}\nSection: {}”.format(book.title, book.author, book.date, book.subject, book.section)

# Menus & Commands
book_fields = {‘T’: “Title”,
‘A’: “Author”,
‘D’: “Date”,
‘S’: “Subject”}

student_fields = {‘N’: “Student Name”,
‘H’: “Student House”}

report_menu = (“REPORT MENU”,
{‘S’: (“Search for Books”, book_search_report),
‘H’: (“House Balance Report”, house_penalty_report),
‘D’: (“Due Today Report”, due_today_report),
‘C’: (“Checkout Report”, checkout_report),
‘E’: (“Exit Report Menu”, None)})

student_menu = (“STUDENT MANAGEMENT MENU”,
{‘A’: (“Add a Student”, add_student),
‘R’: (“Remove a Student”, remove_student),
‘E’: (“Exit Student Menu”, None)})

book_menu = (“BOOK MENU”,
{‘A’: (“Add a Book”, add_book),
‘C’: (“Checkout Books”, checkout_books),
‘D’: (“Delete Books”, remove_books),
‘R’: (“Return Books”, return_books),
‘E’: (“Exit Book Menu”, None)})

main_menu = (“MAIN MENU”,
{‘B’: (“Book Menu”, print_book_menu_response),
‘R’: (“Report Menu”, print_report_menu_response),
‘S’: (“Student Management Menu”, print_student_menu_response),
‘Q’: (“Quit”, None)})

File 3 Structures.py

from collections import namedtuple
import datetime

# ZyBooks Screen Width
SCREEN_WIDTH = 64

# Inaugural Date of the Hogwarts Library Management System
current_date = datetime.date(year=1991, month=9, day=1)

# Namedtuple Definitions
Book = namedtuple(‘Book’, ‘title author date subject section’)
Student = namedtuple(‘Student’, ‘name checked_out_books house penalty’)
Checkout = namedtuple(‘Checkout’, ‘book member due_date’)
Penalty = namedtuple(‘Penalty’, ‘curse point_deduction’)

# Define Container of the total outstanding point balance of every house
house_balance = {“Gryffindor”: 0, “Hufflepuff”: 0, “Ravenclaw”: 0, “Slytherin”: 0}

# Define overdue penalties
no_penalty = Penalty(“None”, 0)
one_day_penalty = Penalty(“Ear-Shrivelling”, 10)
two_day_penalty = Penalty(“Hair Loss”, 20)
three_day_penalty = Penalty(“Curse of the Bogies”, 30)
four_day_penalty = Penalty(“Slug-Vomiting”, 50)
five_day_penalty = Penalty(“Book Return”, 80)

# Book Declarations
hogwarts = Book(“Hogwarts a History”, “Bathilda Bagshot”, “1947”, “Historical”, “Non-Restricted”)
winogrands = Book(“Winogrand’s Wondrous Water Plants”, “Selina Sapworthy”, “1970”, “Water plants”, “Non-Restricted”)
curses = Book(“Curses and Counter-Curses”, “Vindictus Viridian”, “1703”, “Curses”, “Restricted”)
ancient = Book(“Ancient Runes Made Easy”, “Laurenzoo”, “1992”, “Ancient Runes”, “Non-Restricted”)
secrets = Book(“Secrets of the Darkest Art”, “Owle Bullock”, “1943”, “Dark Arts”, “Restricted”)

# Define Members
harry_potter = Student(“Harry Potter”, [curses], “Gryffindor”, no_penalty)
nevil_longbottom = Student(“Nevil Longbottom”, [winogrands], “Gryffindor”, no_penalty)
draco_malfoy = Student(“Draco Malfoy”, [ancient], “Slytherin”, one_day_penalty)

# Define checkouts
curse_checkout = Checkout(curses, harry_potter, datetime.date(year=1991, month=9, day=3))
winogrands_checkout = Checkout(winogrands, nevil_longbottom, datetime.date(year=1991, month=9, day=1))
ancient_checkout = Checkout(ancient, draco_malfoy, datetime.date(year=1991, month=8, day=24))

# Define Library Data Structures
library_collection = [hogwarts, winogrands, curses, ancient, secrets]
library_members = {harry_potter.name: harry_potter, nevil_longbottom.name: nevil_longbottom, draco_malfoy.name: draco_malfoy}
library_checkouts = {curse_checkout.book.title: curse_checkout, winogrands_checkout.book.title: winogrands_checkout, ancient_checkout.book.title: ancient_checkout}
library_penalties = [one_day_penalty, two_day_penalty, three_day_penalty, four_day_penalty, five_day_penalty]
library_passcodes = [“Accio”, “Protego”]

Input:

R
C
R
H
R
E
R
E
R
C
R
H
R
E
R
E
R
C
R
H
R
E
R
E
R
C
R
H
R
E
R
E
R
C
Q

Expect output :

~~~~~~~WELCOME TO THE HOGWARTS LIBRARY MANAGEMENT SYSTEM~~~~~~~~
Sunday 01, September 1991
—————————————————————-
***************************MAIN MENU****************************
B – Book Menu
R – Report Menu
S – Student Management Menu
Q – Quit

Enter Command:

**************************REPORT MENU***************************
S – Search for Books
H – House Balance Report
D – Due Today Report
C – Checkout Report
E – Exit Report Menu

Enter Command:

*** CURRENT CHECKOUT REPORT *******Sunday 01, September 1991****
Book Title Student Name Curse
—————————————————————-
Curses and Counter-Curses Harry Potter None
Winogrand’s Wondrous Water Plants Nevil Longbottom None
Ancient Runes Made Easy Draco Malfoy Ear-Shrivelling

***************************MAIN MENU****************************
B – Book Menu
R – Report Menu
S – Student Management Menu
Q – Quit

Enter Command:

**************************REPORT MENU***************************
S – Search for Books
H – House Balance Report
D – Due Today Report
C – Checkout Report
E – Exit Report Menu

Enter Command:

***** HOUSE PENALTY REPORT ********Sunday 01, September 1991****
School Points
—————————————————————-
Gryffindor 0
Hufflepuff 0
Ravenclaw 0
Slytherin -10

***************************MAIN MENU****************************
B – Book Menu
R – Report Menu
S – Student Management Menu
Q – Quit

Enter Command:

**************************REPORT MENU***************************
S – Search for Books
H – House Balance Report
D – Due Today Report
C – Checkout Report
E – Exit Report Menu

Enter Command:

***************************MAIN MENU****************************
B – Book Menu
R – Report Menu
S – Student Management Menu
Q – Quit

Enter Command:

**************************REPORT MENU***************************
S – Search for Books
H – House Balance Report
D – Due Today Report
C – Checkout Report
E – Exit Report Menu

Enter Command:

~~~~~~~WELCOME TO THE HOGWARTS LIBRARY MANAGEMENT SYSTEM~~~~~~~~
Monday 02, September 1991
—————————————————————-
***************************MAIN MENU****************************
B – Book Menu
R – Report Menu
S – Student Management Menu
Q – Quit

Enter Command:

**************************REPORT MENU***************************
S – Search for Books
H – House Balance Report
D – Due Today Report
C – Checkout Report
E – Exit Report Menu

Enter Command:

*** CURRENT CHECKOUT REPORT *******Monday 02, September 1991****
Book Title Student Name Curse
—————————————————————-
Curses and Counter-Curses Harry Potter None
Winogrand’s Wondrous Water Plants Nevil Longbottom None
Ancient Runes Made Easy Draco Malfoy Hair Loss

***************************MAIN MENU****************************
B – Book Menu
R – Report Menu
S – Student Management Menu
Q – Quit

Enter Command:

**************************REPORT MENU***************************
S – Search for Books
H – House Balance Report
D – Due Today Report
C – Checkout Report
E – Exit Report Menu

Enter Command:

***** HOUSE PENALTY REPORT ********Monday 02, September 1991****
School Points
—————————————————————-
Gryffindor 0
Hufflepuff 0
Ravenclaw 0
Slytherin -30

***************************MAIN MENU****************************
B – Book Menu
R – Report Menu
S – Student Management Menu
Q – Quit

Enter Command:

**************************REPORT MENU***************************
S – Search for Books
H – House Balance Report
D – Due Today Report
C – Checkout Report
E – Exit Report Menu

Enter Command:

***************************MAIN MENU****************************
B – Book Menu
R – Report Menu
S – Student Management Menu
Q – Quit

Enter Command:

**************************REPORT MENU***************************
S – Search for Books
H – House Balance Report
D – Due Today Report
C – Checkout Report
E – Exit Report Menu

Enter Command:

~~~~~~~WELCOME TO THE HOGWARTS LIBRARY MANAGEMENT SYSTEM~~~~~~~~
Tuesday 03, September 1991
—————————————————————-
***************************MAIN MENU****************************
B – Book Menu
R – Report Menu
S – Student Management Menu
Q – Quit

Enter Command:

**************************REPORT MENU***************************
S – Search for Books
H – House Balance Report
D – Due Today Report
C – Checkout Report
E – Exit Report Menu

Enter Command:

*** CURRENT CHECKOUT REPORT *******Tuesday 03, September 1991***
Book Title Student Name Curse
—————————————————————-
Curses and Counter-Curses Harry Potter None
Winogrand’s Wondrous Water Plants Nevil Longbottom None
Ancient Runes Made Easy Draco Malfoy Curse of the Bogies

***************************MAIN MENU****************************
B – Book Menu
R – Report Menu
S – Student Management Menu
Q – Quit

Enter Command:

**************************REPORT MENU***************************
S – Search for Books
H – House Balance Report
D – Due Today Report
C – Checkout Report
E – Exit Report Menu

Enter Command:

***** HOUSE PENALTY REPORT ********Tuesday 03, September 1991***
School Points
—————————————————————-
Gryffindor 0
Hufflepuff 0
Ravenclaw 0
Slytherin -60

***************************MAIN MENU****************************
B – Book Menu
R – Report Menu
S – Student Management Menu
Q – Quit

Enter Command:

**************************REPORT MENU***************************
S – Search for Books
H – House Balance Report
D – Due Today Report
C – Checkout Report
E – Exit Report Menu

Enter Command:

***************************MAIN MENU****************************
B – Book Menu
R – Report Menu
S – Student Management Menu
Q – Quit

Enter Command:

**************************REPORT MENU***************************
S – Search for Books
H – House Balance Report
D – Due Today Report
C – Checkout Report
E – Exit Report Menu

Enter Command:

~~~~~~~WELCOME TO THE HOGWARTS LIBRARY MANAGEMENT SYSTEM~~~~~~~~
Wednesday 04, September 1991
—————————————————————-
***************************MAIN MENU****************************
B – Book Menu
R – Report Menu
S – Student Management Menu
Q – Quit

Enter Command:

**************************REPORT MENU***************************
S – Search for Books
H – House Balance Report
D – Due Today Report
C – Checkout Report
E – Exit Report Menu

Enter Command:

*** CURRENT CHECKOUT REPORT ******Wednesday 04, September 1991**
Book Title Student Name Curse
—————————————————————-
Curses and Counter-Curses Harry Potter None
Winogrand’s Wondrous Water Plants Nevil Longbottom None
Ancient Runes Made Easy Draco Malfoy Slug-Vomiting

***************************MAIN MENU****************************
B – Book Menu
R – Report Menu
S – Student Management Menu
Q – Quit

Enter Command:

**************************REPORT MENU***************************
S – Search for Books
H – House Balance Report
D – Due Today Report
C – Checkout Report
E – Exit Report Menu

Enter Command:

***** HOUSE PENALTY REPORT *******Wednesday 04, September 1991**
School Points
—————————————————————-
Gryffindor 0
Hufflepuff 0
Ravenclaw 0
Slytherin -110

***************************MAIN MENU****************************
B – Book Menu
R – Report Menu
S – Student Management Menu
Q – Quit

Enter Command:

**************************REPORT MENU***************************
S – Search for Books
H – House Balance Report
D – Due Today Report
C – Checkout Report
E – Exit Report Menu

Enter Command:

***************************MAIN MENU****************************
B – Book Menu
R – Report Menu
S – Student Management Menu
Q – Quit

Enter Command:

**************************REPORT MENU***************************
S – Search for Books
H – House Balance Report
D – Due Today Report
C – Checkout Report
E – Exit Report Menu

Enter Command:

~~~~~~~WELCOME TO THE HOGWARTS LIBRARY MANAGEMENT SYSTEM~~~~~~~~
Thursday 05, September 1991
—————————————————————-
~~~~~~~~~~~~~~~OVER DUE BOOK(S) FORCIBLY RETURNED~~~~~~~~~~~~~~~
User: Draco Malfoy
Title: Ancient Runes Made Easy
Author: Laurenzoo
Date: 1992
Subject: Ancient Runes
Section: Non-Restricted
***************************MAIN MENU****************************
B – Book Menu
R – Report Menu
S – Student Management Menu
Q – Quit

Enter Command:

**************************REPORT MENU***************************
S – Search for Books
H – House Balance Report
D – Due Today Report
C – Checkout Report
E – Exit Report Menu

Enter Command:

*** CURRENT CHECKOUT REPORT ******Thursday 05, September 1991***
Book Title Student Name Curse
—————————————————————-
Curses and Counter-Curses Harry Potter None
Winogrand’s Wondrous Water Plants Nevil Longbottom None

***************************MAIN MENU****************************
B – Book Menu
R – Report Menu
S – Student Management Menu
Q – Quit

Enter Command: