Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Dcoder {
- public static void main(String[] args) {
- Animal cao = new Cachorro();
- Animal peixe = new Peixe();
- Animal pexinho = new Mexilhao();
- cao.mover();
- peixe.mover();
- pexinho.mover();
- }
- public static class Animal { //Classe Basica
- public void mover() {
- System.out.println("Me movi !");
- }
- }
- public static class Cachorro extends Animal { //Copia metodos do animal
- @Override
- public void mover() {
- System.out.println("Me movi ! Mas eu uso 4 patas !");
- }
- }
- public static class Peixe extends Animal { //Copia metodos do animal
- @Override
- public void mover() {
- System.out.println("Me movi ! Mas eu fui nadando !");
- }
- }
- public static class Mexilhao extends Peixe { //Copia metodos de Pexei, e por tabela, de Animal tbm !
- @Override
- public void mover() {
- System.out.println("Eu gosto de me mover em bando!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement