Project Overview
Part of the Logic & Flow section of Coddy's GDScript journey. Lesson 42 of 78.
Challenge
EasyThe Student Records Manager keeps data about students: their age, their grades and the courses they take. Over the next steps you will add students, add grades, check enrollment, calculate averages, list the students of a course and find the top students.
The program reads commands, one per line, such as add Alice 20 Math Physics or grade Alice 90. In this step, set up the records and the command loop:
- At the top level of the script, between
extends Nodeandfunc _ready():, declare an empty dictionary:var student_records := {}. A variable declared there, outside every function, can be used by every function of the script, which the next steps need. - In
_ready(), start awhile true:loop. In each iteration, read one line, split it at the spaces and turn the result into an array:var parts := Array(OS.read_string_from_stdin().split(" ", false)) - Use
match parts:with two array patterns:["show"]: printstudent_records["exit"]: printGoodbye!and leave the loop withbreak
Ignore every other command for now. Every test ends with exit. For the commands
show
exitthe output is:
{ }
Goodbye!Try it yourself
extends Node
# Declare student_records here
func _ready():
# Read commands in a loop until exit
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