Sunday, February 26, 2012

Midterm Project Done

This was fun, I think the hardest part for me was figuring out what I want to put as a method. As I am a fairly lazy person, if it is a program that I make solo; normally I just do everything in the button clicks when possible and hardly use methods. Although when working with others, I do appreciate methods since it can be easier to piece everything together and troubleshoot. Good luck everyone, if there's any trouble I'd be more than happy to point towards the right direction.

Friday, February 24, 2012

Rock, Paper, Scissors?

So far I have only made the picture boxes and forms for the midterm project, I will probably try to wrap it up by this Sunday to play with it for a week before turn in. Looking forward to making the stuff behind the picturebox work.

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.

Wednesday, February 15, 2012

Chapter 6 More Methods to Mayhem

I knew that this chapter was going to be a good one, after the first page mentioning "Divide and Conquer." Whether it is in programming or networking, that approach tends to work well. In Networking the OSI model is a loosely based Divide and Conquer approach. Working from the simple to the more complex routes to a solution is my favorite way since, if it does happen to just need a simple fix then the problem is resolved before trying complex methods.

Overall, I am glad that the book is introducing these new concepts at a moderate pace. I enjoy working smarter not harder quite a bit. Now with this chapter, I can leave message boxes that can be as annoying as the User Account Control feature that comes standard with Windows Vista. "Are you sure?"....."Are You Really Sure?"....."Are You Really Really Sure." Well now the mayhem will ensue tomorrow as I attempt the Joe's Automotive problem.

Sunday, February 12, 2012

Chapter 5 wrap up

Chapter 5 was a lot easier to digest than chapter 4. The one thing that I will have to get used to is declaring private variables in the form instead of local variables in the buttons. The assignments this time around were about half the code that the workshop selector was. So far having lots of fun with using Visual Studio. Also learned a new way to create a pop up box, its useful for the Random Number Guessing program.

else if (yourNumber == randomNumber)
                    {
                        if (MessageBox.Show("Congratulations, You won. Would you like to play again?", "You win!", MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            // enter your code to restart the random event again here
                        }
                        else
                        {
                            this.Close();
                        }
                    }

Wednesday, February 8, 2012

Chapter 5 Listboxes, Loops, and Storage

This chapter is where I am starting to get a hang of Visual Studio. Listboxes were fun last chapter but now loops are introduced, I remember making simple loops on friend's TI-84 calculators. They didn't do anything other than repeat endlessly since the code was.

label A
disp "Your calculator is broken"
Goto A

That would be a minor prank I would play on friend's when they weren't near their calculator, it would basically endlessly loop. Now I get to learn how to make use of loops other than for pranking purposes. Some of the data storage methods reminded me of the Linux Vi which I hated using since graphical interfaces are common on almost all distributions. I remember having to | to append things to files and the > to create new files. Although a lot has escaped me, some of this chapter brought back some memories of using the Vi editor. After finishing Chapter 5 and the Dice Simulator, I now appreciate the ease of Visual Studio. Instead of having to type everything through notepad and run it to see if it works, the errors at the bottom make it easier to find where to correct the mistake.

Friday, February 3, 2012

Chapter 4 troubles

The color selection program went smoothly, now working on the workshop selector which is giving some problems. I know there has got to be an easier way than turning this thing into a Rude Goldberg Machine. Here is a sample of the code I have so far
        
private void btn_Calculate_Click(object sender, EventArgs e)
        {
            string workshop; // To hold the workshop
            string location;     // To hold the location
            double registrationcost; // To hold the Registration Cost
            double numberofdays; // To hold Number of Days
            double lodgingFees; // To hold Lodging Fees
            double totlodging; // to hold the total Lodging Fees
            double totalcost;  // To hold Total Cost

            if (list_Workshop.SelectedIndex != -1)
            {
                // Get the Workshop Selected
                workshop = list_Workshop.SelectedItem.ToString();

                // Determine the Regeistration Fee and Number of Days
                switch (workshop)
                {
                    case "Handling Stress":
                        registrationcost = 1000;
                        numberofdays = 3;
                        lbl_Registration_Cost.Text = registrationcost.ToString("c");
                        if (list_Location.SelectedIndex != -1)
                        {
                            // Get the Location to Figure out cost
                            location = list_Location.SelectedItem.ToString();

                            // Determine the Location
                            switch (location)
                            {
                                case "Austin":
                                    lodgingFees = 150;
                                    totlodging = lodgingFees * numberofdays;
                                    totalcost = totlodging + registrationcost;
                                    lbl_Lodging_Cost.Text = totlodging.ToString("c");
                                    lbl_Total_Cost.Text = totalcost.ToString("c");
                                    break;
                            }
                        }
                        break;
I was trying to incorporate the switch element, so far it works ok but having to include a switch for each case seems to make this code a lot longer than it should be, any help is appreciated

Wednesday, February 1, 2012

Chapter 4

This chapter is starting to touch on the items that I normally see on the web. Radio buttons, dropdown lists, ListBoxes, and if else if statements. My least favorite thing in programming is if else if statements, mostly since I hate having to find where I made the error when things don't come out right. Its easier to debug when there's only one statement to look into. Finished the color changer program, I still kinda wanted to put a "default" radio button on one of them to revert the color to the normal grey but didn't. I will likely attempt the next program tomorrow night.
this.Close();
Thanks for the help Ken, now I know how to post my code should it give trouble.