Advertisement
Gauge1417

Untitled

Apr 4th, 2020
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. /*Gauge Smithee
  2. 05-01-20
  3. Animal*/
  4.  
  5. public class MyClass {
  6. public static void main(String args[]) {
  7.  
  8.  
  9.  
  10. Animal Joe, John, Jerry;
  11.  
  12.  
  13. Joe = new Animal(); //Joe the Pig
  14. Joe.type = "pig";
  15. Joe.color = "pink";
  16. Joe.feet = 4;
  17. Joe.hair = true;
  18. Joe.hasWings = false;
  19. Joe.message = "Oink";
  20.  
  21. Joe.speak();
  22.  
  23. John = new Animal(); //John the fish
  24. John.type = "fish";
  25. John.color = "gold";
  26. John.feet = 0;
  27. John.hair = false;
  28. John.hasWings = true;
  29. John.message = "blub";
  30.  
  31. John.speak();
  32.  
  33. Jerry = new Animal(); //Jerry the Goat
  34. Jerry.type = "goat";
  35. Jerry.color = "orange";
  36. Jerry.feet = 6;
  37. Jerry.hair = false;
  38. Jerry.hasWings = true;
  39. Jerry.message = "baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
  40.  
  41. Jerry.speak();
  42.  
  43. }
  44. }
  45.  
  46. class Animal {
  47. String type;
  48. String color;
  49. int feet;
  50. boolean hair;
  51. boolean hasWings;
  52. String message;
  53.  
  54. public void speak() {
  55. System.out.println(message);
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement