Skip to content

Instantly share code, notes, and snippets.

@IEnoobong
Created May 27, 2017 16:31
Show Gist options
  • Save IEnoobong/3c6797931b34090fa01cd4256e6de535 to your computer and use it in GitHub Desktop.
Save IEnoobong/3c6797931b34090fa01cd4256e6de535 to your computer and use it in GitHub Desktop.
Learning Classes and Objects at ALC 4.0
/**
*
* @author ienoobong
*/
public class Animal {
private int hands;
private int legs;
private int eyes;
public Animal (int hands, int legs, int eyes){
}
public void walk(int legs){
}
public void see (int eyes){
}
public String see (int eyes, boolean open){
if ( eyes >= 1 && open){
return "Boys";
}
return "nothing";
}
}
/**
*
* @author ienoobong
*/
public class Demo1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Monkey monkey = new Monkey(1, 3, 4);
System.out.println("I see " + monkey.see(2, false));
monkey.eat("Rice");
}
/**
*
* @author ienoobong
*/
public class Monkey extends Animal {
public Monkey(int hands, int legs, int eyes) {
super(hands, legs, eyes);
}
public void eat(String food){
if ("banana".equals(food)){
System.out.println("I love this");
}
else {
System.out.println("You can do better");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment