1
2package com.journaldev.inheritance;
3
4public class Animal {
5
6 private boolean vegetarian;
7
8 private String eats;
9
10 private int noOfLegs;
11
12 public Animal(){}
13
14 public Animal(boolean veg, String food, int legs){
15 this.vegetarian = veg;
16 this.eats = food;
17 this.noOfLegs = legs;
18 }
19
20 public boolean isVegetarian() {
21 return vegetarian;
22 }
23
24 public void setVegetarian(boolean vegetarian) {
25 this.vegetarian = vegetarian;
26 }
27
28 public String getEats() {
29 return eats;
30 }
31
32 public void setEats(String eats) {
33 this.eats = eats;
34 }
35
36 public int getNoOfLegs() {
37 return noOfLegs;
38 }
39
40 public void setNoOfLegs(int noOfLegs) {
41 this.noOfLegs = noOfLegs;
42 }
43
44}
45