Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- // fields
- private String name;
- private short amountOfLegs;
- private String favoriteFood;
- private String sound;
- //properties
- //getter method
- public short getAmountOfLegs()
- {
- return this.amountOfLegs;
- }
- //setter method
- public void setAmountOfLegs(short amountOfLegs)
- {
- this.amountOfLegs = amountOfLegs;
- }
- public String getFavoriteFood()
- {
- return this.favoriteFood;
- }
- public void setFavoriteFood(String favoriteFood)
- {
- this.favoriteFood = favoriteFood;
- }
- public String getSound()
- {
- return this.sound;
- }
- public void setSound(String sound)
- {
- this.sound = sound;
- }
- //constructor
- public Zoogdier()
- {
- this.amountOfLegs = 4;
- this.favoriteFood = "Banaan";
- this.sound = "OehOehAah";
- }
- public Zoogdier(short amountOfLegs, String favoriteFood, String sound)
- {
- this.amountOfLegs = amountOfLegs;
- this.favoriteFood = favoriteFood;
- this.sound = sound;
- }
- //methods
- public void(show)()
- {
- System.out.println("\r\n+++++++++++++++++++++++++++++++++++++++++++++++" +
- "Het aantal benen van dit dier bedraagt: " +this.amountOfLegs + "\r\n" +
- "Het lievelingeten van dit dier is: " +this.favoriteFood + "\r\n" +
- "Het Geluid van dit die is: " + this.sound + "\r\n" +
- "+++++++++++++++++++++++++++++++++++++++++++++");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement