Questions tagged [getter]

A getter is a public accessor method, used in object-oriented programming, which returns the value associated with a private member of a class.

A getter is public method, used in object-oriented programming, which returns the value associated with a private member of a class. A getter often refers to the get portion of a property. The getter method may perform other tasks such as validation, but is usually considered non-mutating.

1882 questions
0
votes
1 answer

Symfony - Getter and Setter missing

I have a basic controller where an object should be updated: (I hardcoded the id for testing) namespace AppBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use…
Creative crypter
  • 1,348
  • 6
  • 30
  • 67
0
votes
1 answer

Symfony 2 getter returns error: {"__initializer__":{},"__cloner__":{},"__isInitialized__":false}

I'm having a problem with a getter created by Symfony 2 while trying to generate a JSON. The getter is getNcomptador(), which returns a kind of an error. Function called to create the JSON: public function llistatLecturesAction($db){ $sessio =…
ohup
  • 11
  • 4
0
votes
1 answer

When I use a method called movePosition() on a "player object", it changes the x position for all other objects made from that class

I'd like to set the velocity of the player object to augment its x position by two, and I'l also like to set the velocity of the entity object to augment its x position by three. But, at the end of every tick both x positions for both objects…
0
votes
1 answer

Getter worked but returns an error when i turn it into a const

So I'm currently developping a so and a dll file to handle the files of my users (basically a filesystem). I have two classes, one is FileData (representing a single file), and a FileList (which as the name suggests is a list of FileDatas). Here is…
0
votes
2 answers

How to use int in 2 methods

I have created an int called Strength in a method. Looks a bit like this: public void Stats(){ int Strength = (int) Math.ceil(Math.random()*10); int Stamina = (int) Math.ceil(Math.random()*10); int Speed = (int)…
nbray
  • 81
  • 5
0
votes
2 answers

Multiple getter methods for different amount of parameters

I know you can have multiple constructors, for example: public Game (int num, boolean truth) { } public Game (int num) { this(num, false); } Can the same be done for getter methods? So I can have two parameters, but if the user only wants to…
James Mitchell
  • 2,387
  • 4
  • 29
  • 59
0
votes
2 answers

Getting the target when using bindable getter in flex

I have the following files: model.as clint.mxml in clint.mxml I have the following line: ... in the model.as I have a getter: [bindable(event="locationXChanged")) function get locationX () : int { return…
Clint Feher
  • 51
  • 1
  • 3
0
votes
1 answer

How to decorate getter function that implements read-only property?

I'd like to create flexible logic that allows operating with complex wrapper objects via interfaces. But sometimes these objects can be just an instance of simple object that they are "wrapping". Something like this: interface ICoords { var…
meps
  • 579
  • 2
  • 17
0
votes
1 answer

Why do using a getter for an object returns NullPointerException

I'm trying to use a getter for an object, in order to store the information of that object in another object. Yet, just by using the getter, it immediately returns a NullPointerException. This is the code of the class that has the object as a field…
GFV450
  • 111
  • 1
  • 11
0
votes
2 answers

Java Storing Rank and Suit as Strings

I'm still new to programming and am trying to figure out this part of a project: The Card class represents a playing card with a rank and suit. Insert instance data that will store rank and suit as String objects and define a constructor that…
Nguyen13
  • 15
  • 4
0
votes
2 answers

Getters / Setters / Assigning one object to another

I have a class called Chair. I have a view controller that contains an object of type Chair. At some point, I am trying to assign my viewcontrollers instance to another instance of a Chair object as such: [viewcontroller setChair: thisChair]; My…
Lance
  • 1,161
  • 3
  • 12
  • 26
0
votes
1 answer

Node getter doesn't return setter value

EDIT: I believe the problem is in adding nodes. When I start the fetch the nodes they come back null. I believe it is because head is not get setting as the impl.getHeadNode() == null never occurs. Constructor: public CashDonationLinkedListImpl()…
0
votes
1 answer

getText() returning empty string in outside class using JavaFX

I'm attempting to create a simple text editor in JavaFX but have stumbled upon a problem. My code that is supposed to save the current text can't get that text from the TextArea in my Scene. When I call getText() on the TextArea I just get back an…
Kennedal
  • 23
  • 7
0
votes
3 answers

How to print value out loop java

can anybody help me? I have code: public class Demo { String lineValue; public void execute () {String a[] = new String[] { "ping google.com", "ping youtube.com" }; for (int i = 0; i < a.length; i++) { try { …
Orion
  • 59
  • 2
  • 10
0
votes
3 answers

accesing static variable in php

i have a simple case of class with static variable and a get function all compile ok but at run time i am getting this error [Sun Jul 25 03:57:07 2010] [error] [client 127.0.0.1] PHP Fatal error: Undefined class constant 'TYPE' in ..... for the…
shay
  • 1,317
  • 4
  • 23
  • 35