Advertisement
szilard-dobai

BIA - L2

Feb 24th, 2020
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. Aplicatia 1
  2. father(michael, john).
  3. father(rolmund, rolmund_jr).
  4. father(gion, giongion).
  5. father(john, john_ii).
  6. father(john, john_ii_copie).
  7. father(john_ii, john_iii).
  8. father(taticu_lor, michael).
  9. father(john, rolmund).
  10. child(X,Y) :- father(Y,X).
  11. brother(X,Y) :- father(T,X),father(T,Y),not(X=Y).
  12. nephew(X,Y) :- father(B,X),brother(Y,B).
  13. grandchild(X,Y) :- father(Z,X),father(Y,Z).
  14. predecesor(X,Y) :- father(X,Y);father(X,Z),predecesor(Z,Y).
  15.  
  16.  
  17.  
  18.  
  19. Aplicatia 2
  20. class('Vehicle').
  21. class('EnginePoweredVehicle').
  22. class('HumanPoweredVehicle').
  23. class('Car').
  24. class('Bus').
  25. class('Bicycle').
  26. inherits('EnginePoweredVehicle','Vehicle').
  27. inherits('HumanPoweredVehicle','Vehicle').
  28. inherits('Car','EnginePoweredVehicle').
  29. inherits('Bus','EnginePoweredVehicle').
  30. inherits('Bicycle','HumanPoweredVehicle').
  31. memberVariable('numberOfSeats',protected,int,'Vehicle').
  32. memberVariable('engineCapacity',public,int,'EnginePoweredVehicle').
  33. memberVariable('fuelConsumption',protected,float,'EnginePoweredVehicle').
  34. memberVariable('nameOfOwner',private,'java.lang.String','Car').
  35. memberVariable('nameOfOwnerCompany',private,'java.lang.String','Bus').
  36. memberVariable('numberOfGears',public,int,'Bicycle').
  37.  
  38. brother_2(X,Y) :- inherits(X,T),inherits(Y,T),not(X=Y).
  39. ancestor(X,Y) :- inherits(X,Y);inherits(X,T),ancestor(T,Y).
  40. descendant(X,Y) :- inherits(Y,X);inherits(Y,T),descendant(X,T).
  41. containsPublicMemberVariables(X) :- memberVariable(_,A,_,X),A=public.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement