|
For each programming question you answer please zip
up your complete project folder including all source code,
project, and solution files. Then, rename the zip file to:
FinalW2008-Q1.zip where Q1 is for question 1, FinalW2008-Q2.zip where Q2
is for question 2, and so forth. Finally, place the zipped file for
each question you answer in your folder on the FTP site. The date/time
of the zip file will be used to determine when you handed it in.
I will use the same grading procedures I have used
on previous programs (this includes looking at properly named classes,
variables, and files; as well as checking for comments in your code).
Important:
Partial credit will be given. If you can't quite figure something out,
leave the code in your program commented out so I can see where you were
going and how close you got. However, make sure the program you hand in
is syntactically correct and will run.
Please answer the following 2 questions (100 points each):
Question 1
Write a program that will use the “Form.Paint” event and a timer to
draw shapes that will “bounce” around the client area of the form. This
program will have three menu items: “About…”, “Add Shape”, and “Exit”.
The “About…” menu item will display a standard about dialog with your
name on it. The “Exit” menu item will terminate the program. The “Add
Shape” menu item will increase the number of bouncing shapes by one.
When the program starts, there should be no shapes
“bouncing” in the window. Each time the “Add Shape” menu item is
selected, a new shape should start “bouncing.” Each new shape should
start with a random position, direction, and speed.
A shape “bounces” by moving through the window
client area with a particular direction and speed. When it reaches the
edge of the window, its direction should reverse, thus “bouncing” off
the edge. Make sure each shape’s direction has both vertical and
horizontal components (i.e. it can move diagonally). You should use the
Graphics class to draw your shape. The shape you choose can be anything
you wish, as long as you use methods of the Graphics class to draw it.
DO NOT use a picture box.
Aside from the requirements to use the Paint event,
a timer, and the Graphics class, you may use any other programming
tool/construct we have discussed in this class to accomplish this.
EXTRA CREDIT (5 Points): Each time you add a shape
to the window, randomly select one of three shapes to “bounce.”
Question 2
Write a program that has three controls on one main form: a single
line text box next to a button labeled “Search”, and a RichTextBox that
will occupy the majority of the form. This program will also have a
menu with four items on it: “Load File”, “Save File”, “About…”, and
“Exit”. This program will read a text file from disk and display the
file in a RichTextBox control. It should also be able to write out any
modified text to a file as well. (You may have to use the help files to
learn about the features of the RichTextBox control). The user should
also be able to enter a regular expression in the text box and show the
results of the search in the RichTextBox when the “Search” button is
pressed.
The “Load File” menu item will be used to display
the OpenFileDialog to request a file to load into the RichTextBox, the
“Save File” menu item will be used to display the SaveFileDialog to
request a file to save any modified text to, the “About…” menu item will
display a standard about dialog, and the “Exit” menu item will terminate
the program.
When the user enters a regular expression in the
text box and clicks the “Search” button, you should perform a search
using a Regex object. You should then display ALL the results by first
clearing any previous searches, and then highlighting all the matches in
the RichTextBox. Text can be highlighted or cleared by using the
following methods of a RichTextBox: first, select the text using the
Select() or SelectAll() methods, second change the text color/background
using the SelectionColor and SelectionBackColor properties, and finally,
clearing the selection by using the Select() method again. You must
research how to properly specify parameters and values for these
properties and methods. |