Problem SolvingClock ExampleSoftware DiagramsSource CodeLogic OperatorsConstructorsMethod callsMail System ExampleDebuggingcopyright by Scott Grissom Ch 3 Object Interaction Slide 1 Problem Solving•Complex solutions are often divided into smaller piecesCar engineRegistration processPlumbing systemWriting a book•Abstraction is the ability to ignore details and focus on higher level conceptsStarting a car•Mudularization is the process of dividing large things into smaller partscopyright by Scott Grissom Ch 3 Object Interaction Slide 2 Clock Example•Display 18:42•Consider two pieces that have similar behavior•public class NumberDisplay{int limit;int value;}public class ClockDisplay{NumberDisplay hours;NumberDisplay minutes;}copyright by Scott Grissom Ch 3 Object Interaction Slide 3 Software Diagrams•We are not interested in class diagrams•Object diagrams help us visualize the contents of an objectcopyright by Scott Grissom Ch 3 Object Interaction Slide 4 Source Code•see examples on pages 57 & 63•Primitive Typespre-defined in Javadata onlyint, double, booleancopyright by Scott Grissom Ch 3 Object Interaction Slide 5 Logic Operators•More complex boolean values•and && (both are true)•or || (at least one is true)•not ! (invert)•Examplesif (x > 0 && x <= 10)copyright by Scott Grissom Ch 3 Object Interaction Slide 6 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 parameterscopyright by Scott Grissom Ch 3 Object Interaction Slide 7 Method calls•also called invoking•internal methods only require the method name•external methods require an object AND the method namecopyright by Scott Grissom Ch 3 Object Interaction Slide 8 Mail System Example•Review the source codecopyright by Scott Grissom Ch 3 Object Interaction Slide 9 Debugging•BlueJ allows you to inspect the contents of objects and source code•set a breakpoint•single step through code•step into a
or
We will never post anything without your permission.
Don't have an account? Sign up