Problem Solving Complex solutions are often divided into
Problem Solving • Complex solutions are often divided into smaller pieces Car engine Registration process Plumbing system Writing a book • Abstraction is the ability to ignore details and focus on higher level concepts Starting a car • Mudularization is the process of dividing large things into smaller parts copyright by Scott Grissom 1
Clock Example • Display 18: 42 • Consider two pieces that have similar behavior • public class Number. Display{ int limit; int value; } public class Clock. Display{ Number. Display hours; Number. Display minutes; } copyright by Scott Grissom 2
Software Diagrams • We are not interested in class diagrams • Object diagrams help us visualize the contents of an object copyright by Scott Grissom 3
Source Code • see examples on pages 57 & 63 • Primitive Types pre-defined in Java data only int, double, boolean copyright by Scott Grissom 4
Logic Operators • • • More complex boolean values and && (both are true) or || (at least one is true) not ! (invert) Examples if (x > 0 && x <= 10) copyright by Scott Grissom 5
Constructors • • • sets the object to its initial state no return type name is same as class name default constructor has no parameters sometimes have parameters overloaded methods share the same name but have different parameters copyright by Scott Grissom 6
Method calls • also called invoking • internal methods only require the method name • external methods require an object AND the method name copyright by Scott Grissom 7
Mail System Example • Review the source code copyright by Scott Grissom 8
Debugging • Blue. J allows you to inspect the contents of objects and source code • set a breakpoint • single step through code • step into a method • continue copyright by Scott Grissom 9
- Slides: 9