Trying to get into good code habbits
Discussion
Tonsko said:
grumbledoak said:
I don't think your code will 'bleat' - that's the problem! It carries on with an invalid 'tri' for several lines. You should make that impossible, not rely on the caller checking 'valid' before using it.
Ah, I think I see - but how can you tell if it's an invalid triangle before you've added everything up to 180? I suppose you could put some incremental checking when entering angles - e.g. if the first two are less than 60, then the last one has to be greater than 100 or something.Thanks for the if clarification, I didn't think to split it like that.
Tonsko said:
Ahaha! I just copied that in and wasn't paying attention to give the class something to hang around. Duly told
Oh, don't consider yourself 'told', it is a valid criticism. I should have just omitted it the enter angle/check angle/be sarcastic lines. That tendency to do more than you needed to...Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff