Advertisement
cardel

FLP Ejercicio objetos

Nov 27th, 2021
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. class p1 extends object
  2. field a
  3. field b
  4.  
  5. method initialize(f, g)
  6. begin
  7. set a = f;
  8. set b = g;
  9. 0
  10. end
  11.  
  12. method setValor(p,q)
  13. begin
  14. set a = +(a,p);
  15. set b = +(b,q);
  16. send self getValor(a,b)
  17. end
  18.  
  19. method getValor(p,q)
  20. +(p, +(q,a))
  21.  
  22. class p2 extends p1
  23. field d
  24. method initialize(k, l, m)
  25. begin
  26. super initialize(k,l);
  27. set d = m;
  28. 0
  29. end
  30.  
  31. method getValor(m,n)
  32. +(d, +(m,n))
  33. let
  34. o1 = new p1(1,2)
  35. o2 = new p2(4,5,6)
  36. in
  37. let
  38. a = send o1 setValor(1,4)
  39. b = send o2 setValor(3,2)
  40. in
  41. +(a,b)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement