Results 1 to 4 of 4
Thread: 4 digit restriction
- 12-27-2010, 03:04 AM #1
Member
- Join Date
- Dec 2010
- Posts
- 2
- Rep Power
- 0
4 digit restriction
Hey guys, I'm new at the forum, hope I'm not doing nothing wrong.
I have this problem, when I tipe in the PIN (that as to be 4 digits) if the 1st digit isn't a zero it's all good, but if is not it asumes that is a shorter number (like: 0321 it assumes that the number tipped in is 321 and dosen't pass in my 4 digit restriction).
I would like to know if some one can help me with this.
thnks
GTM
-
Let's see your code, else we cannot help you fix your error.
- 12-27-2010, 04:11 AM #3
Senior Member
- Join Date
- Dec 2010
- Posts
- 165
- Rep Power
- 3
- 12-28-2010, 02:26 AM #4
Member
- Join Date
- Dec 2010
- Posts
- 2
- Rep Power
- 0
Hey guys, I already did that, but my Input as to be a short, cuse this is a school project and they use a class to test ower classes and in that class they only input shorts as pin, so my code to validate PIN is:
Java Code:public short validarPin(String pinS) { if (pinS.length() !=4) { return 0; } for (int i = 0; i < pinS.length(); i++) { Character a = pinS.charAt(i); if (!a.isDigit(a)) { return 0; } } return (short) Integer.parseInt(pinS); }
Similar Threads
-
eclipse , Access restriction
By miko5054 in forum EclipseReplies: 7Last Post: 07-17-2010, 02:52 PM -
Access Restriction error
By kraut in forum New To JavaReplies: 2Last Post: 06-19-2010, 01:29 AM -
Access Restriction error
By kraut in forum EclipseReplies: 0Last Post: 06-19-2010, 01:07 AM -
Access restriction: Class is not accessible due to restriction on required
By kiranblighty in forum EclipseReplies: 7Last Post: 02-19-2010, 11:03 AM -
Can we lift the images restriction?
By Cyorxamp in forum Suggestions & FeedbackReplies: 30Last Post: 07-01-2008, 08:32 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks