有一个银行类,我是这么建立的:
using System;
public class Bank
{
#region 私有成员
protected int Account;
protected String userName;
protected String openAccount;
protected String identityCard;
protected float balance;
#endregion
public Bank()
{ }
public Bank(int Account, String userName, String openAccount,
String identityCard, float balance)
{
set(Account, userName, openAccount,
identityCard, balance);
}
public void set(int Account, String userName, String openAccount,
String identityCard, float balance)
{
this.Account = Account;
this.userName = userName;
this.openAccount = openAccount;
this.identityCard = identityCard;
this.balance = balance;
}
public void set(float balance)
{
this.balance = balance;
}
public void set(Bank newAccount)
{
this.set(newAccount.Account, newAccount.userName,
newAccount.openAccount, newAccount.identityCard,
newAccount.balance);
}
public void saving(float money)
{
set(this.balance + money);
}
public void fetching(float money)
{
if(balance>=money)
{
set(this.balance-money);
Console.WriteLine("操作成功");
}
else
{
Console.WriteLine("您的余额不够");
}
}
public void Print()
{
Console.WriteLine("帐户:"+this.Account+"姓名:"+this.userName+"余额:"+this.balance);
}
但是我想操作时保存这些信息,在数据结构课程中,我是用链表实现的。
问题是:我有必要设计一个链表来保存这些信息吗?还是有更好的办法?
链表结构是为了可以快速的增删节点,存储结构可以考虑采用顺序存储,或者用数据库,xml这类的方式存储,用链表方式存储感觉比较复杂,而且没有太大的必要。