import random

class Song:
    def __init__(self, title):
        self.__title = title
        self.__favorite = False
        self.__rating = None

    def setRating(self, rating): # out of 10
        self.__rating = rating

    def setFavorite(self, favorite): # True/False
        self.__favorite = favorite

    def getTitle(self):
        return self.__title

    def __str__(self):
        # Name
        # Favorite: True
        # Rating: 10 / 10
        return self.__title + "\nFavorite: " + str(self.__favorite) + "\nRating: " + str(self.__rating) + " / 10"

class Dreamhouse:
    def __init__(self, owner = "Barbie"):
        # barbie is bossy and wants to own all dreamhouses,
        # unless otherwise specified
        self.__owner = owner
        self.__roomCount = 0
        self.__blocked = None
        self.__partySize = 0
        self.__roomOne, self.__roomTwo = None, None
        self.__cleanliness = random.randint(0, 100)
        # private attributes only!

    def __str__(self): # i should tone this down but it's surprisingly cute
        output = "\n** " + self.__owner + "\'s Dreamhouse **\n"
        output += ("=" * 25)

        # cleanliness percentage gives us our dreamhouse rating (up to 3 stars)
        # last 2 stars obtained from creating rooms
        rating = (self.__cleanliness / 100) * 3 + self.__roomCount
        
        output += ("\nRating: " + format(rating, ".2f") + " / 5.00")
        output += ("\nParty Size: " + str(self.__partySize))
        output += ("\nRoom 1: " + str(self.__roomOne))
        output += ("\nRoom 2: " + str(self.__roomTwo))
        output += "\n"
        output += ("=" * 25)
        output += "\n"
        return output
        
    def enter(self, name): # lowkey funny
        if name == self.__blocked:
            print(self.__blocked, "is on the premise. Police have been called.")
        else:
            print(name, "came to the party!")
            self.__partySize += 1

    def evict(self, name): # random function for cleanliness
        if self.__partySize == 0:
            print(self.__owner, "has no one to evict!")
            return
        
        print(name, "has overstayed their welcome. Bye-bye!")
        self.__partySize -= 1
        dirt = random.randint(-25, 25)
        self.__cleanliness -= dirt
        if dirt <= 0:
            print(name, "was a clean guest!", dirt * -1, "added to cleanliness.")
            self.__cleanliness = min(100, self.__cleanliness) # maximum of 100 for clean
        else:
            print("Ugh!", name, "left behind a mess.", dirt, "subtracted from cleanliness.")
            self.__cleanliness = max(0, self.__cleanliness) # minimum of 0 for clean

    def getCleanliness(self): # getter
        return self.__cleanliness

    def getOwner(self): # getter
        return self.__owner

    def setOwner(self, newOwner = "Barbie"): # setter
        # bossy barbie, she owns dreamhouse by default
        self.__owner = newOwner

    def setBlock(self, newBlock): # setter
        self.__blocked = newBlock

    def addRoom(self, roomName):
        # add rooms to increase dreamhouse rating 
        if self.__roomCount == 0:
            self.__roomOne = roomName
            self.__roomCount += 1
        elif self.__roomCount == 1:
            self.__roomTwo = roomName
            self.__roomCount += 1
        else:
            print("The Dreamhouse is full!")

    def crashParty(self, numKen): # call enter/evict repeatedly in loop
        print("Oh no! Kens are crashing the party!")
        if self.__blocked == "Ken":
            self.__blocked = None
            print("They broke through the block!")
        print()
        # perhaps i could use a while and make it dependent
        # on cleanliness somehow, instead of using numKen...
        # would be more interesting
        for i in range(numKen):
            self.enter("Ken")
            self.evict("Ken")
            print()        
