David Eastwick wrote:
now that means the character object i have created is called "mainCharacter" this is ok for now but i wanted to give it the name in the String nameTest
the idea was going to be that for each character i created its name would be added to an arraylist so i could reference each one for use with the background creator part, rather then have have the names of the objects hard coded like that, this seems impossible (nameTest is already defined is the error...well yeah ofcourse it is but i wanted to use the contents of nameTest not nameTest itself...grrrr)
so thats problem 1 naming objects dynamically seems impossible.
Please don't do that! ;) It will make the application harder to work with late on!problem 2 and the most important one (i can get around problem 1 im sure just by making more hardcoded names then i need and setting each one up as needed)
...so the questions on this:
1) is the fact that the gui object is called mainchar and called from the character class which is named in this case mainCharacter meaning that if i was also make a character object called mainCharacter2, its mainchar would be different to mainCharacter's mainchar ? or would they be fighting it out with each other for the same name?
2) why is it pausing at the gui?
3) how do i update the text in text boxes from the program?(yes text boxes are also designed to be written into manually but in this case i want them to be done from the program and the player can edit that later if they choose)
please dont just say learn more java, i realise your not too keen on helping people on here unless they have tried for them selfs first but please believe me i have struggled with this for days before risking coming back here and asking for help, i just dont get why its not working...im stuck
This may sound rude, but I, for one, am not likely to download a random zip file from someone I don't know. Plus, going to another site to download a file which is bound to be a lot of code to sift through is a lot of work. Too much for me to try to do. The best way to get help is to post the code here, but only enough to show the problem.i have attached the source code...yes parts of it are messy but im sure seeing the code is bound to help more then just the snippets i have posted.(ok i cant attach zip files..)
uploaded it to drop box https://www.dropbox.com/s/xgqf5ene2p2th2n/src.zip
Steve
Steve
Steve Luke wrote:That is a lot of code. Like I said, it takes a lot of effort to go through all that code. I asked you to post the relevant code, not all your code. As it is, it is too long to walk through.
Also, when you post code, please avoid writing long lines, as they make the thread really hard to read. I edited your post to remove the long lines. I was going to fix them but there were too many. I don't know if what I did removed key parts of your code or not. Please review the changes. I would suggest editing your post, removing all non-essential code, and putting in all essential code to describe the problem. And please make sure the code you post doesn't have any lines longer than 80 characters. This sounds like a lot of heavy-handedness ("do this, do that, blah blah blah") and I am sorry for that. It isn't meant to be heavy handed. It is just that it is hard to help you with a wall of code and text you have to scroll horizontally through to read. This is meant to help you get answers not enforce 'rules.'
David Eastwick wrote:
i cant see anything in the start() that would cause a loop but then intelij filled that bit in for me (though it wanted to make it a main method...and well i already have one of them)
Steve
Joanne
Steve Luke wrote:
I see why the name doesn't get displayed. In your Character#guiUpdate() method you create a new CharWindow(). You set the value of the text field, then you call start(). Start creates a new CharWindow and it is this new CharWindow which gets displayed. The one you created before is never put into a Frame and never made visible. You need to make sure you are working with just one window here.
i cant see anything in the start() that would cause a loop but then intelij filled that bit in for me (though it wanted to make it a main method...and well i already have one of them)
I see the beginning of one, though I may have hid the part that closes the loop in the //lots of gui code with long line... comment.
In your Character#guiUpdate() method you create a new CharWindow(). Doing that calls the instance initializer (lines 13-18 of CharWindow as displayed in this response) which calls the $$setup$$() method. That setup method is where the gui components are built. Then later on you call setup() which also creates a new CharWindow, triggers the instance initializer, and calls the $$setup$$ method. If that $$setup$$ method ever makes a call to either CharWindow.start(), or Character#character(), or Character#coreStats() or Character#guiUpdate() or CharWindow#refresh()[/tt] then there is some chance of an infinite loop. This is particularly likely if there is some event on the charNameField which might cause one of these other methods to be called.
Haha, keep at it. It takes practice and patience, and a discriminating eye. Look over your code, think about the problem, think about the logical flow, and think about where a problem could possibly be. The problem wasn't likely to be in the Main class, so no need for that. The probably was related to GUI, so no need for the non-gui related stuff in the Character class, etc... I find when I start a post and follow the code to try to locate the relevant (and only relevant) code I need to post, it helps me to actually find the problem. When I am stuck, I often start writing a forum post as a means to solve the problem, and then don't need to actually post it - it just helps me direct my mind to where the problem might be and I end up finding the problem that way.David Eastwick wrote:It seems i cant win, from not enough code to too much lol
Steve
Joanne Neal wrote:Lines 95 - 228 of your character class is not object oriented code. Your Character class should probably be abstract and then you have a separate concrete class for each of the character types (professions) that extends the Character class.
A lot of the code there seems to be the same for all the characters so that code should be in the Character class and any code unique to a particular character type should be in the subclass.
Then instead of passing the profession into the character method (that should really be a constructor) you use it to decide what sort of character to create.
David Eastwick wrote:>.. it was done auto by intellij which set it as public static void main(String[] args), since i already had a main function i renamed it to start,
Steve
David Eastwick wrote:that code takes the stat rolls above it and puts them in order of the profesions requirement, so it looks very similier but the first attribute listed in each class will be different (as the higher number needs to go there) later i will need to make checks to ensure that the number above the min required for that profession.
I dont know how to do abstract classes, i have heard in passing of them but none of the guides or vids i have watched shows what that is, though i will google it now and see what i can learn.
Joanne
Something must be done about this. Let's start by reading this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|