Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class apples {
- public static void main(String[] args){
- fatty bucky = new fatty();
- food fo = new food();
- food po = new potpie();
- bucky.digest(fo);
- bucky.digest(po);
- }
- }
- public class potpie extends food {
- void eat(){
- System.out.println("this potpie is great");
- }
- }
- public class tuna extends food{
- void eat(){
- System.out.println("this tuna is great");
- }
- }
- abstract public class food {
- void eat(){
- System.out.println("this food is great");
- }
- }
- public class fatty {
- food fo = new food();
- public void digest(food x){
- x.eat();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement