# L-24 MCS 260 : class Book
"""
This module exports a representation for a book.
For each book we store a key, its title, and a boolean variable
to indicate its availability.
The class wide atrribute count keeps track of the number of books
and is used to assign to every book a unique key.
"""
class Book(object):
    """
    Objects of the class Book represent books.
    """
    count = [0]  # class wide attribute

    def __init__(self, *title):
        "constructor a a book"
        self.count[0] = self.count[0] + 1
        self.key = self.count[0]
        if len(title) > 0:
            self.title = title[0]
        else:
            self.title = input('Give title : ')
        self.available = True

    def __str__(self):
        "string representation of book"
        prt = '%2d' % self.key
        prt += ': ' + self.title
        if self.available:
            prt += ' is available'
        else:
            prt += ' is not available'
        return prt

    def check(self):
        "returns the status of the book"
        return self.available

    def change(self):
        "flips the status of the book"
        self.available = not self.available
