{-
   Erstelle folgende Klassen:
   
     - GeomObj    Funktionen: draw, color, area
     - Circle     Funktionen: center, radius            erbt von: GeomObj
     - Rect       Funktionen: lly, lly, width, height   erbt von: GeomObj
   
   und folgende Typen:
   
     - Color      Ausprägung von: Show
     - CircleType Ausprägung von: Circle
     - RectType   Ausprägung von: Rect
-}


-- --------------- Color -----------------------------------
data Color = Red | Green | Blue

instance Show Color where
  show Red   = "red"
  show Green = "green"
  show Blue  = "blue"


-- -------------- GeomObj ----------------------------------

class GeomObj a where
  draw  :: a -> IO()
  color :: a -> Color
  area  :: a -> Float


--------------- Circle -------------------------------------

class GeomObj a => Circle a where
  center :: a -> (Float, Float)
  radius :: a -> (Float)

data CircleType = MkCircle Float Float Float Color

instance GeomObj CircleType where
  draw  (MkCircle x y r c) = putStr ("I'm a " ++ (show c) ++ " circle with center " ++ (show (x,y)) ++ " and radius " ++ (show r))
  color (MkCircle _ _ _ c) = c
  area  (MkCircle _ _ r _) = pi * r * r

instance Circle CircleType where
  center (MkCircle x y _ _) = (x,y)
  radius (MkCircle _ _ r _) = r


---------------- Rectangle ---------------------------------

class GeomObj a => Rect a where
  llx    :: a -> Float
  lly    :: a -> Float
  width  :: a -> Float
  height :: a -> Float

data RectType   = MkRect Float Float Float Float Color

instance GeomObj RectType where
  draw  (MkRect x y w h c) = putStr ("Rect: " ++ (show [x, y, w, h]) ++ " with Color " ++ (show c))
  color (MkRect _ _ _ _ c) = c
  area  (MkRect _ _ w h _) = w * h


instance Rect RectType where
  llx    (MkRect x _ _ _ _) = x
  lly    (MkRect _ y _ _ _) = y
  width  (MkRect _ _ w _ _) = w
  height (MkRect _ _ _ h _) = h
