Guest User

Untitled

a guest
Jun 25th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. public abstract class Superclass {
  2.  
  3. ...
  4.  
  5. public Superclass(...) {
  6. ... // do stuff before initializing subclass
  7. }
  8.  
  9. protected void dispatch() { //method to be called directly after creating an object
  10. doStuff();
  11. ...
  12. }
  13.  
  14. public abstract void doStuff();
  15. }
  16.  
  17. public class Subclass extends Superclass {
  18.  
  19. ...
  20.  
  21. public Subclass(...) {
  22. super(...); //has to be the first line
  23. ... //assign variables etc.
  24. dispatch(); //has to be called after variables are assigned etc.
  25. }
  26.  
  27. public void doStuff() {
  28. //do stuff with assigned variables etc.
  29. }
  30. }
  31.  
  32. public abstract class Superclass {
  33.  
  34. ...
  35.  
  36. public Superclass(...) {
  37. doStuff();
  38. }
  39.  
  40. public abstract void doStuff();
  41. }
  42.  
  43. public class Subclass extends Superclass {
  44.  
  45. ...
  46.  
  47. public Subclass(...) {
  48. super(...); //has to be the first line
  49. }
  50.  
  51. @Override
  52. public void doStuff() {
  53. //do stuff with assigned variables etc.
  54. }
  55. }
Add Comment
Please, Sign In to add comment