Skip to content

Instantly share code, notes, and snippets.

@tomplex
Last active March 8, 2022 03:02
Show Gist options
  • Save tomplex/8ef2b875238badb46831449c9a7bba14 to your computer and use it in GitHub Desktop.
Save tomplex/8ef2b875238badb46831449c9a7bba14 to your computer and use it in GitHub Desktop.
from dataclasses import dataclass
from typing import List
@dataclass
class Room:
name: str
length: int
width: int
height: int
def area(self) -> int:
return self.length * self.width
class House:
def __init__(self, rooms: List[Room]):
self.rooms = rooms
def area(self) -> int:
return sum(room.area() for room in self.rooms)
house = House([])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment