Computational Physics Spring 1998
Student Solutions to Previous Homework
Linear LINEAR plots two linear equations and calculates
their intersection. The program does this simple job well. It is clean, attractive and
easy to use.
|Linear_98.ZIP Source code.
||Linear_98.EXE (472K) Run the
How to Attack the Programming Exercises.
Try and do the problem using pencil and paper using a very special case or a small
amount of data. This will help you understand the algorithm and generate values that you
can use to debug the program.
- Create a separate directory for each programming project.
- Create a new project in Delphi and save this project into the new directory using descriptive
BUILD A SHELL
- Draw the graphical user interface, GUI.
- Set the initial values for important variables.
- Write Do-Nothing subroutines that show your program's structure. Add a comment
to every subroutine declaration to tell yourself what this subroutine will eventually do.
- See if the shell will compile.
- Save your work and make a second backup on floppy disk.
MAKE IT WORK
- Add the algorithms to make the program do the required calculations. Do the simplest
- Add documentation as you go along explaining what you think the code does.
- Use the debug features of Delphi such as breakpoints, single step, and trace
to find bugs.
- Learn how to use the online help!
- Check your results against known solutions.
MAKE IT USEFUL
- Add menus, about boxes, and secondary forms to give the user control.
- Have a friend test the program and watch what they do without any intervention on your
part. Can a new user figure out how to operate the program? Do they like how it looks?
- Try and crash the program. Put in crazy values. Trap for both mathematical singularities
and non-physical input.
LEARN FROM OTHERS
- Read the book. You may not understand everything the author is saying but you can
certainly copy source fragments such as how to create a dialog box.
- Look at the sample code that I have posted on the WWW including solutions to previous
- Come by and ask questions.
THE GOLDEN RULES
- Do only one change at a time and make sure it works before you go on to the next change.
- Save your work often.
- Start early.