Skip to content

Instantly share code, notes, and snippets.

@skiabox skiabox/
Created Oct 11, 2016

What would you like to do?
Animal abstract class
package com.skiabox.java_apps2;
* Created by administrator on 09/10/2016.
public abstract class Animal {
private String picture;
private Food food;
private int hunger;
private int[][] boundaries;
private int locationX;
private int locationY;
//getters and setters
public String getPicture() {
return picture;
public void setPicture(String picture) {
this.picture = picture;
public Food getFood() {
return food;
public void setFood(Food food) { = food;
public int getHunger() {
return hunger;
public void setHunger(int hunger) {
this.hunger = hunger;
public int[][] getBoundaries() {
return boundaries;
public void setBoundaries(int[][] boundaries) {
this.boundaries = boundaries;
public int getLocationX() {
return locationX;
public void setLocationX(int locationX) {
this.locationX = locationX;
public int getLocationY() {
return locationY;
public void setLocationY(int locationY) {
this.locationY = locationY;
//common methods
public void sleep()
System.out.println("The animal sleeps");
//methods that must be implemented below the hierarchy
public void roam()
System.out.println("The animal is roaming");
public abstract void makeNoise();
public abstract void eat();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.