Set min/max value for a field - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Set min/max value for a field

sk37chsk37ch Posts: 1Member
Is it possible to set a minimum and maximum possible value for an integer field? Can I do it within the contructor? I have googled it but everything I find seems for more advanced and technical than what I am looking for.

I am trying to set a minimum of "0" and a maximum of "10" for the field "happiness".
public Tux()
x = 0;
y = 1;
z = 5;
texture = "models/tux/tux.png";
model = "models/tux/tux.obj";

//Additional fields added for "Peppy"
hunger = 5;
happiness = 5;
thirst = 0;
Sign In or Register to comment.