Programming+Club

Programming Club Webpage - Meets Mondays at NOON (11:35 - 12:15)

1. Goals - learn to program in Visual Basic or Java (or both) - develop computer applications (some want to develop Ipod touch or Iphone apps as well - see below) - solve Computer Competition questions

2. Resources - download for Visual Basic [] - introduction to programming in VB [] []

- download the Java Development Kit [] - introduction to Java programming [] []

3. First program in Visual Basic - a review of what most students learn in the first year Create an application that uses two forms. On the first form you can click one of two buttons - the first button displays a messagebox with the words "my name is "; the second button displays form2. Form2 has a "welcome to form two" message, plus buttons to go back to form1 and to end the program. If this works successfully, use an input box on the first form's button to gather the name and then display it in the messagebox. On the second form, create a button that hides all controls other than that button. Ideally, clicking that button again will unhide those buttons. Next steps - display an image in a picturebox, use checkboxes or radio buttons to change form properties, use list/combo boxes for input

4. New Project - creating a working score clock. The goal is to create a score clock for a sport (football, hockey, basketball). You can find good examples if you search google images. The main functions should include: - count down to zero with use of a timer control - stop/start the timer; timer buzzes when it reaches zero; reset the timer for next quarter, period, etc. - increase the score for either team by x points - display image or sound when points are scored - display name of person who scored, was penalized, etc (a banner?) First objective is to create a countdown clock using a timer control. A timer control "agrees" to run through certain lines of code every x milliseconds - so if you want to count down by seconds, you need to set the "interval" to 1000. If the timer control is enabled, it runs, it is disabled (ie: you press stop/pause), the countdown stops. One of the hard things is to get the clock to change from 15:00 to 14:59 - you will need to think for a while about how to solve this. Once you get the countdown clock working, many of the other things should be straight forward. Before you ask me to help with this, sit down with some paper and think about what needs to happen to get a clock to display 15:00, 14:59, 14:58 ... 14:00, 13:59 ... 0:00 sequentially. One thing that I used was two variables - one for minutes and one for seconds; I found that simplified things a bit. I have an file called countdown.exe in my TAKE drive - take\guetter\programmingclub - which is a sample of what I want your clock to do.

5. Good progress on the countdown clock. Next up is to load the score clock with team data - player names and numbers. We don't really want to type in the player information every time someone makes a catch, gets a hit, or scores a goal (or penalty), do we? So we need to be able to do two new things - read information from a text file into your program AND write information from a textbox to a text file. We can accomplish both with the StreamReader and StreamWriter classes in Visual Basic. With a bit of searching, you should be able to find example that implement both of these in file input/output. Here is a summary that I have prepared:

6. Here is the newest program to try out. It allows you to load team data -names and numbers - from a text file. Then you can operate the clock and add events such as goals, assists, and penalties. The key thing is to make most of your program "point and click" - that is, avoid typing. That's why there are already a number of event buttons - and there could probably be a whole lot more. Once your program can load and manipulate data from a text file, the next step is to write the summary to another file.

7. Here is the latest version for you. Designed for baseball, you can load team data from a text file, record events by clicking on the button and player name, and start and stop the timer (probably not useful for baseball). IN ADDITION, you can now save all the data to a text file. This way you can create a record of what happened in the game - a bit like a scoring summary or play by play that you might see on a website or in a newspaper. An extension of this would be to load existing game data into the textbox to review what happened last game; perhaps you could even load this into a textbox on a different form so that you can switch between the two forms - the current one and the past one.

8. I think we're done with the timer/scoreclock for now. This project has taught you valuable programming tricks that will be useful in almost any application you create in the future - things like timers, file input and output, writing to a textbox, writing to a text file. Now we will turn our attention to ARRAYS - an array is a variable that can take on multiple values at the same time. If you have a variable called myWord, you can set its value to "hello"; however if you set the value of myWord to "world" later in the program, your first value is lost. This loss of information is unacceptable. AND we also want to avoid creating unnecessary complexity by creating multiple variables - like myWord1, myWord2...myWord531, etc. This is where arrays come into play. We create a new variable that can take on multiple values - let's call it myWord, and the parentheses designate it as an array. The declaration looks like: Dim myWord(10) as String - which means that we can have up to 10 different values for myWord, as long as we specify which INDEX is which. We can assign values directly, through an inputbox, or from a text file myWord(3) = "welcome" or myWord(1) = InputBox("enter a word ") or we can use a for...next loop to enter multiple values For n = 1 to 5 myWord(n) = InputBox("enter a word ") Next n In this next challenge, you will create a program that asks a user for "n" words. It is probably best to start by asking for a specific number of words - say, FIVE. When they enter the words in an inputbox, the words will also be printed to a textbox After this the user can press a button which will sort the words alphabetically and print them in a second textbox. There are a number of ways to sort a list of things - the easiest way is to use the array.sort method. The following line shows how to sort using the QuickSort method Array.Sort(myWord) Once we master the input and initial printing of the list, we will look at different methods of sorting arrays. Then we will see if we can sort a list that is in a text file and output the sorted list to another text file - see how the same skills keep coming up? Here's a sample of what you might do over the next few Mondays

9. Here is a bit of help for the first part of the array problem. I think you can find all of this on the web, but I like to provide lots of tools so that you can go WAY BEYOND the project requirements.

10. starting in January, we will be learning Python. Here's a summary that I put together You can download python at [] you should select the x86 (32 bit) MSI installer