The Big Programming Thread - Page 519
| Forum Index > General Forum |
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. | ||
|
nunez
Norway4003 Posts
| ||
|
Ben...
Canada3485 Posts
That hour and a half of frustration before remembering that tidbit was my equivalent of a blood sacrifice to the linker gods (it only broke when using object files and trying to link them). Luckily, today I solved a different linking issue in that same makefile in about 5 minutes. The linker gods shine brightly upon me today. I shall mark this day in the history books. | ||
|
ZenithM
France15952 Posts
On September 16 2014 08:08 RoyGBiv_13 wrote: Compilers are one-file-in-one-file-out programs, how hard could they be? Linkers are the true deity. + Show Spoiler + Our Linker in binary, +x be thy permissions. Your ELF, COFF, and PE come, your allocation be done, on our binary as it is in yours. Give us libraries for our executable, and forgive us our bugs, as we have forgiven our compiler. And lead us not into warnings, but deliver us from errors. Amen Take unto Thee, this list of blessed libraries, modules, and symbol tables. Let it be to Your eternal satisfaction that all instances of symbols are singularly defined, and that no COMMONS exist. Amen. Haha that's good. And so true. | ||
|
Epishade
United States2267 Posts
I am creating an instance of a class in my Driver using a while loop that asks the user if they want to continue running the program and entering in different values again. I need to have a running total of some variables (cost subtotals etc) that are calculated when the class is created. Each time I rerun the loop though, the subtotals reset to zero. Here's my while-loop in my driver right now. + Show Spoiler + while (goAgain == 'Y' || goAgain == 'y') { System.out.print ("Enter item price: "); price = input.nextDouble(); System.out.print ("Enter percent discount: "); percentDiscount = input.nextDouble(); System.out.print ("Enter tax rate: "); TAX_RATE = input.nextDouble(); new ItemSale(price, percentDiscount, TAX_RATE); System.out.print ("Would you like to add more items? Y or N: "); goAgain = input.next().charAt(0); } Does the recreation of ItemSale in each loop reset all of the values back to zero (or whatever I set the values to in the constructor) that were in there from the previous iteration? For example, I used TAX_RATE to find the tax value of an item in a method in ItemSale. I wanted to keep a running total of the tax value of all of the items that the user wants to add, but each repeat, the running total goes back to zero. If it does, I'm not entirely sure how to proceed from here then. If it doesn't, then I guess I'm stuck somewhere else and can't find where to fix it. | ||
|
icystorage
Jollibee19350 Posts
| ||
|
Furikawari
France2522 Posts
new ItemSale(price, percentDiscount, TAX_RATE); creates a new object. It creates a new reference to a new object, meaning, it uses free spots in the memory. So yes, basically all members of this object are reinitialized in each iteration. Here you have to problems: design and how to use objects. I'm not sure of the way you want to handle your sum of taxes, but the object that will contain this value must be declared prior to the entrance in the while in order to be known in each iteration of the while. Probably that you want to save your ItemSale. So you should have something like : ItemSale currentItemSale = new ItemSale(price, percentDiscount, TAX_RATE); itemSales.add(currenItemSale); With itemSales being a list declared before you enter the while loop. Another word: by convention, variables in upper letters are constants. So TAXE_RATE should be taxRate in your case, as it is specified for each item. It's not an error, just a convention used by most java programmers. HTH! | ||
|
Epishade
United States2267 Posts
On September 16 2014 16:01 icystorage wrote: maybe because you are instantiating ItemSale over and over again? where do you store the running total? what does ItemSale() look like? I was storing running total in the methods inside ItemSale(), which is why I suppose they were getting wiped each time I reran through the loop. | ||
|
Blisse
Canada3710 Posts
had a rule EXECS : ${EXEC1} ${EXEC2} ${EXEC3} ${EXEC0} EXEC2 always fails cause there are no files with the name was wondering for 3 hours why EXEC0 never built.... i felt so dumb when i realized -____-" | ||
|
Ben...
Canada3485 Posts
On September 16 2014 22:34 Blisse wrote: ughhh stupid makefiles had a rule EXECS : ${EXEC1} ${EXEC2} ${EXEC3} ${EXEC0} EXEC2 always fails cause there are no files with the name was wondering for 3 hours why EXEC0 never built.... i felt so dumb when i realized -____-" That's not so bad. I spent multiple hours trying to get a custom library to work in a makefile. What it ended up being: LIB=-L/.../doc/... when it was supposed to be: LIB=-L/.../docs/... I didn't notice for a fairly long time. Added the s and everything compiled perfectly. Felt like a complete idiot for the rest of the day. That led to my other situation in my previous post. The library would be found correctly when making the object file but not when linking. Ended up burning like 3 hours on a tiny thing. Was not impressed with myself. | ||
|
RoyGBiv_13
United States1275 Posts
My company has its own custom project file format. It makes entirely too much sense. Especially when compared to make. Also, you only need to get bitten by -L, -l, and #include <> versus "" once before you know what to look for, which is nice. It's guaranteed you're going to bump into it at least once though. Linker directive files are for wizards. Each one I look at I find a new piece of syntax I never knew existed. There is no specification for them, and every linker has it's own syntactical sugar. + Show Spoiler + from a piece of documentation I read today: Calling this function on the same Task twice will result in undesirable behavior. No joke, it crashed the entire system... | ||
|
nunez
Norway4003 Posts
oh, how it pleases the eye. today i got a part time job offer from the company i programmed for this summer. they had told me they would probably offer one, but it took longer time than i expected. i made the logical conclusion over a week ago: they took an actual look at the code i wrote and burned every computer that had compiled it. this confidence boost brings me back into balance. of course it might be a trap, they want me to come in so they can finish the cleansing for good. | ||
|
Cyx.
Canada806 Posts
On September 17 2014 08:06 nunez wrote: i consequently use #include<>. oh, how it pleases the eye. today i got a part time job offer from the company i programmed for this summer. they had told me they would probably offer one, but it took longer time than i expected. i made the logical conclusion over a week ago: they took an actual look at the code i wrote and burned every computer that had compiled it. this confidence boost brings me back into balance. of course it might be a trap, they want me to come in so they can finish the cleansing for good. Haha this is exactly how I felt last week when my summer company did the same... now I'm fixing a bunch of bugs in all the stuff I wrote this summer rofl | ||
|
nunez
Norway4003 Posts
| ||
|
Cyx.
Canada806 Posts
On September 17 2014 09:37 nunez wrote: that does not bode well! awh it's okay, that's just for the first week or so =P but prepare to get a few bug reports if you wrote anything big near the end of the summer rofl | ||
|
Millitron
United States2611 Posts
On September 17 2014 01:41 Ben... wrote: That's not so bad. I spent multiple hours trying to get a custom library to work in a makefile. What it ended up being: LIB=-L/.../doc/... when it was supposed to be: LIB=-L/.../docs/... I didn't notice for a fairly long time. Added the s and everything compiled perfectly. Felt like a complete idiot for the rest of the day. That led to my other situation in my previous post. The library would be found correctly when making the object file but not when linking. Ended up burning like 3 hours on a tiny thing. Was not impressed with myself. If we're talking about annoying problems, I got a dilly. I had to make a sudoku game for a User Interfaces course. It was a semester-long project in which each chapter would end with us implementing the chapter topic in the game. For instance, an early one was to split the game up into an MVC-style program. Anyways, it is the night before the assignment is due, and I am putting what I think is the finishing touches on. 11PM rolls around, and suddenly this program which was nearly complete and running great starts crashing constantly. 7 hours later, and it's 6AM and I find the problem. Somewhere along the way, I had lost a close-parenthesis, and eclipse neglected to tell me. But now I find a few more minor problems and end up working on it until 30 minutes before I present. tl;dr: One missed parenthesis almost cost me a semester long project. | ||
|
Blisse
Canada3710 Posts
+ Show Spoiler + ![]() | ||
|
Millitron
United States2611 Posts
| ||
|
icystorage
Jollibee19350 Posts
| ||
|
amazingxkcd
GRAND OLD AMERICA16375 Posts
If i could get some tips or tricks for designing this stuff would be appreciated since I never done any web dev before (I'm a soft dev, test guy) | ||
|
ZenithM
France15952 Posts
On September 17 2014 11:20 Blisse wrote: haha, maybe not on one parenthesis level, but this was a makefile error. worked on my machine, did not compile on submission servers. deadline was 11:59 :p can you feel the pain hahaha + Show Spoiler + ![]() Been there, done that haha. Good (and terrifying) stuff. | ||
| ||
![[image loading]](http://i.imgur.com/vRdrj2x.jpg)