O GoConqr está de visual novo! Conte para nós o que você achou.

Mapa mental

public class Car(): (Blueprint/Template)

Edward Bill Inglês

Conteúdo do mapa

public class Car(): (Blueprint/Template)

  1. Fields (Attributes): color, name, number of tires

    • Fields can be public or private
  2. Methods (Actions): Methods can be private, protected, or public. ReturnType (void, primitive type, or object)

    • Getters: getColor, getName, getNumberOfTires
      • This method returns a primitive or an object. Also, it does not accept any argument(s)
    • Setters: setName, setColor, setNumberOfTires
      • This method helps to set method arguments to the class fields using the "this" keyword e.g color = this.color.
    • Other methods: run(), brake()
  3. Constructor (Most important): Used to construct the class object in the driver program. Must be at least one.

    • No-arg constructor (Initialization constructor): does not accept any arguments and initializes the fields in the class
    • Constructor with arguments: Accepts arguments and is used to initialize the class fields
  4. Driver program: In the main program, to use the class, Car, as an object, we create an instance of that class (define it) e.g private Car car (we do this outside and above the main). Since the variable, car, is null we need to use the "new" keyword to construct the object. E,g in main, we do=> car = new Car("blue", Benz, 4). To use the method created in the class, Car, we do this=> car.setName("V7"). This will change the name of the car which was instantiated as "Benz". Thus, if we print car.getName(), we get V7 in the console

Informações

Descrição
Mapa Mental sobre public class Car(): (Blueprint/Template), criado por Edward Bill em 12-09-2020.
Criado por
Edward Bill
Visualizações
0
Avaliação

Fale Conosco

Sobre o que é sua mensagem?

O que você acha do novo visual?

Você gostou?