11/30: CS100M lecture 27 -- the end and new beginnings +-----------------------------------------------------------------------------+ polymorphism: - a use of inheritance - can treat a subclass as if it were an object of superclass - why? superclasses supposedly "more general" than subclasses +-----------------------------------------------------------------------------+ class A {} class B extends A {} public class poly { public static void main(String[] args) { // superclass type can connect to any subclass // (super more general than sub) A a1 = new A(); B b1 = new B(); a1 = b1; // subclass type shouldn't really connect to any superclas // (sub less general than super) A a2 = new A(); B b2 = new B(); // b2 = (B) a2; // compiles, but won't run } } +-----------------------------------------------------------------------------+ args: + command line arguments + strings input to program > java +-----------------------------------------------------------------------------+ Course summary: + Programming is automated problem solving - problem - algorithm (human language) - code (computer language) - solution + Process - figure out human approach - break things down - think writing + Writing - brainstorm - outline - code - refine + Suggestions - sooner to computer, longer it takes - use commenting to avoid starting - use writing process - outline on computer - convert outline to comments - convert comments to code - presto! you have program + Overall issues - modeling: attributes -> variables behaviors -> functions/methods things -> classes (vars+meths) - redundancy: avoid! conditions for choices loops for automated repetition functions for repeated code classes to group vars and methods packages/toolboxes to collect classes/functions drivers to control function/script/class interaction - code reuse write general code create own collections +-----------------------------------------------------------------------------+ CS211: + modulus operator: % + casting: (type) + abstract classes + practice inheritance + practice sorting + beyond CS100: I/O, interfaces, GUIs, data structures +-----------------------------------------------------------------------------+ Drums + Dr. Dave shows off his djembe' technique + has nothing to do with CS100M, unless you want to start modeling wave functions of drum heads, which happens to be a hot research topic +-----------------------------------------------------------------------------+