# Inventory System -- module (finished).

###################################################################
# Item class
###################################################################

class Item:
    def __init__(self, name, weight, value):
        self.name = name
        self.weight = weight
        self.value = value

    def describe(self):
        return f"{self.name} ({self.weight:.1f}kg, {self.value}g)"


###################################################################
# Inventory class
###################################################################

class Inventory:
    def __init__(self):
        self.items = []

    def add(self, item):
        self.items.append(item)

    def remove(self, name):
        for i, item in enumerate(self.items):
            if item.name == name:
                return self.items.pop(i)
        return None

    def total_weight(self):
        total = 0
        for item in self.items:
            total = total + item.weight
        return total

    def total_value(self):
        total = 0
        for item in self.items:
            total = total + item.value
        return total

    def list(self):
        print(f"Inventory ({len(self.items)} items):")
        for item in self.items:
            print("  - " + item.describe())
        print(f"  Totals: {self.total_weight():.2f}kg, {self.total_value()}g")
