⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ld_ex_add.cpp

📁 设计模式:工厂模式、单例模式的基本实现
💻 CPP
字号:
#include <iostream>
#include <string>
#include <conio.h>

#include "LD_Ex_Add.h"
#include "LD_File.h"

using namespace std;

void LD_Ex_Add::LD_EX_Add_ExamAdd(LD_File _FL_One, LD_File* &_HeadP, LD_File* &_LastP)
{
	LD_File* Tmp_OneP = new(LD_File);
	string FL_XuanXiang[7];
	for(int i=0;i<7;++i)
	{
		FL_XuanXiang[i] = _FL_One.getXuanXiang(i);
	}

	Tmp_OneP->setFL_TaoTi(_FL_One.getTaoTi());
	Tmp_OneP->setFL_TiHao(_FL_One.getTiHao()%10);
	if(Tmp_OneP->getTiHao() == 0)
	{
		Tmp_OneP->setFL_TiHao(10);
	}
	Tmp_OneP->setFL_TiGan(_FL_One.getTiGan());
	Tmp_OneP->setFL_XuanXiang(FL_XuanXiang,7);
	Tmp_OneP->setFL_FenShu(_FL_One.getFenShu());
	Tmp_OneP->setFL_DaAn(_FL_One.getDaAn());
	if(_HeadP == NULL)
	{
		 _HeadP =  _LastP= Tmp_OneP;
	}
	else
	{
		Tmp_OneP->setFL_PreviousP(_LastP);
		_LastP->setFL_NextP(Tmp_OneP);
		_LastP = Tmp_OneP;
	}

	return;
}

int LD_Ex_Add::LD_EX_Add_Fenshu(LD_File* &_LastP)
{
	LD_File* CH_LastP10 = _LastP;
	LD_File* CH_LastP9 = CH_LastP10->getPreviousP();
	LD_File* CH_LastP8 = CH_LastP9->getPreviousP();
	LD_File* CH_LastP7 = CH_LastP8->getPreviousP();
	LD_File* CH_LastP6 = CH_LastP7->getPreviousP();
	LD_File* CH_LastP5 = CH_LastP6->getPreviousP();
	LD_File* CH_LastP4 = CH_LastP5->getPreviousP();
	LD_File* CH_LastP3 = CH_LastP4->getPreviousP();
	LD_File* CH_LastP2 = CH_LastP3->getPreviousP();
	LD_File* CH_LastP1 = CH_LastP2->getPreviousP();

	while(1)
	{
		system("cls");
		cout << "☆□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□☆"<<'\t'<<'\n'<<endl;
		cout << "\t\t\t\t"<<"分数修改"<<'\t'<< endl;
		cout << ""<<'\t'<<endl;
		cout << "☆□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□■□☆"<<'\t'<<'\n'<<endl;

		cout << " 第 "<<CH_LastP1->getTiHao()+(_LastP->getTaoTi()-1)*10<<"  题题目:" << CH_LastP1->getTiGan() << "——( " << CH_LastP1->getFenShu() << " )" << endl;
		cout << " 第 "<<CH_LastP2->getTiHao()+(_LastP->getTaoTi()-1)*10<<"  题题目:" << CH_LastP2->getTiGan() << "——( " << CH_LastP2->getFenShu() << " )" << endl;
		cout << " 第 "<<CH_LastP3->getTiHao()+(_LastP->getTaoTi()-1)*10<<"  题题目:" << CH_LastP3->getTiGan() << "——( " << CH_LastP3->getFenShu() << " )" << endl;
		cout << " 第 "<<CH_LastP4->getTiHao()+(_LastP->getTaoTi()-1)*10<<"  题题目:" << CH_LastP4->getTiGan() << "——( " << CH_LastP4->getFenShu() << " )" << endl;
		cout << " 第 "<<CH_LastP5->getTiHao()+(_LastP->getTaoTi()-1)*10<<"  题题目:" << CH_LastP5->getTiGan() << "——( " << CH_LastP5->getFenShu() << " )" << endl;
		cout << " 第 "<<CH_LastP6->getTiHao()+(_LastP->getTaoTi()-1)*10<<"  题题目:" << CH_LastP6->getTiGan() << "——( " << CH_LastP6->getFenShu() << " )" << endl;
		cout << " 第 "<<CH_LastP7->getTiHao()+(_LastP->getTaoTi()-1)*10<<"  题题目:" << CH_LastP7->getTiGan() << "——( " << CH_LastP7->getFenShu() << " )" << endl;
		cout << " 第 "<<CH_LastP8->getTiHao()+(_LastP->getTaoTi()-1)*10<<"  题题目:" << CH_LastP8->getTiGan() << "——( " << CH_LastP8->getFenShu() << " )" << endl;
		cout << " 第 "<<CH_LastP9->getTiHao()+(_LastP->getTaoTi()-1)*10<<"  题题目:" << CH_LastP9->getTiGan() << "——( " << CH_LastP9->getFenShu() << " )" << endl;
		cout << " 第 "<<CH_LastP10->getTiHao()+(_LastP->getTaoTi()-1)*10<<"  题题目:" << CH_LastP10->getTiGan() << "——( " << CH_LastP10->getFenShu() << " )" << endl;  


		int nTmp = 0;
		int CH_FenShu = 0;
		cout<<"\n◆请输入要修改的题号:";
		cin >> nTmp;
		while(nTmp>CH_LastP10->getTiHao()+(_LastP->getTaoTi()-1)*10||nTmp<CH_LastP1->getTiHao()+(_LastP->getTaoTi()-1)*10)
		{
			cout<<"\n◆输入的题号错误! 请重新输入要修改的题号:";
			cin >> nTmp;
		}
		cout<<"\n◆输入试题 "<<nTmp<<" 的分数:";
		cin >> CH_FenShu;

		if(nTmp == CH_LastP1->getTiHao()+(_LastP->getTaoTi()-1)*10)			CH_LastP1->setFL_FenShu(CH_FenShu);

		if(nTmp == CH_LastP2->getTiHao()+(_LastP->getTaoTi()-1)*10)			CH_LastP2->setFL_FenShu(CH_FenShu);

		if(nTmp == CH_LastP3->getTiHao()+(_LastP->getTaoTi()-1)*10)			CH_LastP3->setFL_FenShu(CH_FenShu);

		if(nTmp == CH_LastP4->getTiHao()+(_LastP->getTaoTi()-1)*10)			CH_LastP4->setFL_FenShu(CH_FenShu);

		if(nTmp == CH_LastP5->getTiHao()+(_LastP->getTaoTi()-1)*10)			CH_LastP5->setFL_FenShu(CH_FenShu);

		if(nTmp == CH_LastP6->getTiHao()+(_LastP->getTaoTi()-1)*10)			CH_LastP6->setFL_FenShu(CH_FenShu);

		if(nTmp == CH_LastP7->getTiHao()+(_LastP->getTaoTi()-1)*10)			CH_LastP7->setFL_FenShu(CH_FenShu);

		if(nTmp == CH_LastP8->getTiHao()+(_LastP->getTaoTi()-1)*10)			CH_LastP8->setFL_FenShu(CH_FenShu);

		if(nTmp == CH_LastP9->getTiHao()+(_LastP->getTaoTi()-1)*10)			CH_LastP9->setFL_FenShu(CH_FenShu);

		if(nTmp == CH_LastP10->getTiHao()+(_LastP->getTaoTi()-1)*10)			CH_LastP10->setFL_FenShu(CH_FenShu);

		nTmp = 0;
		cout<<"\n\t1 继续\t\t2 完成修改"<<endl;
		char CH_In;
		while(1)
		{
			CH_In = getch();
			if(CH_In == '1')
			{
				break;
			}
			else if(CH_In == '2')
			{
				int nScore = 0;
				nScore = CH_LastP1->getFenShu()+CH_LastP2->getFenShu()+CH_LastP3->getFenShu()+CH_LastP4->getFenShu()+CH_LastP5->getFenShu()+CH_LastP6->getFenShu()+CH_LastP7->getFenShu()+CH_LastP8->getFenShu()+CH_LastP9->getFenShu()+CH_LastP10->getFenShu();
				if(nScore == 100)
				{
					cout<<"\n\n◆分数修改成功,组成第 "<<CH_LastP10->getTaoTi()<<" 套试卷。\n\n(按任意键返回)";
					getch();
					return '1';
				}
				else
				{
					cout<<"\n\n◆总分数与100分不符。\t(按任意键继续)";
					getch();
					break;
				}
			}
		}
	}
}

⌨️ 快捷键说明

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