下载后可任意编辑实验六 数组编程练习姓名: 刘帆 学号: 082550 日期: 2010/12/2 实验名称: 继承与多态 成绩: 一、实验目的与要求实验目的1.了解数组的概念,掌握数组的声明、初始化方式;2. 熟练掌握foreach语句的用法,理解params关键字的使用;4. 掌握数组转换方法的使用;5. 理解索引器的概念,掌握在整数索引和在字符串上索引的应用。实验要求1. 调试程序,要给出测试数据和实验结果。2. 整理上机步骤,总结经验和体会。3. 完成实验日志和上交程序。二、实验环境 Windows 7三、实验源程序及关键代码解释 namespace 实验六{ class Account//帐户类 { int AccountNumber;//帐户帐号 double Balance;//本金 double CurrentInterestRate;//当前利率; double totalInterestPaid;//总支付利息 //属性 public int AAcountNumber { get { return AccountNumber; } set { AccountNumber = value; } } public double ABalance { get { return Balance; } set { Balance = value; } } public double ACurrentInterestRate {下载后可任意编辑 get { return CurrentInterestRate; } set { CurrentInterestRate = value; } } public double AtotalInterestPaid { get { return totalInterestPaid; } set { totalInterestPaid = value; } } //构造函数 public Account(int AN, double Ba) { AccountNumber = AN; Balance = Ba; } } class Bank//银行类 { double totalPaid;//银行付的总利息 Account[] accounts = new Account[100]; //构造函数 public Bank() { } ///
/// 修改 /// ///
///
///
public Bank(int no, int[] AN, double[] Ba) { for (int i = 0; i < no; i++) { Account tmp = new Account(AN[i], Ba[i]); accounts[AN[i]] = tmp; } } ///
/// 修改 /// ///
///
///
下载后可任意编辑 //设置帐户的利率 public void SetInterestRate(int num, int cir) { if (cir == 0) accounts[num].ACurrentInterestRate = 0.0...