text: """
  Class Encore CIS 211 w/ Joseph
  horror.py
  Author: Joseph Goh
  Updated: 05/20/2021
  """
  
  from typing import List
  
  
  class Horror:
      """yikes"""
      def __init__(self, name: str, spookiness: int, appearances: int):
          self.name = name                # Name of the horror
          self.spookiness = spookiness    # Spookiness rated from one to ten
          self.appearances = appearances  # Number of movies it appears in
  
      def __str__(self):
          return f"Horror({self.name}: {self.spookiness} spook, {self.appearances} appearances)"
  
      def __repr__(self):
          return f"Horror({self.name})"
  
  
  class Comparison:
      """Abstract base class for all Comparison types."""
      def compare(self, h1: Horror, h2: Horror) -> bool:
          raise NotImplementedError("Concrete subclass must implement compare method!")
  
  
  class Spookier(Comparison):
      def compare(self, h1: Horror, h2: Horror) -> bool:
          """Return True if h1 has higher spookiness. Else, return False."""
          return h1.spookiness > h2.spookiness
  
  
  class MoreTotalSpooks(Comparison):
      def compare(self, h1: Horror, h2: Horror) -> bool:
          """Return True if h1 has higher total spooks (spookiness times appearances) than h2. Else, return False."""
          return (h1.spookiness * h1.appearances) > (h2.spookiness * h2.appearances)
  
  
  class HorrorList(List[Horror]):
      def best(self, comparison: Comparison) -> Horror:
          """Return the Horror that is the best according to the comparison given."""
          winner = self[0]
          for horror in self:
              if comparison.compare(horror, winner):
                  winner = horror
          return winner
  
      def drop_pg_horrors(self) -> "HorrorList":
          """
          Return a HorrorList with only the Horror objects whose spookiness is greater than the average
          spookiness of all Horror objects in self.
          """
          total = 0
          for horror in self:
              total += horror.spookiness
          avg = total / len(self)
  
          new_li = HorrorList()
          for horror in self:
              if horror.spookiness >= avg:
                  new_li.append(horror)
  
          return new_li
  
  
  # Example code
  horror_li = HorrorList()
  horror_li.append(Horror("Freddy Krueger", 6, 9))
  horror_li.append(Horror("Pennywise", 8, 3))
  horror_li.append(Horror("Any antagonist from Courage the Cowardly Dog", 5, 52))
  horror_li.append(Horror("The cats from Cats (2019)", 11, 1))
  
  # Horror(The cats from Cats: 11 spook, 1 appearances)
  print(horror_li.best(Spookier()))
  
  # Horror(Any antagonist from Courage the Cowardly Dog: 5 spook, 52 appearances)
  print(horror_li.best(MoreTotalSpooks()))
  
  # [Horror(Pennywise), Horror(The cats from Cats (2019))]
  print(horror_li.drop_pg_horrors())
  