CSc 330
Object-Oriented Programming & Design Professor Domanski
Lab 2 Simple
Loan Calculator
All programs must have your name, and lab number on
them; in additions, all programs
must be commented (you don't have to go crazy, but the comments should explain
enough so that someone who doesn't know the program can follow the general flow
of the program). Your program will not
be handed in; you will present / demonstrate it in front of the class when its
due. Be prepared to explain your code,
and why you did what you did.
Lab 2 Redesign your Loan Calculator's internal structure so that you define a class that is defined using a header (.h) file.
As before, the GUI should remain the same .. use your form1.h file to "read" the values that a user types in, and to validate the input.
Define a header file, for example, loan.h, which will contain the definition of the class. The loan class needs for you to identify what private data (member variables) you want to have (e.g. C, R, N, P) ... and you need to define the member functions that will compute what you need computed! For example, you might want a member function computeR that will take C, N and P as validated parameters, and computes (and returns) R. Similarly, you might want a computeN function that accepts C, R and P as validated parameters, and a computeP function that works on C, R and N.
Your loan.h file should contain:
class loan
{
private:
// member variables
public:
// prototypes of member functions
// set and get function prototypes or inline definitions
};
Next, you need to define your implementation file: loan.cpp . This will contain all of the member function definitions - that is the parameters are spelled out, and the logic of each function is written here. Remember, if your class is called loan then the member functions are defined by writing ... loan::memberfunction(...)
You should also define a constructor function that will initialize the private data members. Use form1.h to capture the raw text input from the GUI, convert them to int's, float's, double's, etc., and then use the constructor to instantiate a loan object and to initialize starting values. Refer the examples (classes-Rectangle and classes-Sale)) that we covered in class) that are posted on the website.
Your form1.h program acts as a main program ... it gathers in the input, converts the input data as necessary, allocates and initializes a loan object, calls on the different member functions in the loan object to calculate what you need, and then output the calculations in the appropriate GUI control / textbox.
Remember, you have already written the essence of this program. I'm only asking you to re-engineer it. All of the 'extra' functionality you have already added (e.g. IsNumeric testing) should definitely be salvageable!
Good luck! Ask questions ... send me zipped entire folders via email if you need my help.
References Class website: the .zip files called classes-Rectangle and classes-Sale
What You Need To Know - Basic class definitions, how to add a .h and a .cpp file to your project.
Due
Thursday 3/16
Last Updated by DrB: Friday March 10, 2006 08:44 PM -0500