11.07.2015 Views

Soluzioni Esercizi Q2 (pdf, it, 131 KB, 3/23/09)

Soluzioni Esercizi Q2 (pdf, it, 131 KB, 3/23/09)

Soluzioni Esercizi Q2 (pdf, it, 131 KB, 3/23/09)

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

public String specie() {return "un gatto siamese";}}public double quantoCosta() {return 1000.0;};import prog.io.ConsoleOutputManager; importprog.io.ConsoleInputManager; import felini.*;public class MainFelini {// crea un gatto, una tigre, un gatto siamese// e un gatto scozzesepublic static void main(String[] args) {ConsoleOutputManager schermo = new ConsoleOutputManager();ConsoleInputManager tastiera = new ConsoleInputManager();Gatto aureliano = new Gatto("Aureliano");Tigre attila = new Tigre("Attila");Siamese chen = new Siamese("Chen");Scozzese intosh = new Scozzese("Intosh");schermo.println(aureliano.toString());schermo.println(attila.toString());schermo.println(chen.toString());schermo.println(intosh.toString());if (aureliano.possoComprarloCon(200))schermo.println("aureliano si’");elseschermo.println("aureliano no");if (attila.possoComprarloCon(200))schermo.println("attila si’");elseschermo.println("attila no");if (chen.possoComprarloCon(200))schermo.println("chen si’");elseschermo.println("chen no");if (intosh.possoComprarloCon(200))schermo.println("intosh si’");elseschermo.println("intosh no");Gatto g;int n = tastiera.readInt("Immetti un numero: ");if (n % 2 == 0) g = chen;else g = intosh;}schermo.println(g.toString());}17

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!