Project Overview
Part of the Logic & Flow section of Coddy's GDScript journey. Lesson 71 of 78.
Challenge
EasyIn 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:
- Create the empty dictionary
inventoryand printInventory Management System - In a
while true:loop, read one line and split it at the spaces. The first part is the command. - For the command
exit, printGoodbye!and leave the loop - For the command
show, print theinventorydictionary - 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
1Strings In Depth
String MethodsSearching in StringsReplace and TrimSplit and JoinRecap - Username Check4Dictionaries Part 2
Nested DictionariesArrays of DictionariesMerging DictionariesCopying DictionariesRecap - Frequency Counter2Advanced Decision Making
Match With VariablesMatch GuardsArray PatternsDictionary PatternsMembership ChecksRecap - Command Parser5Contact Book Application
Display MenuAdd Contact8Student Records Manager
Project OverviewAdd Student3Multi-dimensional Arrays
2D Arrays BasicsAccessing 2D Array ElementsNested Loops with 2D ArraysRecap - 2D ArraysJagged ArraysCommon 2D Array PatternsRecap - Game Board6Sets with Dictionaries
What is a Set?Dictionary as a SetAdding and RemovingUnion and IntersectionSet DifferenceRecap - Remove Duplicates9Advanced Data Aggregation
Summing ValuesFinding Minimum and MaximumCustom SortingRecap - Dictionary SorterPractice on your own: Online GDScript compiler