// Five OOP test — Harbour-compatible CLASS syntax // In Harbour, this would require: #include "hbclass.ch" // In Five, CLASS is native syntax (no preprocessor needed) CLASS Person DATA cName INIT "" DATA nAge INIT 0 METHOD New(cName, nAge) METHOD Greet() METHOD GetInfo() ENDCLASS METHOD New(cName, nAge) CLASS Person ::cName := cName ::nAge := nAge RETURN Self METHOD Greet() CLASS Person ? "Hello, I'm " + ::cName + "!" RETURN Self METHOD GetInfo() CLASS Person RETURN ::cName + " (age: " + Str(::nAge) + ")" // Inheritance test CLASS Employee INHERIT FROM Person DATA cCompany INIT "" DATA nSalary INIT 0 METHOD New(cName, nAge, cCompany, nSalary) METHOD GetInfo() ENDCLASS METHOD New(cName, nAge, cCompany, nSalary) CLASS Employee ::cName := cName ::nAge := nAge ::cCompany := cCompany ::nSalary := nSalary RETURN Self METHOD GetInfo() CLASS Employee RETURN ::cName + " @ " + ::cCompany + " ($" + Str(::nSalary) + ")" FUNCTION Main() LOCAL oPerson, oEmployee ? "=== Five OOP Test ===" ? "" // Create Person oPerson := Person():New("Kim", 30) oPerson:Greet() ? "Info:", oPerson:GetInfo() ? "Name:", oPerson:cName ? "Age:", oPerson:nAge ? "" // Create Employee (inherits Person) oEmployee := Employee():New("Lee", 25, "FiveSoft", 50000) oEmployee:Greet() ? "Info:", oEmployee:GetInfo() ? "Company:", oEmployee:cCompany ? "" ? "OOP test passed!" RETURN NIL