COP4226, Assignment 1
Due Monday, February 6 at 6 PM.
Zip your entire project and upload it on the web. Exclude all of the
Debug and Release directories.
Submitting
Homework Online.
Zip file of executable, control library dll, and config file:
Zip File
You are to write a program that you might have done in your first programming
class! You are to calculate the distance that an object will travel on different
planets. How hard can this be? You are to create a GUI front end that has
three input boxes, a radio group, a combo box, a checkbox and a few buttons.
There will also be an error provider for validating input, a user control
library, and another form for information about the project.
The formula to calculate the distance traveled is
distance = ((velocity * velocity)/gravity)*sin(2*angle_in_radians)
There are 2*PI radians in 360 degrees.
Code Organization
-
Organize your code so that you do not have enormous methods. Break large
routines into smaller routines. As a guide, there should be a very compelling
reason for having a method that is longer than 25 lines. Do this as you develop
your code, not one hour after it is due.
-
Use meaningful variabe names and control names in the dialog. Do not
use any of the default names that the wizards create.
Create Two Auxiliary Classes
-
Create a class that encapsulates a planet. A planet has a name, a gravity,
and a color.
-
The color will be used as the background color of the output area.
-
Make the variables private.
-
Create properties for each of the variables.
-
Create a class that encapsulates firing a projectile. There will be a name,
and an intial velocity.
-
Make the variables private.
-
Create properties for each variable.
Create a Control Library
-
Create a control library that has two separate controls in it.
-
One control should contain your name.
-
Enlarge the font
-
Change the foreground color
-
The second control should contain the following oath. There will be five
labels in the form: one for each section of the oath.
-
I attest that this homework was done by me. I understand that if it is determined
that I shared my assignment with another person, or copied my assignment
from another person's work, then I and the other person will suffer the following
consequences:
-
1. This assignment will be graded as a zero.
-
2. A full letter grade will be removed from the final grade for the course
I am taking.
-
3. A letter will be placed in my permanent file in the School of Computer
Science.
-
4. If this is a second transgression, then I will receive an F in this course.
My case will be forwarded to the Dean for further action.
From Based Application
-
Add the name control from your control library to the main form.
-
Add a button that will calculate the distance that an object will travel
on a planet. Do not be concerned with air resistance, nor terminal velocity.
-
Add a button that will display a new form that contains information about
the application.
-
Place the name control from your control libraryin this form
-
Place the oath control from your control libraryin this form
-
Place a label in this form that has a brief description of your application.
-
Add a checkbox that controls whether the advanced options should be displayed.
By default, it should be unchecked.
-
Input
-
There will be three input text boxes: distance in meters to the target, angle
in degrees to fire the projectile, and the size of the target in meters.
-
Default distance: 0.0
-
Default angle: 0.0
-
Default size: 1.0
-
Convert each input to a
float
. When a user tabs out of an input
box, validate that the data is a float. Do not let the user exit the box
if it has invalid data, unless the form is being closes. Use an
ErrorProvider
to keep track of errors.
-
If the advanced button is checked display a radio group and a drop down list
inside of a group box.
-
The radio group should allow the user to select different methods of propelling
a projectile.
-
Jump: the intial velocity will be 5 m/s.
-
Throw: the initial velocity will be 24.5 m/s.
-
Shoot: the intial velocity will be 200 m/s.
-
When any of the radio buttons is chosen, change the label on the firing button
to match the method.
-
Place the radio buttons in a group box.
-
Create and use a static array of the velocity class that you created.
-
The drop down list will allow the user to select one of four heavenly bodies.
-
Earth: gravity 9.81m/s2
-
Moon: gravity 1.62 m/s2
-
Jupiter: gravity 25.95 m/s2
-
Sun: gravity 274.12 m/s2
-
When a new body is chosen, change the color of the output area to a different
color.
-
Create and use a static array of the planet class that you created. Initialize
the drop down list at run time from this static array.
-
The advance button will control the following behavior.
-
When the advanced button is checked, display all the input elements.
-
When the advanced button is unchecked, hide the advanced group box and its
contents.
-
Display the output area snuggly below all the visible elements.
-
Resize the form so that its minumum size will be large enough to display
all of the visible elements. Set the current size to the minimum size.
-
Use anchoring to make the form look good no matter how large the form is
made.
-
Center the advanced group box whenever the form is resized.
-
Limit the maximum height of the form so that all visible elements can be
seen.
-
The maximum width of the form should be unlimited.
-
Display the output in a read-only text box.
-
Change the color of the background based on the current planet.
-
Whenever an input value, radio button, or list selection changes, clear the
output.
-
The output should indicate if the target was hit, or if the shot was too
short or too long. Include the name of the planet in the output.
-
Edit the 16x16 and 32x32 pixel icons for the application.
-
Place your initials in each icon.
-
Embed the icon in the application.
-
The 16x16 will appear in the title bar and task bar.
-
The 32x32 will appear in Windows Explorer when large icons are used.
-
Change the title of the form.
Configuration File
-
Create a configuration file that will read the default planet and method
for firing the projectile.
-
Planet: use the name of the planet. If the name is not present, then default
to Earth.
-
Method: use the name of the method. If the method does not exist, then default
to Throw.