CSC153, Class 40: Polymorphism Overview: * Questions from previous class * Polymorphism * Interfaces * Example: Prerequisites * Abstract Classes Notes: * Exam 3 distributed * Read chapters 1 and 6 of Bailey * Accepted student visits. * Cool talk today. * Sam screws up: Cryptology in the spring. Why come to Grinnell? * Grinnell needs more Westies * Cool small classes with sarcastic professors who pick on you regularly. * Availability of summer research Unavailability of graduate courses * "Relaxed cultural atmosphere" * Lots of multicultural interaction with the international students Why not come to Grinnell? * Dates * Faculty actually expect you to learn * Students unable to comment thoughtfully on other schools (e.g., biases in favor of Grinnell) ---------------------------------------- Q. How does higher-orderness relate to polymorphism and and inheritance? * The higher-order procedure is effectively polymorphic because it can work on many different kinds of data. * You're changing the basic thing a procedure does. You inherit things about the structure * All three are for reuse Q: What is multiple inheritance? A: When you inherit from more than one object. You gain the characteristics (e.g., fields, methods) of both structures. Q. Why have multiple inheritance? A: For example, you might want to define library book in terms of "Book" and "BorrowableThingymajig" (no, that is not Katherine's term) Q: Why not have multiple inheritance? A: What happens if both superclasses have a method with the same name and parameters? Which do you use? Polymorphism, a close friend to inheritance * Once you know how to do something with a general class of object, you know how to do that thing with related objects Side note: Ocassionally you want to say "These are the capabilities I expect" without specifying the initial versions of those capabilities Solution: Interfaces Like classes but * No fields * No constructors * No bodies to methods We've decided what methods are prerequisites should support. What kinds of prerequisites are there? * Specific courses (e.g., CSC151 is a prereq for CSC152) * Choices of classes (e.g., CSC152 or CSC153 before CSC211) Generalize: One of two prereqs * Specific non-Grinnell courses * Standing (e.g., second year) * Converse prereqs (not XXX) * Permission from the professor (left as an exercise for later) * Combinations of classes (e.g., in order to CS301, you need 152/153 AND MAT218) Coreqs are a lot like prereqs, you just look at one more semester For Monday: * Think about the rest of PrereqOr