CSCI 342 Fall 2014
Computer Graphics
Archived Class
Charles Cusack
Computer Science
Hope College
Main
Schedule
Grading
Gradebook
Homework

Policies
Advice
College
    Policies

Notes
Programs
Tutorials

CSCI 125
CSCI 255
Others

Admin

Homework 2

General Comments

Homework assignments will be drawn from a variety of sources. For programs, make sure you commit your solution to SVN by the assignment deadline!

Details

The purpose of this assignment is to help familiarize yourself with programming in C#.

For this assignment, you need to create a simple calculator that looks/functions similarly to this one: SimpleCalculator.exe. (When you download and run this, you will probably get a warning message if you are using Windows 8. You will need to Click More Information followed by Run anyway to run it.)

Don't over-complicate this assignment—I wrote the program in just about 45 minutes.

Here are a few hints:

  • You might want to know about the Convert and TableLayoutPanel classes.
  • My solution contains only two class fields. One is a double, and the other is an int (although I could have used an enumeration instead).
  • Besides declaring two fields, the rest of my code is in 14 event handler methods. The majority of them are one line long. One is slightly more complicated since it contains a switch statement. The rest are really simple.
  • Most importantly, start early, especially if you are new to C# and/or Visual Studio. You will need to figure out how to change properties of GUI elements, add events, etc. and although nothing in this assignment is at all difficult once you know how, you may need to experiment a little to figure how to do a few things. (It's like driving a car. Once you know how, it's really easy. But it wasn't so easy before you know what all of the controls did.)

You should create a project called SimpleCalculator in the CSCI342 Solution you have already created. If you don't remember how to do this, see the Adding a new project to the solution section on the last page of the Getting a Computer Graphics Project Started handout. Make sure you commit your changes to SVN before the deadline.

To receive full credit your calculator must look as good (or better) than the sample provided, and it should function properly. I will briefly look at your code just to make sure you didn't do anything really bizarre, inefficient, etc. In other words, I will simply be looking for clean, clear, and concise code.

If you have time, you are encouraged to go beyond the assignment for the purpose of becoming more familiar with C#. In other words, if you can think of ways of adding different GUI elements, using different events, etc., do so. But make sure that the basic features are implemented correctly first! In particular, if you can figure out how to get the keyboard keys (e.g. 0-9, +, -, etc.) to work, you will learn some useful stuff. But I will forewarn you—handling keys can sometimes be tricky.