Constructors- Passing in values in and setting it up?

Feb 27 2005 6:34 AM
Hi guys, Im working on savings account program that the user inputs a interest rate and a balance. 1.)How would i set the initial interest rate and balance values zero? 2.)Would anyone know how to take the interest rate and balance values from the client class to my driver constructor class so i can modify them? I know you do something like : balance = balance_box.Text or something like that... right now i have this as my driver constructor class: using System; namespace project { /// /// Summary description for SavingsAccount. /// public class SavingsAccount { //creating private variables private double annualInterestRate, savingsAccountBalance; //defualt constructor setting values to zero public SavingsAccount() { SetAnnualInterestRate( 0 ); SetSavingsAccountBalance( 0 ); } //methods to set values to zero, but i did that above, or do i need these? public SavingsAccount(double annualInterestRate ) { SetAnnualInterestRate(0); } public SavingsAccount(double savingsAccountBalance ) { SetSavingsAccountBalance(0); } } }

Answers (1)