forked from steger/pr3-ws202526
51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
package main
|
|
|
|
type Product struct {
|
|
Name string
|
|
Price float64
|
|
Quantity int
|
|
Category string //TODO: use enum instead
|
|
}
|
|
|
|
func addProduct(inventory *[]Product, name string, price float64, quantity int, category string) {
|
|
//TODO: implement
|
|
}
|
|
|
|
func removeProduct(inventory *[]Product, name string) {
|
|
//TODO: implement
|
|
}
|
|
|
|
func updateQuantity(inventory *[]Product, name string, newQuantity int) {
|
|
//TODO: implement
|
|
}
|
|
|
|
func displayInventory(inventory []Product) {
|
|
//TODO: implement
|
|
}
|
|
|
|
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"},
|
|
}
|
|
|
|
// 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)
|
|
}
|