from datetime import datetime

class Cow:
def __init__(self, cow_id, breed):
self.cow_id = cow_id
self.breed = breed
self.production_history = {} # Format: {date: liters}

def record_milk(self, liters, date_str=None):
if date_str is None:
date_str = datetime.today().strftime(‘%Y-%m-%d’)
self.production_history[date_str] = liters
print(f”Logged {liters}L for Cow #{self.cow_id} on {date_str}.”)

def get_total_yield(self):
return sum(self.production_history.values())

class DairyFarm:
def __init__(self, farm_name):
self.farm_name = farm_name
self.herd = {}

def add_cow(self, cow):
self.herd[cow.cow_id] = cow
print(f”Cow #{cow.cow_id} ({cow.breed}) added to {self.farm_name}.”)

def get_herd_total_production(self, date_str):
total = sum(cow.production_history.get(date_str, 0) for cow in self.herd.values())
return total

# — Execution Example —
if __name__ == “__main__”:
my_farm = DairyFarm(“Green Valley Dairies”)

# Register cattle
cow1 = Cow(cow_id=101, breed=”Holstein Friesian”)
cow2 = Cow(cow_id=102, breed=”Jersey”)
my_farm.add_cow(cow1)
my_farm.add_cow(cow2)

# Record yields
today = “2026-09-26″
cow1.record_milk(28.5, today)
cow2.record_milk(22.0, today)

# Aggregate data
print(f”Total farm yield for {today}: {my_farm.get_herd_total_production(today)} Liters.”)