/* Author: Ryan Peters
Description: Sorts post into 1 of 5 categories based on dimensions and weight. The categories are letter, large letter, packet, parcel and neither.
I'm using these two methods to model turning the package around, like if you stand a book up, or let it lie flat.
The sorting method is as follows
So when I enter 100 180 4 25
I receive the message, this item is a large letter... It should swap the length and width (180 100 4 25) and return "This item is a latter."
Any advice would be greatly appreciated.
I've needed a lot of help with this one, I've tried to put a lot of what I've learned into this one program and all the little things have been catching me out so I'd just like to give a huge thanks to everybody who has helped me get this far!
Also, rather than posting disjoint code snippets, if you post an SSCCE(←click), with just enough code to completely demonstrate the problem in one coherent piece, and nothing not directly related to the problem (for instance, hardcode values, rather than taking user input), it will make it easier for folks here to understand what you're trying to do and where you're stuck.
@Rykurex Peters: Despite the rather more direct answer that Ivan has provided, I strongly encourage you to add the println()s anyway, see for yourself what's happening, and see if you conclusion matches what he told you. This investigative technique is one you'll use constantly throughout your programming career, whether it's just a semester or two academically or a lifetime as a professional.
Aj Prieto wrote:You're not calling the switchLength or switchThickness methods, which is why it won't switch the values.
Since he just posted a couple of disjointed code snippets, we don't know that for sure. But if that is the problem, then he'll see it when he adds the println() calls I suggested. If he puts them in those switch methods, then when he sees those print statements not showing up, he'll know the methods are not being called.
I've added a call to the two switch methods and I will recompile it and update you guys straight away.
Thanks for the tip on adding braces for if statements no matter what though, I'm sure that will come in handy someday without me even knowing it!
I've also tried the print statements along the way, I can see how this will be very useful in time to come when I move further in to loops and such
EDIT: It works !!
I also had to move the switch methods into the user class to keep them private, but everything is working well now
I keep on forgetting that I have to call the method in the main method as the method will not just activate by itself >.<
Rykurex Peters wrote:I won't quote people directly but I've read all of the responses, I guess it's just mate who would hate looking at all of the code, but I see now how relevant it is >.<
Note that we don't generally want all the code, and that's not what I was asking for here. Just all the relevant code. Often this means you'll have to create a completely separate program to strip out all the stuff that's not directly related to the problem and hardcode values that would have come from those other parts.
Glad you got it sorted out though!
Without subsidies, chem-ag food costs four times more than organic. Or this tiny ad:
ScroogeXHTML 7.2 - RTF to HTML5 / XHTML converterhttps://coderanch.com/t/692027/ScroogeXHTML-RTF-HTML-XHTML-converter