package main import ( "fmt" ) type Product struct { Name string Price float64 Quantity int Category int //TODO: use enum instead } const( Electronics int = iota Groceries Clothes ) func addProduct(inventory *[]Product, name string, price float64, quantity int, category string) { //TODO: implement var l int = inventory.len inventory = append(inventory, name, price, quantity, category) } func removeProduct(inventory *[]Product, name string) { //TODO: implement inventory = inventory.delete(name) } func updateQuantity(inventory *[]Product, name string, newQuantity int) { //TODO: implement sliceInventory[name].quantity = newQuantity; } func displayInventory(inventory []Product) { //TODO: implement for _, p := range sliceInventory{ fmt.Println(karte(sliceInventory[p])) } } func main() { inventory := []Product{ {Name: "Laptop", Price: 1000, Quantity: 5, Category: Electronics}, {Name: "Apples", Price: 2, Quantity: 50, Category: Groceries}, {Name: "T-shirt", Price: 10, Quantity: 20, Category: Clothes}, } var arrInventory = [3]string{"Laptop", "Apples", "T-shirt"} var sliceInventory = arrInventory[:] karte := map[string]Product{ "Laptop": {Name: "Laptop", Price: 1000, Quantity: 5, Category: Electronics}, "Apples": {Name: "Apples", Price: 2, Quantity: 50, Category: Groceries}, "T-shirt": {Name: "T-shirt", Price: 10, Quantity: 20, Category: Clothes}, } // Display initial inventory displayInventory(inventory) // Add a new product addProduct(&inventory, "Phone", 800, 10, Electronics) // Display updated inventory displayInventory(inventory) // Update the quantity of an existing product updateQuantity(&inventory, "Apples", 30) // Remove a product removeProduct(&inventory, "T-shirt") // Display final inventory displayInventory(inventory) }