Advertisement
Guest User

Animal

a guest
Mar 26th, 2019
807
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. //*Mattie Richardson
  2. //* 3/26/19
  3. //* 4th Period
  4. //*Computer Science
  5.  
  6. public class Program {
  7.  
  8. public static void main(String[] args) {
  9. // TODO Auto-generated method stub
  10. int age;
  11. String name;
  12. Animal bob, sue, lily, moe, milly;
  13.  
  14. bob = new Animal (); // Names of animals
  15. sue = new Animal ();
  16. lily = new Animal ();
  17. moe = new Animal ();
  18. milly = new Animal ();
  19.  
  20. //type of animal, features, and noise it makes
  21. bob.type = "cow";
  22. bob.color = "brown";
  23. bob.feet = 4;
  24. bob.canFly = false;
  25. bob.message = "moo";
  26. bob.speak();
  27.  
  28. sue.type = "cat";
  29. sue.color = "black";
  30. sue.feet = 4;
  31. sue.message = "meow";
  32. sue.speak();
  33.  
  34.  
  35. lily.type = "goat";
  36. lily.color = "white";
  37. lily.feet = 4;
  38. lily.canFly = false;
  39. lily.message = "bahaha";
  40. sue.speak();
  41.  
  42. moe.type = "pig";
  43. moe.color = "pink";
  44. moe.feet = 4;
  45. moe.message = "oink";
  46. moe.speak();
  47.  
  48. milly.type = "donkey";
  49. milly.color = "brown";
  50. milly.feet = 4;
  51. milly.message = "e-aah";
  52. milly.speak();
  53.  
  54.  
  55. }
  56. }
  57.  
  58. class Animal {
  59. String type;
  60. String color;
  61. int feet;
  62. boolean canFly;
  63. String message;
  64. public void speak() {
  65. System.out.println(message);
  66. }
  67.  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement