diff --git a/controller/controller.go b/controller/controller.go index e69de29..cbe8127 100644 --- a/controller/controller.go +++ b/controller/controller.go @@ -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() +} diff --git a/main.go b/main.go index 09152d2..b041b64 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,16 @@ -// main.go 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) } diff --git a/model/estoque.go b/model/estoque.go deleted file mode 100644 index e69de29..0000000 diff --git a/model/inventory.go b/model/inventory.go new file mode 100644 index 0000000..e4732bf --- /dev/null +++ b/model/inventory.go @@ -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() {} diff --git a/view/view.go b/view/view.go index e69de29..f78e6b6 100644 --- a/view/view.go +++ b/view/view.go @@ -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 + `) +}