Menu
CoddyTech

Project Overview

Part of the Logic & Flow section of Coddy's GDScript journey. Lesson 71 of 78.

challenge icon

Challenge

Easy

In this project you build an Inventory Management System for a store: it adds items, updates their stock, checks what is available and sells items with a revenue report.

The store's data lives in a dictionary named inventory. Each key is an item name, and each value is another dictionary with two keys: "price" (a float) and "stock" (an int). In this step, start with an empty dictionary.

The program is driven by commands, one per line of input. Write it like this:

  1. Create the empty dictionary inventory and print Inventory Management System
  2. In a while true: loop, read one line and split it at the spaces. The first part is the command.
  3. For the command exit, print Goodbye! and leave the loop
  4. For the command show, print the inventory dictionary
  5. For any other command, print Unknown command

For the commands show, sell and exit, the output is:

Inventory Management System
{  }
Unknown command
Goodbye!

Every test ends with the command exit.

Try it yourself

extends Node

func _ready():
	# Create the inventory, print the title and read the commands
	pass

All lessons in Logic & Flow

Practice on your own: Online GDScript compiler