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
0 answers

Override "scrollTop" property and reach value in getter

for a custom scrollbar script I want to override the default scrolltop property. Now I have the problem, that I need to reach the value first to modify it. I use Object.defineProperty( document.documentElement, "scrollTop", { …
Simon
  • 26
  • 4
0
votes
0 answers

javafx chart dynamic multiple entity

I want to create a JavaFx LineChart able to display data from entity class dynamically selected by the user through a combobox. Since the number of entity and their attributes is big and could be change, I want to create this process in a flexible…
Sliver
  • 15
  • 3
0
votes
2 answers

If let clause when getting from NSUserDefaults()

I'm trying to manage a variable like this: var isFinished: Bool { get { return NSUserDefaults.standardUserDefaults().boolForKey("isFinished") } set { NSUserDefaults.standardUserDefaults().setBool(newValue, forKey:…
nontomatic
  • 2,003
  • 2
  • 24
  • 38
0
votes
0 answers

How to use more than one method?

So, I've got to write an invoice for a video store that has a Customer class which takes six attributes, the customer name (string), the street address (string), the city(String), the state(string), the zip code(string), and the telephone number. I…
theshu
  • 15
  • 6
0
votes
1 answer

using method-declared variable in mutators?

Confused on the logic of getting a variable out of a method in a class and using it in a mutator. Edit: here is my code dump My Code: package tests; import java.io.File; import javax.swing.JFileChooser; import javax.swing.JPanel; import…
Tack
  • 121
  • 1
  • 12
0
votes
1 answer

How to access to the raw value of a column when there is a getter?

When there is a getter method on a model class how can I access to its original value? e.g if there is a public function getFooAttribute(){return 4;)} method in the model how to get raw table column value foo?
Handsome Nerd
  • 17,114
  • 22
  • 95
  • 173
0
votes
2 answers

How can I compare two strings and return the lexicographical ordered result using the compareTo method?

I am trying to use compareTo method to compare two different names. After running the first attempt the program terminates immediately without returning anything. How can I modify this compareTo method to compare the names (Name n and Name n2) and…
Peanutcalota
  • 135
  • 1
  • 8
0
votes
3 answers

Combining getters and setters into gettersetters

In terms of "good code", is it acceptable to combine set and get methods into one? Like this: public function dir($dir=null) { if (is_null($dir)) return $this->dir; $this->dir = $dir; }
mattalxndr
  • 9,143
  • 8
  • 56
  • 87
0
votes
2 answers

Issue with trying to fix my printf statement

I need to fix my addQuiz() in my student class. Then, with that class, I pull all the info into my main of prog2. I have everything working except two things. I need to get the formula fixed for my addQuiz() so it totals the amount of points…
T.Brown68
  • 11
  • 1
  • 8
0
votes
2 answers

How to fix my counter and average calculator

I have to create a code that takes user input for grades based on a students name that the user has inputted. The input is to stop when a number less than 0 is inputted and the output should be the student name, the total of all the scores, and the…
theshu
  • 15
  • 6
0
votes
1 answer

Getter returning 0 [Java]

I'm trying to call a Getter from another class, and when I do, it returns and prints 0 every time. It generates a random number when you click the easyButton. After I click that button, it still shows zero after I call the getter with the…
Whatty
  • 79
  • 2
  • 5
0
votes
1 answer

Node.js: How do I write an "asynchronous" getter

I'm new to Node.js, so apologies if my question sounds somehow stupid. Here's what I'm heading for: I'm designing an object of which one property has to be set by database query. For this task I'm requiring promise-mysql. In order to provide the…
Greg
  • 365
  • 1
  • 3
  • 12
0
votes
0 answers

Forbid fields from being used in a child classes java

i'm not sure if this has been asked before. I've got a class that has all of the variables i want to use in my project(30 fields) and i have many other classes based on it, however, i want to disable specific getters in some and specific setters in…
Yash
  • 97
  • 1
  • 11
0
votes
2 answers

Getter functions

I've peeked into many plugins' code (for educational purposes) and basically every one of them (which deals with prototypes), has bunch of functions like this: myMarker.prototype.getPosition = function() { return this.latlng;…
Solo
  • 6,687
  • 7
  • 35
  • 67
0
votes
1 answer

Returning null AFTER a try-catch block

I'm having some trouble understanding the implications of the code in my accessor method below. Eclipse's compiler is requiring that I have a return statement after my try-catch block. Does this mean that my getter method will always return null or…
Her
  • 55
  • 1
  • 9