Forums

ForumsProgramming Forum

Java Shenanigans

Posted Oct 17, '11 at 6:46pm

Graellic

Graellic

4 posts

That is correct so that you understand you may receive a &quotossible loss of precision" error or possibly some other error (e.g. some type of data overflow) with, using your example:

number = otherNumber;

since you are demoting this way and promoting in your example. However, with your final input being String, I don't know of any reason that you would ever need to demote.

The only reason I would, possibly, overload the method would be if you were to have a generic "utility" class of your own design that you import regularly for some of your more favorite functions. Then, the next time you're need to take something to hex, you may be wanting to come from another data type. Of course, this is up to your individual programming style and, truthfully, would probably apply more to some other type of function that may have a wider incoming selection of variables. For example, a data reading class accepting a File as an argument that brings in any data type and converts it to ASCII, etc.

For this, though, it sounds like you've got it worked out.

lol. I'm now up to 4 posts on these forums... all in this thread.

 

Posted Oct 17, '11 at 10:27pm

snowguy13

snowguy13

2,172 posts

@Graellic

Yeah! Thanks for your help!

I just realized that my code from before:

int number;
long otherNumber;

otherNumber = number;


would result in an error because number has not yet been initialized. xD I can picture the error now:

"variable 'number' may not have been initialized"


:P

=====================================================================

In other news, I have about four more player actions to program into my game, and then it's on to the enemy's intelligence! > I finally made it to the fun part!
 

Posted Oct 19, '11 at 2:19pm

snowguy13

snowguy13

2,172 posts

I have one more player action left to program, and then I can begin working on the enemy's intelligence. This is where things will get tricky (but very fun).

How I think I want to go through with this is by first making a list of what is most important to the enemy's survival (ie, first check if health is low and attempt to counteract that). Also, I have considered adding natures for enemies; ie, aggressive (will attack more) or wise (will heal before other actions).

Does anyone have any thoughts or suggestions?

 

Posted Oct 23, '11 at 10:12pm

snowguy13

snowguy13

2,172 posts

Hmm... Now that I think about this, I could have the enemy's intelligence keep track of the average damage it receives each turn, the average damage its physical attacks do, the average damage its magical attacks do, the number of times the player raise his/her stats, the number of times the player lowers the enemy stats, etc.

I could use things like that to get the enemy to actually, in a way, *think* about what it should be doing. For example, if the player attacks a lot (average damage taken per turn would be higher), I could make the enemy adopt a more aggressive strategy, or perhaps a more healing-based one as well.

Again, does anyone have any suggestions (especially if you want to offer a suggestion for an if-statement hierarchy)?

 

Posted Oct 28, '11 at 6:07pm

snowguy13

snowguy13

2,172 posts

I think I'm going to take a break from the battle game for now; my interest seems to have bottomed-out for now...

So, instead, I'm going to learn more about Java GUI's; including JFrames, JPanels, JButtons, etc.

However, just now (literally five minutes ago), I had an idea to try a one-directional motion simulator involving hills. What I mean is to simulate where an object will be over time on a straight track that may contain hills (so it would only deal with one direction of motion, but varying speeds). I have an idea to start this, using a slope field map and my recently groomed understanding of acceleration and motion.

 

Posted Nov 3, '11 at 10:32pm

snowguy13

snowguy13

2,172 posts

I just created this pretty awesome math class! It finds the factors and prime factorization of two numbers, and their greatest common factor and least common multiple!

The code for it is here!

I'm reeeeaaallly excited about this!

 

Posted Nov 15, '11 at 11:30am

Smokeshow

Smokeshow

71 posts

I dont understand nothing :O

 

Posted Nov 20, '11 at 9:53pm

snowguy13

snowguy13

2,172 posts

I dont understand nothing :O

Of the code I linked to above? If you want an explanation, you can copy and paste a part of it into a post (please not all of it at once; that's a lot of code), and I'll explain it.
 

Posted Nov 28, '11 at 9:33pm

snowguy13

snowguy13

2,172 posts

I haven't posted here in quite a while! :P

But now I'm working on a large project that is (so far) coming along quite nicely!

I'm creating a tournament manager for the NCAA March Madness prediction tournament my family does (mostly everyone creates his/her own "bracket" predicting who will win, and a correct prediction of a game gets that person points; person with most points at end wins pool of money).

Right now I've created part of the main GUI, the new tournament GUI, and some other objects. The program also creates its own data files and reads them (right now just for simple settings like asking the user if he/she really wants to exit when he/she clicks "Exit", and the last open tournament).

So my task at the moment is finishing some object programming so that I can make a tournament object. This object will display the bracket and manage most of the tournament.

I'm so excited with how much progress I'm making!!!

 
Reply to Java Shenanigans

You must be logged in to post a reply!