How to resolve the algorithm Collections step by step in the Visual FoxPro programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Collections step by step in the Visual FoxPro programming language
Table of Contents
Problem Statement
Collections are abstractions to represent sets of values.
In statically-typed languages, the values are typically of a common data type.
Create a collection, and add a few values to it.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Collections step by step in the Visual FoxPro programming language
Source code in the visual programming language
LOCAL loColl As Collection, o, a1, a2, a3
a1 = CREATEOBJECT("animal", "dog", 4)
a2 = CREATEOBJECT("animal", "chicken", 2)
a3 = CREATEOBJECT("animal", "snake", 0)
loColl = NEWOBJECT("Collection")
loColl.Add(a1)
loColl.Add(a2)
loColl.Add(a3)
FOR EACH o IN loColl FOXOBJECT
? o.Name, o.Legs
ENDFOR
DEFINE CLASS animal As Custom
Legs = 0
PROCEDURE Init(tcName, tnLegs)
THIS.Name = tcName
THIS.Legs = tnLegs
ENDPROC
ENDDEFINE
You may also check:How to resolve the algorithm Floyd's triangle step by step in the Perl programming language
You may also check:How to resolve the algorithm Box the compass step by step in the PureBasic programming language
You may also check:How to resolve the algorithm Convert decimal number to rational step by step in the Nim programming language
You may also check:How to resolve the algorithm Kosaraju step by step in the Racket programming language
You may also check:How to resolve the algorithm Successive prime differences step by step in the jq programming language