class Page(object):
    # Initializes the page class
    def __init__(self):
        # These are private variables that can only be modified from outside the class through the use of a setter
        self.__title = "Welcome to the Zoo"
        # Error is a placeholder in this variable, it will be replaced by a function below.
        self.__current_animal = "ERROR"
        # This variable holds the first part of my HTML code.
        self.head = """
<!DOCTYPE HTML>
<html>
    <head>
        <title>{self.title}</title>
        <link href="css/styles.css" rel="stylesheet" type="text/css" />
    </head>
    <img class='welcome' src='images/wood_sign.png' alt='Welcome to the Jungle' />
    <body>
        """

        # Second part of my HTML code, this holds the Navigation for my page.
        self.__body = """
            <img class='background'  src='images/background.jpg' alt='background image' />
            <h1>Select an Animal to learn more.</h1>
            <ul>
                <li><a href="?animal=0" class='myButton'>Komodo Dragon</a></li>
                <li><a href="?animal=1" class='myButton'>Hummingbird</a></li>
                <li><a href="?animal=2" class='myButton'>Human Being</a></li>
            </ul>
        """
        # This section of HTML code will hold the info about each camera deal. It will be generated by a setter below.
        self.__display = """
            <h1 class='Home'>Click One of Animals to Learn More</h1><br/>
            """
        self.__loud_noises = "<audio autoplay src='audio/jungle.mp3' />"
        # This is the closing section of my HTML, it will not be changed
        self.close = """
    </body>
</html>"""
        # This variable is used to store all of the HTML code. It will be compiled by the update function
        self.whole_page = ""
        self.__section = ""

        # This is used to concatenate all HTML sections that need to be pushed to the page
    def update(self):
        self.whole_page = self.head + self.__body + self.__section + self.__loud_noises + self.close
        # This checks for and { } references and changes them to the appropriate value from its variable
        self.whole_page = self.whole_page.format(**locals())

    """
    Below are getters (@property) and setters (@name.setter) They listen for updates to specific private variables and
    run the predefined function. Sometimes they are used just to return a value. Sometimes I use them for more
    complicated tasks.
    """
    @property
    def title(self):
        return self.__title

    @title.setter
    def title(self, new_title):
        self.__title = new_title
        return self.__title

    @property
    def current_animal(self):
        return self.__current_animal

    @current_animal.setter
    def current_animal(self, new_animal):
        self.__current_animal = new_animal
        if self.__current_animal != "ERROR":
            # This holds all the info found on the notecard on my page. It is generated based on animal selected.
            self.__section = """
            <section class="animal_pic">
                <img class='animal' src="{self.current_animal.url}" alt="Image of {self.current_animal.name}" />
            </section>
            <section class="animal_info">
                <p class='push'>This is a {self.current_animal.name}.</p>
                <p>It is from the {self.current_animal.phylum} phylum.</p>
                <p>Which is in the {self.current_animal.klass} class.</p>
                <p>Its family is {self.current_animal.family}.</p>
                <p>Its genus is {self.current_animal.genus}.</p>
                <p>It can live for {self.current_animal.lifespan} years.</p>
                <p>It likes to live in {self.current_animal.habitat}.</p>
                <p>And spends most of its time {self.current_animal.geolocation}</p>
            </section>
            """
        else:
            pass
        self.update()

    @property
    def section(self):
        return self.__section

    @section.setter
    def section(self, new_section):
        self.__section = new_section
        self.update()

    @property
    def loud_noises(self):
        return self.__loud_noises

    @loud_noises.setter
    def loud_noises(self, new_noise):
        self.__loud_noises = new_noise
        self.update()