How to resolve the algorithm Call an object method step by step in the XBS programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Call an object method step by step in the XBS programming language
Table of Contents
Problem Statement
In object-oriented programming a method is a function associated with a particular class or object. In most forms of object oriented implementations methods can be static, associated with the class itself; or instance, associated with an instance of a class. Show how to call a static or class method, and an instance method of a class.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Call an object method step by step in the XBS programming language
Source code in the xbs programming language
class MyClass {
construct=func(self,Props){
self:Props=Props;
}{Props={}}
GetProp=func(self,Name){
send self.Props[Name];
}
}
set Class = new MyClass with [{Name="MyClass Name"}];
log(Class::GetProp("Name"));
set MyObj = {
a=10;
AddA=func(self,x){
send self.a+x;
};
}
log(MyObj::AddA(2));
You may also check:How to resolve the algorithm Terminal control/Positional read step by step in the BASIC programming language
You may also check:How to resolve the algorithm Split a character string based on change of character step by step in the BaCon programming language
You may also check:How to resolve the algorithm Loop over multiple arrays simultaneously step by step in the Perl programming language
You may also check:How to resolve the algorithm Hello world/Line printer step by step in the COBOL programming language
You may also check:How to resolve the algorithm Ludic numbers step by step in the PL/SQL programming language