Botre Posted September 10, 2014 Share Posted September 10, 2014 (edited) public static int rndmInt(boolean allowMinimum, int minimum, int maximum, boolean allowMaximum) { int min = minimum + (allowMinimum ? 0 : 1); int max = maximum + (allowMaximum ? 1 : 0); return new Random().nextInt(max - min) + min; } ^it's "exclusive" not "exlusive". Edited September 10, 2014 by Botrepreneur Link to comment Share on other sites More sharing options...
thepecher Posted September 10, 2014 Share Posted September 10, 2014 Wouldn't MethodProvider.random(int,int) do the same. If you don't want to allow max or min, you reduce the interval? Link to comment Share on other sites More sharing options...
Botre Posted September 10, 2014 Author Share Posted September 10, 2014 Wouldn't MethodProvider.random(int,int) do the same. If you don't want to allow max or min, you reduce the interval? Yep, this is to help people understand some of the mechanics behind such methods. I prefer booleans to include / exclude limits, not the most type-friendly way to go, but improves the readability imo. 1 Link to comment Share on other sites More sharing options...
Swizzbeat Posted September 10, 2014 Share Posted September 10, 2014 If you really want people to learn from this you probably should use the words exclusive and inclusive instead of allowed. Link to comment Share on other sites More sharing options...
Mysteryy Posted September 10, 2014 Share Posted September 10, 2014 If you really want people to learn from this you probably should use the words exclusive and inclusive instead of allowed. If you look at his comments, they say inclusive and exclusive. The way he did it is better than saying only inclusive and exclusive, because now people can look at his comments and make the connection to the method itsself. From that they can get that allow means inclusive and allow' would be non inclusive. 1 Link to comment Share on other sites More sharing options...
Botre Posted September 10, 2014 Author Share Posted September 10, 2014 If you really want people to learn from this you probably should use the words exclusive and inclusive instead of allowed. I actually used includeMin and excludeMax as argument names first. But then I though "allow" would be more comprehensible. Meh, not a huge difference anyways. Link to comment Share on other sites More sharing options...
Swizzbeat Posted September 10, 2014 Share Posted September 10, 2014 If you look at his comments, they say inclusive and exclusive. The way he did it is better than saying only inclusive and exclusive, because now people can look at his comments and make the connection to the method itsself. From that they can get that allow means inclusive and allow' would be non inclusive.How are people supposed to learn if you have to dumb down simple vocab words? Link to comment Share on other sites More sharing options...
Botre Posted September 10, 2014 Author Share Posted September 10, 2014 How are people supposed to learn if you have to dumb down simple vocab words? Dumb -> less dumb -> almost smart -> smart. You have to start somewhere ^^ Link to comment Share on other sites More sharing options...
Swizzbeat Posted September 10, 2014 Share Posted September 10, 2014 Dumb -> less dumb -> almost smart -> smart. You have to start somewhere ^^ An autistic kid has basic knowledge of simple prefixes. Link to comment Share on other sites More sharing options...
Dog_ Posted September 10, 2014 Share Posted September 10, 2014 An autistic kid has basic knowledge of simple prefixes.Questionable. 1 Link to comment Share on other sites More sharing options...
Mysteryy Posted September 10, 2014 Share Posted September 10, 2014 How are people supposed to learn if you have to dumb down simple vocab words? By your logic we don't even need dictionaries. Why should we ever look at a dictionary? Why not just magically know every word ever naturally? We need to learn somewhere, typically by making relations, which is exactly what he did. Link to comment Share on other sites More sharing options...
Swizzbeat Posted September 10, 2014 Share Posted September 10, 2014 Questionable. asexual gtfo By your logic we don't even need dictionaries. Why should we ever look at a dictionary? Why not just magically know every word ever naturally? We need to learn somewhere, typically by making relations, which is exactly what he did. That is probably the worst comparison to this topic you could have ever came up with. Jeez, all I do is make a logical suggestion and everyone goes ape shit. Link to comment Share on other sites More sharing options...
Dog_ Posted September 10, 2014 Share Posted September 10, 2014 asexual gtfo That is probably the worst comparison to this topic you could have ever came up with. Jeez, all I do is make a logical suggestion and everyone goes ape shit. @wyd 2 Link to comment Share on other sites More sharing options...