Advertisement
IanO-B

Untitled

May 7th, 2020
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. class Dog {
  2. int age;
  3.  
  4. public Dog (int dogsAge) {
  5.  
  6. age = dogsAge;
  7. }
  8.  
  9. public void bark(){
  10. System.out.println("Woof!");
  11. }
  12.  
  13. public void run(int feet) {
  14. System.out.println("Your dog ran "+ feet +" feet!");
  15. }
  16.  
  17. public int getAge(){
  18. return age;
  19. }
  20. public static void main(String[] args) {
  21. Dog spike = new Dog(4);
  22. spike.bark();
  23. spike.run(40);
  24.  
  25. int spikeAge = spike.getAge();
  26. System.out.println(spikeAge);
  27.  
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement