feat: criando a view do menu e as regras de cadastro e listagem de produtos

This commit is contained in:
2026-07-14 20:16:10 -03:00
parent ada03a9ddb
commit 70f433ce2b
5 changed files with 97 additions and 2 deletions
+21
View File
@@ -0,0 +1,21 @@
package controller
import (
"bufio"
"controle-de-estoque/model"
"controle-de-estoque/view"
)
type Controller struct {
inventory *model.Inventory
}
func New(inventory *model.Inventory) *Controller {
return &Controller{inventory: inventory}
}
func (c *Controller) CapturarComando(scanner *bufio.Scanner) {
view.ExibirMenu()
// scanner.Scan()
}
+12 -2
View File
@@ -1,6 +1,16 @@
// main.go
package main package main
func main() { import (
"bufio"
"controle-de-estoque/controller"
"controle-de-estoque/model"
"os"
)
func main() {
estoque := model.NewInventory()
controller := controller.New(estoque)
scanner := bufio.NewScanner(os.Stdin)
controller.CapturarComando(scanner)
} }
View File
+49
View File
@@ -0,0 +1,49 @@
package model
type Product struct {
ID int
Name string
Category string
Price float64
Quantity int
}
type ProductInput struct {
Name string
Category string
Price float64
Quantity int
}
type Inventory struct {
products []Product
nextID int
}
func NewInventory() *Inventory {
return &Inventory{}
}
func (e *Inventory) AdicionarProduto(i *ProductInput) Product {
e.nextID += 1
product := Product{
ID: e.nextID,
Name: i.Name,
Category: i.Category,
Price: i.Price,
Quantity: i.Quantity,
}
e.products = append(e.products, product)
return product
}
func (e *Inventory) ListarProduto() []Product {
return e.products
}
func (e *Inventory) AtualizarProduto() {}
func (e *Inventory) DeletarProduto() {}
+15
View File
@@ -0,0 +1,15 @@
package view
import "fmt"
func ExibirMenu() {
fmt.Print(`
============ CONTROLE DE ESTOQUE ==============
ESCOLHA UMA DAS OPÇÕES:
1 / adicionar - Adiciona o produto no estoque
2 / listar - Lista todos os produtos do estoque
3 / atualizar - Atualiza um produto do estoque
4 / deletar - Deleta um produto do estoque
0 / sair - Sair do programa
`)
}