Android Developers documentation:
Known direct subclasses: ... TextView...
but if you click on TextView:
Shouldn't it be shown like:
Anyway, I'm thinking if it suits me and how to implement such a thing without having inheritance, i.e. using objects.
For example:
Will it be useful (and difficult) to use objects instead of classes? Will using objects involve duplicating many methods?
P.S. ["Playing around"]
Um... to create a new Manager I have to create before all its "parent objects"!
First a Man, then a Worker, then an Employee and only after this long list of actions I can create a Manager!
And to get (log) the name of the Manager? clsManager could have a property:
but this would imply having to have a similar property in clsEmployee:
and so on. Or clsManager should have an instance of all its parent objects, objEmployee, objWorker, objMan.
What a headache ?
EDIT: no, this is "enough", in clsManager, to get its name:
[Attached a test but B4J, sorry]
Known direct subclasses: ... TextView...
but if you click on TextView:
Shouldn't it be shown like:
B4X:
Java.lang.Object
... Object.View
...View.TextView
Anyway, I'm thinking if it suits me and how to implement such a thing without having inheritance, i.e. using objects.
For example:
B4X:
clsMan
... clsWorker
... ... clsEmployee
... ... ... clsManager
P.S. ["Playing around"]
Um... to create a new Manager I have to create before all its "parent objects"!
First a Man, then a Worker, then an Employee and only after this long list of actions I can create a Manager!
B4X:
Dim Man As clsMan
Dim Worker As clsWorker
Dim Employee As clsEmployee
Dim Manager As clsManager
Man.Initialize("Erel")
Worker.Initialize(Man)
Employee.Initialize(Worker)
Manager.Initialize(Employee)
Log(Manager.Name)
And to get (log) the name of the Manager? clsManager could have a property:
B4X:
Public Sub getName As String
Return mEmployee.Name
End Sub
B4X:
Public Sub getName As String
Return mWorker.Name
End Sub
What a headache ?
EDIT: no, this is "enough", in clsManager, to get its name:
B4X:
Public Sub getName As String
Return mEmployee.Worker.Man.Name
End Sub
[Attached a test but B4J, sorry]
Attachments
Last edited: