Difference between revisions of "Module:Test1234"

From Wiki Knowledge Base | Teltonika GPS
 
Line 11: Line 11:
 
   self.breadth = breadth or 0
 
   self.breadth = breadth or 0
 
   self.area = length*breadth;
 
   self.area = length*breadth;
   return o
+
   return self.area
 
end
 
end
  

Latest revision as of 15:06, 29 November 2018


-- Meta class
Rectangle = {area = 0, length = 0, breadth = 0}

-- Derived class method new

function Rectangle:new (o,length,breadth)
   o = o or {}
   setmetatable(o, self)
   self.__index = self
   self.length = length or 0
   self.breadth = breadth or 0
   self.area = length*breadth;
   return self.area
end

-- Derived class method printArea

function Rectangle:printArea ()
   return self.area
end