Kenny Kuchera

Greenhorn
+ Follow
since Mar 16, 2010
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Kenny Kuchera

@ rob: Exactly... but generateID() is an abstract method that is overrided in weapons,... So for armor it should return the ID so i can assign it to the field ID...
Thanks!

Kenny
13 years ago
@Rob, it doesnt get a generated id, the thing is i would like to use that method to return the id if its a valid one(a prime). Since in item i do ID = generateID() and ID is final(and must be) Thanks in advance!!

Kenny
13 years ago
@Yogesh

Thats a pretty good idea though. the problem is that if that constructor would be used to make a weapon or another item then i cant do give it an id.. and this still leaves me with the problem i gotta be able to check that it is a prime number and if not make it one. so i wanted in generateID() to be able to get the ID that was used with the creation of a new armor and check if it is prime and if not make it so, this is not that important though. the key here is that i need to be able to have access to a variable that contains the ID before the super() is executed. Thanks a lot for the help!!

Kenny
13 years ago
Its behind the scenes for everything EXCEPT the class armor, so they all inherit from item and they are all generated except for the one from armor that one is given by the user. Thanks in advance for any advice!
13 years ago
Thanks, but this isn't allowed though (it's a project we got in school), see the actual ID is final and has to be generated "behind the screens" in other words without the user knowing anything about it, for all the classes inheriting from item, except for Armor. So item can't have an argument. Thanks anyway! any idea's are always greatly appreciated!

Kenny
13 years ago
Hi, I was wondering if it is possible to initialize a field as argument?
What i want to do:
Armor:


a method that just returns the long ID

See the reason i cant do it in the constructor itself is because it inherits from a class called Items, and in a method in items i need the ID, Since a super() has to be first line i have a problem.

What i thought about doing:

making wantedID a field in armor and:

this doesnt work though but if somehow i can do it before the constructor of item is executed my problem would be solved


Item:


So it comes down to, i need a method generateID() in my class armor that just returns the wantedID

Any help would be greatly appreciated! Thanks in advance

Kenny
13 years ago

Ulf Dittmer wrote:

Is this restriction only for Public class?


That's quite easy to test, no?



True, but I do think its the same for non-public classes.
14 years ago
Thanks a lot for the reply! that will make it a lot more efficient! thanks!
14 years ago
hey, thanks for quick reply. i forgot to say though that a-z A-Z is always allowed. now i came up with following code which works perfect for what i need it to do


the only problem with this is that there is something like \'{0,2} wich would be more efficient cause lets say that I want three ' to be allowed or two @'s then the code would get really long cause i'd always have to add '? or @? so now my question is if there is anyway to make it so i can set the limit to lets say ten ' in the entire string with \'{0,10}? Thanks a lot in advance!
14 years ago