 
                                
                    
                        Re: Java
                        Posted by Crono on 
    Sat Mar 18th 2006 at 1:33am
                     
                    
                 
                
            
            
                
    
                    
                             Crono
                            Crono
            
                        super admin
     
            6628 posts
        700 snarkmarks
        Registered: 
    Dec 19th 2003
                            Location: Oregon, USA
             
                
                        You should look into switch statements.
If you're already in the current class don't you use the "this" pointer? Or just call the func ... I mean method, directly.
You could say "this.formula();" or "formula();" instead of "MappingFormula.formula();" ?
I'm not sure, since I haven't used Java in ... 2 years ... Monkey works with it on a daily basis though (I think), he could help if he actually still lurks around.
But, from the look of it, it looks like scope is the issue ...
I'm a C/C++ guy myself. Java is nice for multiplatform stuff though. Oh, and people who refuse to manage their own memory :rolleyes:
                                            
                        Blame it on Microsoft, God does.
                                    
             
        
            
            
                                     
                                
                    
                        Re: Java
                        Posted by Crono on 
    Sat Mar 18th 2006 at 3:41am
                     
                    
                 
                
            
            
                
    
                    
                             Crono
                            Crono
            
                        super admin
     
            6628 posts
        700 snarkmarks
        Registered: 
    Dec 19th 2003
                            Location: Oregon, USA
             
                
                        Obsolete? No, they're for the purpose of replacing many if-else statements that check one variable against several values.
More efficient, easier to program and read.
Postfix incrementing is bad (for general purpose), but people use that more than pre-fix :\
                                            
                        Blame it on Microsoft, God does.
                                    
             
        
            
            
                                     
                                
                    
                        Re: Java
                        Posted by Crono on 
    Sat Mar 18th 2006 at 10:26pm
                     
                    
                        
                        Posted 
    2006-03-18 10:26pm
                     
                 
                
            
            
                
    
                    
                             Crono
                            Crono
            
                        super admin
     
            6628 posts
        700 snarkmarks
        Registered: 
    Dec 19th 2003
                            Location: Oregon, USA
             
                
                        Windows, your program doesn't give a decent output, that's what I was pointing out. Anything below 10240 and the program gives 0 as the price. :rolleyes: If it's a "price" as implying it's something that'd cost you something valuable, you want to round up. As for the way you wrote the program, it was just a little sloppy, that's all. There's not really a way you could know that if you're just starting out unless someone tells you.
Did you try changing the method call, since that's been suggested about 5 times now?
Reno, no, that's exactly right.
If you want to know why is makes three copies, do some research into operator overloading. (Since to overload the operator's you have to have the same declaration structure)
Note*: The function uses pass by value and return by value and makes a copy in the function body too!
Also, the crappy thing is, if it's a higher language, there's a chance it DOESN'T copy to a register, but memory.
                                            
                        Blame it on Microsoft, God does.
                                    
             
        
            
            
                                     
                                
                    
                        Re: Java
                        Posted by Orpheus on 
    Sat Mar 18th 2006 at 11:51pm
                     
                    
                        
                        Posted 
    2006-03-18 11:51pm
                     
                 
                
            
            
                
    
                    
                             Orpheus
                            Orpheus
            
                        member
     
            13860 posts
        2024 snarkmarks
        Registered: 
    Aug 26th 2001
                    Occupation: Long Haul Trucking
                            Location: Long Oklahoma - USA
             
                
                        I wish that I knew more about Java than simply drinking the stuff. It would be nice to know how to take a good cup of Jo and making a web page outa the stuff.
You guys are simply amazing. :eek:
                                            
                        
The best things in life, aren't things.
                                    
             
        
            
            
                                     
                                
                    
                        Re: Java
                        Posted by Crono on 
    Sun Mar 19th 2006 at 12:09am
                     
                    
                        
                        Posted 
    2006-03-19 12:09am
                     
                 
                
            
            
                
    
                    
                             Crono
                            Crono
            
                        super admin
     
            6628 posts
        700 snarkmarks
        Registered: 
    Dec 19th 2003
                            Location: Oregon, USA
             
                
                        Orph, that's JavaScript and even then it doesn't "make" the page, it just allows you to do some gritty calculations. That's a different language anyway, this is Java, it's a system programming language, not a browser programming language :smile:
Also, take into consideration that pretty much everyone who's responded has some educational and/or hobbyist background in this. (I should post up some Asm programs ... if I can find them) I'm working on some SML stuff now too for compilers. (It compiles the Mini-Java language, which is an sub-set of Java, just not everything ... since that'd be a pain in the ass. I don't know if we're writing the garbage collector and stuff next term or not, but it was mentioned)
Windows, There's a step that hasn't been done then. I could be wrong, but don't you have to have the JRE running for java programs to work? Is that running? Or do you have to define something in the program to make it run? I don't particularly remember, however, but just some things to look at.
Anyway, what error does it give once you take out the "MappingFormula" part? Same error? More information you give, the easier someone could recognize the problem and help you out.
                                            
                        Blame it on Microsoft, God does.
                                    
             
        
            
            
                                     
                                
                    
                        Re: Java
                        Posted by fraggard on 
    Sun Mar 19th 2006 at 3:36am
                     
                    
                 
                
            
            
                
    
            1110 posts
        220 snarkmarks
        Registered: 
    Jul 8th 2002
                    Occupation: Student
                            Location: Bangalore, India
             
                
                        Win98: What does your CLASSPATH contain? The last entry in the
environment variable CLASSPATH should be for the current directory,
i.e. "." .
Just to check, run the program with
c:\>java -classpath . MappingFormula
If it works then you know where the problem is.