Saturday, February 18, 2012

Methods a new tool to be lazy

Finished both problems, I made a HUGE error initially when I did the Joe's Automotive. I forgot that whitespace is a big no no when it comes to naming, it also applies to file names. Methods will likely be a huge help in trouble shooting so that if a logic error occurs, the method just needs to be isolated than the entire predefined method. Calling methods also makes the click action a lot more cleaner looking than a mess that mine usually resembles. If your having trouble with some of the method code, Below is a sample of what I used for Joe's Automotive problem, just remember before you start don't use the apostraphe in the save name or hours of work will go wasted.





private int OilLubeCharges()
        {             
            int total = 0;

            
            if (oilChangeCheckBox.Checked)
            {
                total += 26;              

            }
            if (lubeJobCheckBox.Checked)
            {
                total += 18;
                return total;

            }            
            else
            {
                return total;

            }

        }
Good luck with programming, I found the hospital one to be the easy victory. The Automotive one is a bit of a task but if you have used methods before its a lot of the same as modules in pseudocode.

1 comment:

  1. Congratulations! This chapter was kind of a relief to read after last weeks failures on my part!

    ReplyDelete