Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class Human
- {
- ...
- public abstract void goPee();
- }
- /**
- *"Human" è una classe astratta per la quale il metodo "goPee" non può trovare un'applicazione concreta.
- *Non tiene infatti conto delle differenze fisiologiche e comportamentali tra uomo e donna.
- /*
- public class Male extends Human
- {
- ...
- @Override
- public void goPee()
- {
- System.out.println("Stand Up");
- }
- }
- public class Female extends Human
- {
- ...
- @Override
- public void goPee()
- {
- System.out.println("Sit Down");
- }
- }
- public static void main(String[] args){
- ArrayList<Human> group = new ArrayList<Human>();
- group.add(new Male());
- group.add(new Female());
- // ... add more...
- // tell the class to take a pee break
- for (Human person : group) person.goPee();
- }
- /**L'esecuzione di person.goPee() restituirebbe un risultato del tipo:
- *Stand Up
- *Sit Down
- *...
- /*
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement