account.cpp

来自「这是一个银行系统的管理软件」· C++ 代码 · 共 128 行

CPP
128
字号
/**********************************************************************************
*                                                                                 *
*  Henry Banking System ATM Module                                                *
*  Copyright (c) 2004 by Henry. All rights reserved.                              *
*                                                                                 *
*  Permission to use, copy, modify, and distribute this software for any purpose  *
*  is hereby granted without fee, provided that this copyright and permissions    *
*  notice appear in all copies and derivatives, and that no charge may be made    *
*  for the software and its documentation except to cover cost of distribution.   *
*                                                                                 *
*  This software is provided "as is" without express or implied warranty.         *
*                                                                                 *
**********************************************************************************/

/*
*  Description:
*
*    Theinstance of account.
*
*  Notes:
*
*    This code has been written to conform to standard C++ and STL. It has been
*    compiled successfully using Visual C++ 7.0.
*/


#include <string>
#include <vector>
#include "banking.h"
#include "common.h"
#include "dataSet.h"

namespace banking
{
	Account::Account() : DataSet("database/account.txt")
	{
		
	}

	//Card No.
	string Account::getCardNo()
	{
		return dataRow[CARD_NO];
	}
	void Account::setCardNo(string cardNo)
	{
		dataRow[CARD_NO] = cardNo;
	}

	//Card Holder's Name
	string Account::getName()
	{
		return dataRow[NAME];
	}
	void Account::setName(string name)
	{
		dataRow[NAME] = name;
	}

	//Password
	string Account::getPassword()
	{
		return dataRow[PASSWORD];
	}
	void Account::setPassword(string password)
	{
		dataRow[PASSWORD] = password;
	}

	//Amount
	double Account::getAmount()
	{
		return string2double(dataRow[AMOUNT]);
	}
	void Account::setAmount(double amount)
	{
		dataRow[AMOUNT] = double2string(amount);
	}

	//DateTime
	string Account::getDateTime()
	{
		return dataRow[DATE_TIME];
	}
	void Account::setDateTime(string dateTime)
	{
		dataRow[DATE_TIME] = dateTime;
	}

	string Account::toString()
	{
		string myString = "";
		myString += "Card No.  :  " + getCardNo() + "\n";
		myString += "Name   .  :  " + getName() + "\n";
		myString += "Password  :  " + getPassword() + "\n";
		myString += "Amount    :  " + double2string(getAmount()) + "\n";
		myString += "DateTime  :  " + getDateTime() + "\n";
		return myString;
	}

	bool Account::searchByCardNo(string cardNo)
	{
		return query(CARD_NO, cardNo);
	}

	bool Account::login(string cardNo, string password)
	{
		bool hasCardNo = searchByCardNo(cardNo);
		if(!hasCardNo) return false;

		if(password == getPassword())
			return true;
		else
			return false;
	}

	void Account::createAccount(string name, string password)
	{
		System system;
		vector<string> vec;
		vec.push_back(long2string(system.generateNewCardNo()));
		vec.push_back(name);
		vec.push_back(password);
		vec.push_back("0");
		vec.push_back(getNow());
		append(vec);
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?