CSC152 2005S, Class 21: Object-oriented design and Interfaces Admin: * Presents * Lecture/discussion style class * How did Friday go? * Questions on the exam? Overview: * OOD, reviewed * Motivating example * Basic classes * Representing operations * Implementing Surround * Using interfaces Questions on Javadoc * How do I insert linebreaks?
* Now that we know it, do you expect us to use it? YES * Now that we've seen pre and postconditions, do you expect us to use them? YES * Even on the exam? IT WOULD BE NICE Questions on the Exam? * Should we turn in our tester (if we write one) for problem 2? YES * Should we turn in our fraction class, since we have to update it, for problem 3? YES Object-oriented programming: * Programs are built from objects, which combine data and capabilities * We look for three key ideas in doing oop + Encapsulation + Inheritance + Polymorphism Sam's silly motivating example: Laying out text on the screen ****************************************************************** * FFFFF ourscore and seven years ago our forefathers and mothers * * F did something which I now forget because it's much later * * FFF * F * F Description: * An object that represents the big F (SimpleTextBlock) * An object that represents the "ourscore ... later" * The two objects are placed side-by-side * The result is surrounded by stars Our goal: Build objects and "other stuff" to make it easier to do things like the above "programatically" What simple classes might we build to contribute to our "text layout" program? * TextLine (line or part of a line like a string, but may have different capabilities) * print, given a PrintWriter * Or "convert to String", so that we can print it using a PrintWriter * Determine the width * SimpleTextBlock * Determine the width * Determine the number of lines * Get one line What advanced operations might we include? * Emphasize * Surround with asterisks * Reformat a single line onto many lines, given a particular width * Break a sentence into lines containing certain number of words * Search