CSCI 157 - topics

In Ch6 we started WRITING OUR OWN (non-WindowController) CLASSES.

That meant we had to put together a lot of info. And picked up some ... complication.

Ch 6 - Writing non-WC CLASSES

  1. we pay (even more!) attention to instance variables

    They are the memory/storage area for individual objects of the class. They are what gets mutated and accessed!

  2. we had to write methods & constructors and learn how to PASS PARAMETERS

    That meant we had to learn to differentiate between formal parameters and actual parameters

  3. Writing a method with a method header became a thing.
    privacy modifiers
    - public, private, protected
    return type
    - choose one: void or ... anything else!
    name_of_method
    - easy! though we should be predictable and coding standards indicate should be ... verb-like.
    parameter list
    - a comma separated list of formal parameters listed by type and method-local name MUST follow name_of_method; even if the list is empty().

    public void move (double dx, double dy)

  4. Writing a constructor header also became a thing.
    privacy modifiers
    same as above
    parameter list
    same as above

     
    return type
    DOESN'T HAVE ONE explicitly because...
    name_of_constructor
    DOESN'T HAVE ONE explicitly because...

    public FunnyFace (double x, double y, DrawingCanvas dc)

  5. overloading a method(or constructor!)
      two methods (or constructors!)in the same class with same name but parameter lists with parameter lists that differ in number an/or type of parameters.

      (Notice _identifiers of parameters is NOT how they are differentiated!)

    VALID Examples

    public FunnyFace (double x, double y, DrawingCanvas dc)
    public FunnyFace (double x, double y, double radius, DrawingCanvas dc)
    public FunnyFace (Location p, DrawingCanvas dc)
    public FunnyFace (Location p, double radius, DrawingCanvas dc)

     

    INVALID Examples

    public void move (double dx, double dy)
    public void move (double ownWidth, double ownHeight)


Left over topics from various chapters...