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

📄 class.cpp

📁 小小游戏专业源代码2
💻 CPP
字号:
#include "class.h"
#include <string.h>
#include <iostream.h>

Item::Item()
{
	strcpy(Title,"");
	strcpy(Author,"");
	strcpy(IndexCode,"");
	BarCode = 0;
}

Item::Item(Item & it)
{
	strcpy(Author,it.Author);
	strcpy(Title,it.Title);
	strcpy(IndexCode,it.IndexCode);
	BarCode = it.BarCode;
}

void Item::SetTitle(char *t1)
{
	strcpy(Title, t1);
}

void Item::SetAuthor(char *t1)
{
	strcpy(Author, t1);
}

void Item::SetIndexCode(char *t1)
{
	strcpy(IndexCode, t1);
}

void Item::SetBarCode(long t)
{
	BarCode = t;
}

void Item::Show()
{
	cout<<Title<<'\t'<<Author<<'\t'<<IndexCode<<'\t'<<BarCode<<'\n';
}

Reader::Reader()
{
	strcpy(Name,"");
	strcpy(Position,"");
	Counter = 0;
	Age = 0;
	Code = 0;
}

void Reader::SetName(char *t)
{
	strcpy(Name,t);
}

void Reader::SetPosition(char *t)
{
	strcpy(Position,t);
}

void Reader::SetAge(int t)
{
	Age = t;
}

void Reader::SetCode(long t)
{
	Code = t;
}

void Reader::ShowBooks()
{
	for(int i = 0; i<Counter; i++)
		items[i].Show();
}

void Reader::AddBook(Item it)
{
	if(Counter<10){
		items[Counter] = it;
		Counter++;
	}

	return;
}

void Reader::DelBook(Item it)
{
	if(Counter>=0){
	int i=0;
		do{
			if(items[i].GetBarCode()==it.GetBarCode()){ //查找待还书
				for(int j=i; j<Counter-1; j++)
					items[j] = items[j+1];  // 从所借书中删除
				Counter--;
				break;
			}
			i++;
		}while(i<Counter);
	}
	return;
}

⌨️ 快捷键说明

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