|
Hmm I was thinking about that program in the shower from what you posted in the other thread, and it looks a bit different from what I thought it would be. When I was thinking of the addition, I was implementing reducing to the lowest terms. This looks like it just multiplies the denominators and leaves it like that. Just curious though, would a feature to keep people from entering fractions that would become complex use the modulus operator?
|
# ¿ Feb 26, 2008 06:58 |
|
|
# ¿ Apr 28, 2024 22:47 |
|
MEAT TREAT posted:It says in the instructions that in the next project they will reduce the fraction to it's lowest terms. For now it's enough that they just keep multiplying the denominator. Yeah, I was jus' sayin.
|
# ¿ Feb 26, 2008 08:55 |
|
This is kind of an odd question because it's about my approach and not a bug in the code. I'm trying to do different projects to learn Java and C, and one of my Java projects was to build a very simple fighting RPG from the ground up as I learn. So tonight I was messing around with getting it to let the player choose which class to play and then shows them the stats when they pick. My question is, how terrible did I go about this? I don't want to get in the habit of a bad approach to different problems. code:
code:
|
# ¿ Mar 11, 2008 03:22 |
|
MEAT TREAT posted:Well your approach isn't very OO yet. I'll try to critique your Player class first. Thanks for the advice, the bit about making a more robust Player object is very helpful. I spent a long time thinking about how to set that up and this clears it up for me This short program was a quick attempt at displaying some information based on user selection using a setup kind of like I would if I was making the actual game. I will be making the game at some point as a larger project, but at the moment I'm just making random pieces to have something to do.
|
# ¿ Mar 11, 2008 04:11 |
|
MEAT TREAT posted:There is Bruce Eckel's Thinking in Java which is available online for free. I've been reading his C++ book and I like it very much. I can't think of any Java tutorials, but frankly you should stay away from them. Tutorials rarely cover any subject in depth so there usefulness is limited. That's the book I use and I'm really pleased with it for being free of charge and all.
|
# ¿ Mar 11, 2008 19:03 |
|
|
# ¿ Apr 28, 2024 22:47 |
|
ynef posted:Depending on your game and what it will support in the future, I'd say that Player should be an abstract class and that you should subclass it with a Fighter and an Archer class. The reason (which may not be valid in your case) is that, for instance, you'll want to give all archers a bonus for ranged weapons or restrict so that fighters can't used crossbows (whatever). If you stick to using conditional statements (if, switch) then you will quickly get a headache trying to code all these rules that will be easily avoided if you just go with the subclassing. Also, the constructor for each class will be very simple and you can still keep the toString() method (which you should use) in the abstract Player class. Adding more types of Player will be ridiculously easy too. That does make sense but I'm a little ashamed to say I had to look up how to create a subclass, since I haven't learned it yet. Thanks for the help!
|
# ¿ Mar 11, 2008 20:14 |