I'm studying object-oriented programming. I am very fascinated as this new world.
But now a question has arisen. I believe you can help me.
I'm making a Person class, which has the attributes, age, and gender attributes. But this class will have some methods, they are: register () display() delete() edit ()
I would like to know the correct way to pass values to the attributes and in sequence to register in the DB.
PS. To register in the database I am making a class to work only with the bank. This bd class will have the method inserted.
If it is using "Set" and then "Get" to access the value of each attribute?
Use "construct" to assign values?
Or in the register () method it receives the values of the attributes and then passes these values to the attributes:
function cadastrar($nome, $idade, $sexo){
$this->nome = $nome;
$this->idade = $idade;
$this->sexo = $sexo;
}
I believe that my doubt is very simple for experienced developers, but this is a very important question for my study.
And if it does not ask a lot, how can I know the correct time to use GET and SET and when a method should receive "parameters" / attribute values?