Overview
This laboratory will further familiarize you with visual programming and layout. You'll first create a console application that demonstrates your understanding of arithmetic operators. Then you'll use visual programming to layout a business card application and code the behaviors.
Procedures
- Arithmetic console application
- View a finished release candidate
- Open a new instance of VS08
- New Project... > Console Application > Name it: Product (pay attention to where you save it)
- Declare 4 variables: x, y, z, result
- Prompt the user for the first integer
- When the Enter key is pressed, store the integer into variable x
- Prompt the user for the second integer
- When the Enter key is pressed, store the integer into variable y
- Prompt the user for the third integer
- When the Enter key is pressed, store the integer into variable z
- Then calculate the product of the three numbers and store the product into variable result
- Write out the result
- Write out a message to press the Enter key to continue and wait so the user can see the result
- Test your project
- Business card application
- View a finished release candidate
- Purdue logo --- background image --- icon
- Open a new instance of VS08
- New Project... > Windows Forms Application > Name it: BusinessCard (pay attention to where you save it)
- Layout
- Resize form to 800x400
- Select the form. Add the background image. Add the icon.
- Using the toolbox, drag and drop Labels onto the form, right aligned, for the labels to the left of the textboxes. Use the Properties panel to change the name and text of each one. The name should always start with "lbl" so that anybody reading your code knows that it's a Label (Ex: lblName). Change the background color to transparent.
- Hint: use arrow keys to nudge the controls around the form.
- Using the toolbox, drag and drop Textboxes. Resize the boxes as appropriate. Change the name of each one. The name should always start with "tb" so that anybody reading your code knows that it's a TextBox (Ex: tbName).
- Using the toolbox, drag and drop two Buttons. Change the name and text of each one. Resize the button as appropriate. The name should always start with "btn" (Ex: btnClearCard).
- Add a Panel to the right side of the form. Size it to 380x190. Change the name, start it with pnl (Ex: pnlCard). Change the background color to white.
- Add a PictureBox to the Panel. Size it to 101x35. Change the name, start with picbx (simply using pb would confuse it with ProgressBar). Add the location of the image.
- Add a Label for the department.
- Add a Label for the Name. Change the font to Times, 12pt, Bold. (you will need to change the text also so that you can tell what each Label is for and where it resides on the form)
- Add Labels for the other elements. Change the text to have your own data in it so that you know what each Label is.
- Add two Labels at the top for the version number. Change the text of one to "Version". Change the text of the other to "x". Make them both bold. Change the background color to transparent for both.
- Add a Label at the bottom to make the line. Change AutoSize to False. Change the size to 350x2. Change the background color to Tan.
- Coding
- Right Click one of the buttons > View Code
- Declare and initialize string variables for each of the textbox values, and one int variable for the version number. Comment your code.
- Inside the Constructor, after InitializeComponent, initialize each of the business card Labels to the empty string. Comment your code.
- Go back to the form. Select the first button. In Properties > Events tab > under Actions > Click > Double click in the white space next to "Click"
- Increment the version number variable
- Set the Text of the version number label
- Store the TextBox values into the variables
- Store the variable values into the business card Labels
- Comment your code
- Go back to the form. Select the second button. In Properties > Events tab > under Actions > Click > Double click in the white space next to "Click"
- Set the version number label Text equal to the empty string
- Set the string variables equal to the empty string
- Set the business card labels equal to the empty string
- Note: do not reset the integer value of the version number
- Comment your code
- Test your project
- Finalization
(do this for both applications)
- Build > Configuration Manager
- Change "Active solution configuration" to Release.
- Make sure "Configuration" changes to Release.
- Close
- Rebuild
- Look in <project folder> / bin / Release
- Double click <projectName>.exe
- On your own
- Write the pseudocode for each application in a large comment block at top of the .cs files. Be thorough with your pseudocode. It should be easily readable by anybody (regular english terminology). Essentially, if there's a line of code, there should be a line of pseudocode. You do not have to write pseudocode for the "layout" code.
- Turn in both entire projects.
Grading
Console App |
5 pts |
Business Card App |
10 pts |
Commenting / Pseudocode |
5 pts |
|
|
Total |
20 pts |
|