Questions tagged as 'getters-setters'

2
answers

Create a set method for different variables

I want to create a setter for a Character object, where it will modify the attributes String name , int intellect , int strength and int stamina , but what is the best method for if you do that? public class C...
asked by 12.08.2014 / 02:16
2
answers

Methods Getters and Setters [duplicate]

In my course, I'm learning getters that gets "data" and setters , which inserts / modifies. I made my code like this for pen class: <?php class Caneta { public $modelo; private $ponta; public function getModelo(){ retu...
asked by 12.06.2017 / 20:56
1
answer

What happens in real life in a developer environment if the programmer does not encapsulate an attribute? [duplicate]

The programmer John went there and created a Cliente class and the public double saldo attribute and the Sacar() public method as well. What is the problem with leaving the double saldo attribute, what would be t...
asked by 12.05.2017 / 23:36
4
answers

How to construct a class correctly with access methods?

How do I join multiple variables into a single object? How do I get the following code? <?php class Produto { //Atributos var $cpu; var $mb; var $psu; //Getters & Setters function setProduto($produto, $produto1)...
asked by 14.09.2017 / 01:00
2
answers

Eclipse creating getter with prefix is

I created the methods using the Eclipse Getters and Setters command, but when I created the getter of the status Boolean attribute, it was automatically created as isStatus . Should not be created as getStatus ? Could anyon...
asked by 27.09.2017 / 03:54
1
answer

Attribute and private field and getter and setter in object-oriented programming in Java

In object-oriented programming in Java, when I create a particular attribute or private field, without its methods getter and setter do you have to set the attribute to final or do not require? For example: public class...
asked by 03.11.2018 / 12:43
1
answer

Error: "illegal target for variable annotation" using "@property"

Because pygame does not have a library-like function SFML - > View , I'm developing a "camera" format to scroll the screen and preserve the positions of the objects within the general coordinate within the "world". As default for...
asked by 02.10.2018 / 23:53
1
answer

Field handling in the Model before writing to the database (Python + Django)

I am trying to perform a password encryption using Python 3.7 and Django 2.1. Looking at the Python documentation, Django and some answers here in StackOverflow, I came up with the code as follows, however, the password field is written blank...
asked by 31.08.2018 / 13:46
1
answer

Method error Get in a collection

I need to use XML in a university job and I had problems with a Get method I had to implement in a Collection p> After a while I took a look at some websites to do this and found the following tutorial , it has a Contact class as foll...
asked by 02.11.2017 / 00:50
1
answer

Get and Set using PROPERTY - Python3

As a property learning object, I created a small currency converter. See: class converteMoeda(): def __init__(self, dollar=0, real=0): self.dollar = dollar self.real = real def toDollar(self): dollar = self.real/self.dolla...
asked by 28.06.2017 / 16:44