Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. //Carson Ricketts
  2. public class Program {
  3.  
  4. public static void main(String[] args) {
  5. // age and name of animals
  6. int age;
  7. String name;
  8. Animal phil, gene, rob;
  9.  
  10. // New animal Phil the duck
  11. age = 17;
  12. name = "phil";
  13. phil = new Animal();
  14. phil.type = "duck";
  15. phil.color = "yellow";
  16. phil.feet = 2;
  17. phil.canFly = true;
  18. phil.message = "quack";
  19.  
  20. phil.speak();
  21.  
  22. // New animal Gene the wombat
  23. age = 12;
  24. name = "gene";
  25. gene = new Animal();
  26. gene.type = "wombat";
  27. gene.color = "grey";
  28. gene.feet = 4;
  29. gene.canFly = false;
  30. gene.message = "squeal";
  31.  
  32. gene.speak();
  33.  
  34. // New animal rob the snake
  35. age = 3;
  36. name = "rob";
  37. rob = new Animal();
  38. rob.type = "snake";
  39. rob.color = "green";
  40. rob.feet = 0;
  41. rob.canFly = false;
  42. rob.message = "hisss";
  43.  
  44. rob.speak();
  45.  
  46.  
  47. }
  48.  
  49. }
  50. // Code to make program run
  51. class Animal{
  52. String type;
  53. String color;
  54. int feet;
  55. boolean canFly;
  56. String message;
  57.  
  58. public void speak() {
  59. System.out.println(message);
  60. }
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement