Thanks
- Code: Select all Expand view
- #include "fivewin.ch"
function main()
local oPerson1,oPerson2
set date format to "DD/MM/YYYY"
oPerson1 :=Tperson():new("Enas Samir",ctod("17/02/1967"))
oPerson2 :=Tperson():new("Ehab Samir",ctod("20/02/1972"))
msginfo (oPerson1:cName)
msginfo (oPerson1:dDob)
msginfo (oPerson1:age())
msginfo (oPerson1:calculate())
msginfo (oPerson2:cName)
msginfo (oPerson2:dDob)
msginfo (oPerson2:age())
msginfo (oPerson2:calculate())
return nil
create class TPerson
var cName
var dDob
var nAge_years
var nAge_months
var nAge_days
method new
method age
method calculate
endclass
method age
*---------------
::nAge_days:= (date()-::dDob)
return (::nAge_days)
method new(cName,dDob,nAge_years,nAge_months,nAge_days)
*-----------------------------------------------------
default cName:="",dDob:=ctod(" / / "),nAge_years:=0,nAge_months:=0,nAge_days:=0
::cName:=cName
::dDob:=dDob
::nAge_years:=nAge_years
::nAge_months:=nAge_months
::nAge_days:=nAge_days
return self
method calculate()
*-----------------------
::nAge_years:=int (::nAge_days/365)
::nAge_months:=int (::nAge_days/12)
::nAge_days:=::nAge_days%12
return (::nAge_years)