Advertisement
JeffGrigg

Kamba Peter Question 7

Nov 28th, 2016
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.60 KB | None | 0 0
  1. public class Dog {
  2.     String name;
  3.     int age;
  4.  
  5.     Dog(String n, int age) {
  6.         name = n;
  7.         this.age = age;
  8.     }
  9.  
  10.     void bark() {
  11.         System.out.println("Woof!");
  12.     }
  13.  
  14.     void wakeTheNeighbors() {
  15.         int i= 50;
  16.         while (i > 0) {
  17.             bark();
  18.             i = i - 1;
  19.         }
  20.     }
  21.  
  22.     public static void main(String[] args) {
  23.         Dog fido = new Dog("Fido", 5);
  24.  
  25.         // Assumed:
  26.         System.out.println("bark()");
  27.         fido.bark();
  28.  
  29.         System.out.println("wakeTheNeighbors()");
  30.         fido.wakeTheNeighbors();
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement