Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Project {
- public static void main(String[] args) {
- /* Kendred Thompson
- * 4th Period
- * CS 2
- * Animal
- */
- int age;
- String name;
- Animal bill,tim,bobby ;
- bill = new Animal();
- tim = new Animal();
- bobby = new Animal();
- //New Animal Bill
- bill.type = "Dog";
- bill.color = "Brown";
- bill.feet = 8;
- bill.canFly = false;
- bill.message = "Bark";
- bill.speak();
- //New Animal Tim
- tim.type = ",Hippo";
- tim.color = "Black";
- tim.feet = 15;
- tim.canFly = false;
- tim.message = "Roar";
- tim.speak();
- //New Animal Bobby
- bobby.type = "Bird";
- bobby.color = "Blue";
- bobby.feet = 4;
- bobby.canFly = true;
- bobby.message = "Tweet";
- bobby.speak();
- }
- }
- class Animal{
- String type;
- String color;
- int feet;
- boolean canFly;
- String message;
- public void speak() {
- System.out.println(message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement