Advertisement
Kendred

Animal

Mar 25th, 2019
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1.  
  2. public class Project {
  3.  
  4. public static void main(String[] args) {
  5.  
  6. /* Kendred Thompson
  7. * 4th Period
  8. * CS 2
  9. * Animal
  10. */
  11.  
  12. int age;
  13. String name;
  14. Animal bill,tim,bobby ;
  15.  
  16.  
  17. bill = new Animal();
  18. tim = new Animal();
  19. bobby = new Animal();
  20.  
  21. //New Animal Bill
  22. bill.type = "Dog";
  23. bill.color = "Brown";
  24. bill.feet = 8;
  25. bill.canFly = false;
  26. bill.message = "Bark";
  27.  
  28. bill.speak();
  29.  
  30. //New Animal Tim
  31. tim.type = ",Hippo";
  32. tim.color = "Black";
  33. tim.feet = 15;
  34. tim.canFly = false;
  35. tim.message = "Roar";
  36.  
  37. tim.speak();
  38.  
  39. //New Animal Bobby
  40. bobby.type = "Bird";
  41. bobby.color = "Blue";
  42. bobby.feet = 4;
  43. bobby.canFly = true;
  44. bobby.message = "Tweet";
  45.  
  46. bobby.speak();
  47.  
  48.  
  49.  
  50.  
  51. }
  52.  
  53. }
  54.  
  55. class Animal{
  56. String type;
  57. String color;
  58. int feet;
  59. boolean canFly;
  60. String message;
  61. public void speak() {
  62. System.out.println(message);
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement