¡GoConqr estrena diseño! Cuéntanos qué te parece.

Mapa mental

COP3502- Objects and Classes

Jeremy Deleon Inglés

COP3502- Objects and Classes

Contenido del mapa

COP3502- Objects and Classes

  1. Objects

    • Attributes & actions
      • Attributes are "fields"
      • Actions are "methods" or "functinos"
        • Define actions that a class's objects can do
          • returnType methodName (listofArguments)
            • double getSalary()
              • getSalary does not accept arguments
            • int negate (int number)
              • accepts an argument
            • Address getAddress()
              • returns an Address object
            • int add(int a, int b)
              • following add method takes two ints and return an int
          • return type of method can be primitive, an object or void.
            • void: method returns nothing.
        • main: provides entry point into an application
          • application usually has many classes and only one of the classes needs to have a main method.
            • public static void main (String[] args)
              • signature of main method
            • java className arg1 arg2 arg3 ...
              • by passing arguments to main when using java to run a class
              • all arguments must be passed as string.
                • java Test 1 safeMode
    • To create, you need "classes"
      • Class name
        • must have at least one constructor to construct an object
          • does not have a return value, even when void
            • constructorName (listof Arguments)tab {enter, tab [constructor body] enter}
              • must have the same name as class
              • can be used to initialize the fields in the object.
                  • with this constructor, you can assign values to age and position
                    • new Employee (20, 90000.00)
        • Class Members- UML allows one to include field types and method signatures
            • method's agrument list is in parenthesis and return type is written after a colon
      • the field
        • Variables that can be primitive or refer to objects.
          • Primitive: Age, salary
          • Objects: such as Address which represents a street address
        • should follow camel naming convention
      • the methods
      • class className { enter, tab [class body] enter, tab }
        • class Employee { int age; double salary; }
      • Class definition: must be saved in a file that has the same name as the class name and extension: Employee class must be saved as Employee.java
          • in UML diagrams, a class contains three parts: 1. top: class name, 2. middle: fields and 3. bottom: methods
      • creating an object from a class
        • "new" keyword is followed by the constructor of the class to be instantiated
          • new Employee () ;
            • Employee employee = new Employee () '
              • declares an object reference with the same type as the object.
              • employee is an object reference of type Employee
        • upon creating an object, you call its methods and access it field by:
          • objectReference.methodName objectReference.fieldName
            • Employee employee = new Employee (} ; employee.age = 24; employee.salary = 50000;
        • null keyword: when reference variable doesnt have a value.
          • Book book; // book is null
          • Book book = null ;
          • test by using":
            • if (book == null) { book = new Book () ; } System.out.printIn(book.title);
  2. Naming & Conventions

    • Pascal: class names capitilize the initial of each word: Employee, DateUtility,. RegularRateCalculator
    • Camel: capiitallize the initia of each word, except for the first one

Imágenes y archivos del mapa

  • COP3502- Objects and Classes
  • COP3502- Objects and Classes
  • COP3502- Objects and Classes

Información

Descripción
Mapa Mental sobre COP3502- Objects and Classes, creado por Jeremy Deleon el 19/05/2019.
Creado por
Jeremy Deleon
Visitas
0
Valoración

Escríbenos

¿Sobre qué es tu mensaje?

¿Qué te parece el nuevo diseño?

¿Te gusta?