C++ :个人财产类

写一个理财软件,首先我想到的抽象出一个 个人财产 类;

 

class DATA{
public:
	unsigned int year;
	unsigned char month;
	unsigned char day;

public:
	DATA(unsigned int Year,unsigned char Month,unsigned char Day){
		year = Year;
		month = Month;
		day = Day;
	}
	DATA(){}
	~DATA(){}

	bool isEmpty(){
		if(year == month == day ==0) return true;
		else return false;
	}
};

class CProperty{

	typedef	struct DETAIL{
		DETAIL(){};
		unsigned long currentProperty;  //现在有的钱
		unsigned long money;			//收入或支出的钱
		DATA data;						//支出或收入的时间
		char * pszReason;				//支出或收入的原因
	};

public:

	DETAIL detail;
	
	CProperty(unsigned long money=0){
		if(ReadcurrentProperty() == false)
			detail.currentProperty = money;
	}
	~CProperty(){}

	bool ReadcurrentProperty()
	{

	// 从文件中读取现在有的钱,赋值给detail.currentProperty,成功返回TRUE
		//return true;
	//失败返回FALSE
		return false;
	}

	void get(unsigned long money){	detail.currentProperty += money;	}
	void out(unsigned long money){	detail.currentProperty -= money;	}

	void saveToFile(){

	//把 类数据成员 detail 写到文件去

	}

	void searchAndShow(DATA from,DATA to){

		if(from.isEmpty()==true && to.isEmpty()==true){

		  //显示全部储存的信息

		}

		if(from.isEmpty()==false && to.isEmpty()==true){

		//显示从from到最后一条信息

		}

		if(from.isEmpty()==true && to.isEmpty()==false){

		//显示第一条到to的信息

		}

	}

};

void main()
{
	CProperty myProperty(10000000);		//初始财产1000万
	myProperty.get(5000000);

	DATA d(0,0,0);
	myProperty.detail.data=d;
	char * psz = "工资";
	myProperty.detail.pszReason=psz;

	myProperty.saveToFile();
}


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值