Java

Moderators: zibadian
Number of threads: 7818
Number of posts: 18218

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Set min/max value for a field Posted by sk37ch on 2 Oct 2012 at 8:58 PM
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;
}



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.