![]() ?- bassethound::create_dog(boss, 2, Dog). % a couple of (static) dogs as parametric object proxies ![]() % support representing dogs as plain database facts using a parametric object It uses prototypes for simplicity but it still illustrates some key concepts including inheritance, default predicate definitions, static and dynamic objects, and parametric objects. Just an example of one of the possible reimplementations of your sample code in Logtalk. Is there a way to hide the state of the objects i.e to have private variables?įor example I might want to have a way of storing the state has_barked for each dog object, which would be true if it has barked earlier in the program and false otherwise, then change the behaviour of bark/1 based on this.Īlso how would you handle inheritance and overriding methods etc?Īny pointer to readings welcomed. ![]() So I now have two objects with different behaviours based on their own states but at the moment I am storing the state of the objects in the Dog variables where they can be seen by the code in the main program. I understand that in oop you have objects that have behaviours and state. I then make another dog object Dog2 which is a bloodhound and make this also bark. This makes a dog object Dog which is a basset hound and makes it bark 5 times, If I have two files, one defining a class dog and then another one that uses this class to make two dog objects. I am trying to get my head around this, and if it a good way to code. I read somewhere that you can think of modules as objects in Prolog.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |