Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Gauge Smithee
- 05-01-20
- Animal*/
- public class MyClass {
- public static void main(String args[]) {
- Animal Joe, John, Jerry;
- Joe = new Animal(); //Joe the Pig
- Joe.type = "pig";
- Joe.color = "pink";
- Joe.feet = 4;
- Joe.hair = true;
- Joe.hasWings = false;
- Joe.message = "Oink";
- Joe.speak();
- John = new Animal(); //John the fish
- John.type = "fish";
- John.color = "gold";
- John.feet = 0;
- John.hair = false;
- John.hasWings = true;
- John.message = "blub";
- John.speak();
- Jerry = new Animal(); //Jerry the Goat
- Jerry.type = "goat";
- Jerry.color = "orange";
- Jerry.feet = 6;
- Jerry.hair = false;
- Jerry.hasWings = true;
- Jerry.message = "baaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
- Jerry.speak();
- }
- }
- class Animal {
- String type;
- String color;
- int feet;
- boolean hair;
- boolean hasWings;
- String message;
- public void speak() {
- System.out.println(message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement