I have a class (Wall) that inherits from Sprite.
Sprite already has width and height properties. But for wall, I need to do some other additional calculations when the properties change (f.e. make sure the new size won't cause it to overlap any other walls).
So, how do I set the width property inherited from the Sprite class from withi...
I'm considering the approaches to write
class MyClass {
@Get
@Set
protected int aValue;
}
and then, automatically, generate get_aValue() and set_AValue() methods for the class.
I've found these possibilities:
1a) At compile time. Use an annotation processor for separately processing MyClass.java, then write a new MyClass.j...
I have a web service that i typed on c#.
I have added a class to this web service. This class has two properties. One of them has getter and setter and the other has just one getter or has private setter.
class ClassName{
public string propGetSet{get;set;}
public string propGet{ get; private set; }
}
class WebSer : WebService{...
Possible Duplicate:
Property and Encapsulation
NEWB Alert!!
I am starting with Android and Java and I am starting to understand it but I am wondering why I should use getters and setters and not just public variables?
I see many people make a private variable and create a get and set method.
What is the idea here?
...
Hi,
Does anyone know how to override Doctrine_Record getters and setters for Relation fields. For example if I have a class Note, Note has many Users, now can I override, for example, this operation Note->Users[] = $user1 ?
Thanks!
...
Should I use getters and setters in C++ or is it better to access class data directly?
...
I have a series of models for my application. Across all these models there are (will be) some 200 or 300 instance variables. The application stores its persistent data on a web-based server (MySQL - but I guess that part doesn't matter). Whenever a model iVar is updated I need to make a call to the server to update the appropriate value...
I have a whole host of models that watch themselves for changes. When a setter is triggered, the observer in the model is called and within that model I make a call to a web server and update information in the web server so it correctly has the data it should.
However, in my call to the web server I can get back an error for anything f...
What's the purpose of getting/setting values when you can just reassign the value? Is it just because you can get/set private variables?
...
I recently started making simple 2D games, and came across a dilemma - to use or not to use getter and setter methods for the x and y positions of an object. It would look clearer if i wouldn't use methods, but access the variables directly instead, and also, many method calls on the object would hurt performance. Also getting and settin...
I have a model class (obviously, it extends Doctrine_Record) that "acts as" a custom template.
I want to get values like this: "echo $record->virtual_field". Is there a way to override the getter method in my custom template to provide a custom response, then either pass on the request to the parent class or not?
In other words, is th...
Okay so I have an assignment where I have to create a class with a set of private properties, which I have done. It gets tricky because I'm fairly new to java programming (or programming in general) and am not very practiced in encapsulation. I have not used getters/setters or constructors before. I understand the getter/setter methods, ...
I have a property like so:
private Decimal _payout;
public Decimal PayoutValue
{
get { return _payout; }
set
{
_payout = value;
//second part of following conditional is an enum
if (Math.Abs(value) > 1 && this.PayoutType == CutType.Percent)
{
_...
Hi Guys,
I have alluded to this issue in my other question, but i think it's worthwhile breaking it out into its own question, as it's not really dependant on the other scenarios i mentioned.
Anyways - onto the Q, don't know if this is possible. Looking for a solution/workaround.
I have a Class Library, with nothing but POCO's:
MyCom...
I initialize a view(Image) through:
Image *myImageView = [[Image alloc]init];
myImageView.myId = randomImageNumber;
[myImageView initWithImage:myImage];
At the Image class I do a Log(LOG1) and get the previously set randomImageNumber.
Later on, in the very same Class, I do a second Log(LOG2).
Why does my second log have no va...
A small debate flared up in a question about protected member variables regarding the use of getters/setters. There are lots of questions already over whether getters/setters are evil, however one particular argument against them, which was posed by two separate individuals with much higher reputation than myself, struck me.
One said...
When dealing with buisness classes, like the typical Customer and Employee classes, is it better to use getters and setters only or to use properties?
I am translating to Delphi (for self learning) some OO examples from java books, in those examples there is always GetName() and SetName(), properties are not used.
Now, I can see that i...
I know I can generate setters and getters for fields in the Eclipse source menu, but I'm very surprised it doesn't offer to replace the direct field accessors with calls to the newly created methods.
Does anyone know how to do this short of manual search and replace?
Thanks!
...
It's the first time I'm trying to use typedef. Admittedly I don't have a very clear idea of what's going on but my understanding was that the values inside typedef get assigned integers starting with 0. I've tried to use them as integers but I get various warnings and errors. One of them is "[NSCFNumber objectForKey:]: unrecognized selec...
Hello there!
I had asked a question similar to this before, but I have a new problem with it so I've reposted part of the question.
I have this before the interface declaration in my MainView.h header.
typedef enum { UNKNOWN, CLEAR, NIGHT_CLEAR, CLOUDY, NIGHT_CLOUDY } Weather;
Then I declared it (in my MainView) like this:
Weather...