04.04.2013 Views

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

Processing: Creative Coding and Computational Art

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.

Ogre subclass<br />

class Ogre extends Creature{<br />

// overriden method within Creature superclass<br />

void castSpell(){<br />

println("I miss ya donkey");<br />

}<br />

/* required method implementation<br />

from abstract Creature superclass */<br />

String getCreatureName(){<br />

return "I am an an Ogre";<br />

}<br />

}<br />

// Elf subclass<br />

class Elf extends Creature implements Archer{<br />

// overriden method within Creature superclass<br />

void castSpell(){<br />

println("Gotta make the cookies");<br />

}<br />

/* required method implementation<br />

from interface Archer */<br />

void shoot(){<br />

println("Elf shoots");<br />

}<br />

/* required method implementation<br />

from abstract Creature superclass */<br />

String getCreatureName(){<br />

return "I am an an Elf";<br />

}<br />

}<br />

// Knight subclass<br />

class Knight extends Creature implements Archer{<br />

// overriden method within Creature superclass<br />

void castSpell(){<br />

println("Mirror, mirror on thw wall...");<br />

}<br />

/* required method implementation<br />

from interface Archer */<br />

void shoot(){<br />

println("Knight shoots");<br />

}<br />

OBJECT-ORIENTED PROGRAMMING<br />

335<br />

8

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

Saved successfully!

Ooh no, something went wrong!