Guest User

Untitled

a guest
Jun 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. /*
  2. * Example of an abstract class
  3. * An abstract class can have instance variables and methods of both static and normal nature
  4. * Can have a constructur, but that cannot be called directly, as abstract classes cannot be instantiated
  5. * It should contain one abstract method (which is just method signature, to be implemented later in child classes extending it
  6. *
  7. */
  8. public abstract class HealthAbstract {
  9.  
  10. public HealthAbstract() {
  11. System.debug('Welcome to the abstract class of Health');
  12. }
  13.  
  14. public Integer weight;
  15.  
  16. //define a method to set current weight of different people (different classes in this example)
  17. public void setWeight(Integer wt) {
  18. weight = wt;
  19. }
  20.  
  21. //define a method to get the weight from other classes
  22. public Integer getWeight() {
  23. if(weight != null) {
  24. return weight;
  25. } else {
  26. return null;
  27. }
  28. }
  29.  
  30. //define an abstract method which needs to be implemented in all child classes extending this
  31. public abstract String workoutIntensity(Integer BicepsSize, Integer ChestSize);
  32.  
  33. }
Add Comment
Please, Sign In to add comment