count.cpp

来自「一个简单的记账软件」· C++ 代码 · 共 60 行

CPP
60
字号
// Count.cpp: implementation of the CCount class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "Tally.h"
#include "Count.h"
#include "TallyDoc.h"
#include "Item.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CCount::CCount()
{
	/*for (int j=0; j<9; j++){	
			m_Times[i][j] += 
		}*/
	//CArray<CItem,CItem&> m_aMonth[12];
	CWnd * pMain = AfxGetApp( )->m_pMainWnd;
	CTallyDoc * pActiveDoc = (CTallyDoc*)((CMDIFrameWnd*)pMain)->MDIGetActive()->GetActiveDocument();
	for (int i=0; i<12; i++){
		for (int j=0; j<9; j++){
			m_Times[i][j] = 0;
			m_Count[i][j] = 0;
		}
	}
	for (i=0; i<12; i++){
		for (int j=0; j<pActiveDoc->m_aMonth[i].GetSize(); j++){
			m_Times[i][pActiveDoc->m_aMonth[i][j].m_tType] ++;
			m_Count[i][pActiveDoc->m_aMonth[i][j].m_tType] += pActiveDoc->m_aMonth[i][j].m_dCost;
		}		
	}
}

CCount::~CCount()
{

}
int CCount::GetYearTimes (int type)
{
	int temp = 0;
	for (int i=0; i<12; i++)
		temp += m_Times[i][type];
	return temp;
}
double CCount::GetYearCount (int type)
{
	double temp = 0;
	for (int i=0; i<12; i++)
		temp += m_Count[i][type];
	return temp;
}

⌨️ 快捷键说明

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