我需要帮助处理订单对象 [英] I need help with puting in order objects

查看:79
本文介绍了我需要帮助处理订单对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码,我想从txt导入一些对象的参数,然后按顺序将对象放入过滤器(主要和次要)"type,id,author和year"。



Book.cpp

 #include< iostream> 
#include< fstream>
#include< cstdio>
#include< cstdlib>
#include< string>
using namespace std;

#include" Book.h"


BibElement :: BibElement()
{
setType(" @"," @ article"," @ Book"," @) inproceedings","");
setId();
setAuthor();
setYear();
}
void BibElement :: setType(char TYPE [])
{
type = TYPE;

}
void BibElement :: setId(char ID [])
{
id = ID;
}
void BibElement :: setAuthor(char AUTHOR [])
{
author = AUTHOR;
}
void BibElement :: setTitle(char TITLE [])
{
title = TITLE;
}
void BibElement :: setJournal(char JOURNAL [])
{
journal = JOURNAL;
}
void BibElement :: setVolume(char VOLUME [])
{
volume = VOLUME;
}
void BibElement :: setBooktitle(char BOOKTITLE [])
{
booktitle = BOOKTITLE;
}
void BibElement :: setPublisher(char PUBLISHER [])
{
publisher = PUBLISHER;
}
void BibElement :: setPages(char PAGES [])
{

pages = PAGES;
}
void BibElement :: setYear(char YEAR [])
{
year = YEAR;
}

string BibElement :: getType()
{
返回类型;

}
string BibElement :: getId()
{
return id;
}
string BibElement :: getAuthor()
{
return author;
}
string BibElement :: getTitle()
{
return title;
}
string BibElement :: getJournal()
{
return journal;
}
string BibElement :: getVolume()
{
返回量;
}
string BibElement :: getBooktitle()
{
return booktitle;
}
string BibElement :: getPublisher()
{
return publisher;
}
string BibElement :: getPages()
{
返回页面;
}
string BibElement :: getYear()
{
返回年份;
}




Book.h


 //标题簿

#include< iostream>
#include< fstream>
#include< cstdio>
#include< cstdlib>
#include< string>
using namespace std;

class BibElement {

private:
string type;
string id;
string author;
字符串标题;
string journal;
字符串量;
string booktitle;
字符串发布者;
字符串页面;
string year;
public:

BibElement(string,string,string,string,string,string,string,string,string,string);
~BibElement();
void setType();
void setId();
void setAuthor();
void setTitle();
void setJournal();
void setVolume();
void setBooktitle();
void setPublisher();
void setPages();
void setYear();
string getType();
string getId();
string getAuthor();
string getTitle();
string getJournal();
string getVolume();
string getBooktitle();
string getPublisher();
string getPages();
string getYear();
};



main_Book.cpp


 #include< iostream> 
#include< fstream>
#include< cstdio>
#include< cstdlib>
#include< string>
using namespace std;



int main()
{
int i = 1; N = 0;
string text,temp;
fstream fileRead,fileWrite;

system(" chcp 1253");
system("CLS");

fileRead.open(" input.txt",ios :: in);

if(!fileRead)
{
cerr<<"'找不到档案...... \ n" ;;
退出(1);
}

do {
getline(fileRead,temp);
n ++
} while(!fileRead.eof());
fileRead.close();

fileRead.open(" input.txt",ios :: in);
for(i = 0; i< n; i ++)
{
if(i> 0)
text + ='\ n';
getline(fileRead,temp);
text = text + temp;
}
fileRead.close();

n = text.length();

for(i = 0; i< n; i ++)
{
cout<<" Give primary filter"<< output.txt<< endl ;
cout<<"授予二级过滤器:"<<<<< endl;


if(text [i] == year || text [i] == author)
text [i] =
}



system("PAUSE");
返回0;
}

------------------------------- --------------------------


txt文件示例


@inproceedings {Eme96,

author =" Emerson,EA",

title ="关于反应系统的自动时间推理",
booktitle =""关于并发逻辑的第八届班夫高级研讨会会议记录:结构与自动机","
pages =" 41--101",
year =" 1996" ,}


@Book {Eme90,

author =" Emerson,EA",

title =" Temporal and模态逻辑","
publisher ="理论计算机科学手册,B卷:形式模型和语义学","
pages =" 995--1072",

year =" 1990",}


@inproceedings {BR86,

author =" Bancilhon,F。和Ramakrishnan, R.",

title ="业余对递归查询处理策略的介绍",
booktitle =" Proc。 ACM会议关于数据管理,华盛顿",
pages =" 16--52",

year =" 1986",}


@article {CES86,

author =" Clarke,EM and Emerson,EA and Sistla,AP",$
title =" Automatic Verification of finite - 使用时间逻辑规范的"状态并发系统","journal ="ACM编程语言和系统事务(TOPLAS)","
volume =" 8(2)",

pages =" 244--263",

year =" 1986",}


@Book {Che80,

author =" Chellas,Brian F.",
title =" Modal Logic:An Introduction",
publisher =" Cambridge University Press" ;,
year =" 1980",}


@article {EH86,

author =" Emerson,EA and Halpern,JY",

title ="有时而且从未重新访问:在分支与线性时间时间逻辑","
journal =" Journal of the ACM",volume =" 33(1)",pages =" 151--178",year =" 1986",}



--------------------------------------- -------------------------------------------------- --------------



提前感谢您的帮助。



解决方案

这听起来像是家庭作业。


您采取了哪些步骤来调试代码以确定无法实现目标的原因?


您知道如何使用Visual Studio调试器吗?


I have this code and I want to import the parameters of some objects from a txt and then to put the object in order with filters(primary and secondary)"type,id,author and year".

Book.cpp

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <string>
using namespace std;

#include "Book.h"


BibElement::BibElement()
{
	setType("@", "@article", "@Book", "@inproceedings", "");
	setId();
	setAuthor();
	setYear();
}
void BibElement::setType(char TYPE[])
{
	type = TYPE;

}
void BibElement::setId(char ID[])
{
	id = ID;
}
void BibElement::setAuthor(char AUTHOR[])
{
	author = AUTHOR;
}
void BibElement::setTitle(char TITLE[])
{
	title = TITLE;
}
void BibElement::setJournal(char JOURNAL[])
{
	journal = JOURNAL;
}
void BibElement::setVolume(char VOLUME[])
{
	volume = VOLUME;
}
void BibElement::setBooktitle(char BOOKTITLE[])
{
	 booktitle=BOOKTITLE;
}
void BibElement::setPublisher(char PUBLISHER[])
{
	publisher=PUBLISHER;
}
void BibElement::setPages(char PAGES[])
{
	
	pages=PAGES;
}
void BibElement::setYear(char YEAR[])
{
	year=YEAR;
}

string BibElement::getType()
{
	return type;

}
string BibElement::getId()
{
	return id;
}
string BibElement::getAuthor()
{
	return author;
}
string BibElement::getTitle()
{
	return title;
}
string BibElement::getJournal()
{
	return journal;
}
string BibElement::getVolume()
{
	return volume;
}
string BibElement::getBooktitle()
{
	 return booktitle;
}
string BibElement::getPublisher()
{
	return publisher;
}
string BibElement::getPages()
{
	return pages;
}
string BibElement::getYear()
{
	return year;
}


Book.h

//Header book

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <string>
using namespace std;

class BibElement{
	
	private:
		string type;
		string id;
		string author;
		string title;
		string journal;
		string volume;
		string booktitle;
		string publisher;
		string pages;
		string year;
	public:
		
		 BibElement(string, string, string, string, string, string, string, string, string, string);
		 ~BibElement();
		 void setType();
		 void setId();
		 void setAuthor();
		 void setTitle();
		 void setJournal();
		 void setVolume();
		 void setBooktitle();
		 void setPublisher();
		 void setPages();
		 void setYear();
		 string getType();
		 string getId();
		 string getAuthor();
		 string getTitle();
		 string getJournal();
		 string getVolume();
		 string getBooktitle();
		 string getPublisher();
		 string getPages();
		 string getYear();
};

main_Book.cpp

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <string>
using namespace std;



int main()
{ 
	int i=1; n=0;
	string text, temp;
	fstream fileRead, fileWrite;
	
	system("chcp 1253");
	system("CLS");
	
	fileRead.open("input.txt", ios::in);
	
	if(!fileRead)
	{
		cerr<<"File not found ...\n";
		exit (1);
	}
	
	do {
		getline(fileRead, temp);
		n++	
	} while (!fileRead.eof());
	fileRead.close();
	
	fileRead.open("input.txt", ios::in);
	for (i=0; i<n; i++)
	{
		if(i>0)
		text+='\n';
		getline(fileRead, temp);
		text=text+temp;
	}
	fileRead.close();
	
	n=text.length();
	
	for(i=0; i<n; i++)
	{
		cout<<"Give primary filter"<<output.txt<<endl;
		cout<<"Give secondary filter: "<<<<endl;
		
		
		if(text[i]==year || text[i]== author)
		text[i]=
	}	

	
	
	system("PAUSE");
	return 0;
}

---------------------------------------------------------

Example of txt file

@inproceedings{Eme96,
author = "Emerson, E. A.",
title = "Automated Temporal Reasoning about Reactive Systems",
booktitle = "Proceedings of the VIII Banff Higher order workshop conference on Logics for concurrency: structure versus automata",
pages = "41--101",
year = "1996" , }

@Book{Eme90,
author = "Emerson, E. A.",
title = "Temporal and modal logic",
publisher = "Handbook of Theoretical Computer Science, Volume B: Formal Models and Semantics",
pages = "995--1072",
year = "1990", }

@inproceedings{BR86,
author = "Bancilhon, F. and Ramakrishnan, R.",
title = "An amateur's introduction to recursive query processing strategies",
booktitle = "Proc. ACM Conf. on Management of Data, Washington",
pages = "16--52",
year = "1986", }

@article{CES86,
author = "Clarke, E. M. and Emerson, E. A. and Sistla, A. P.",
title = "Automatic Verification of finite-state concurrent systems using temporal logic specifications", journal = "ACM Transactions on Programming Languages and Systems (TOPLAS)",
volume = "8(2)",
pages = "244--263",
year = "1986",}

@Book{Che80,
author = "Chellas, Brian F.",
title = "Modal Logic: An Introduction",
publisher = "Cambridge University Press",
year = "1980", }

@article{EH86,
author = "Emerson, E. A. and Halpern, J. Y.",
title = "Sometimes and not never revisited: On branching versus linear time temporal logic",
journal = "Journal of the ACM", volume = "33(1)", pages = "151--178", year = "1986", }

-------------------------------------------------------------------------------------------------------

Thanks you in advance for your help.

解决方案

This sounds like a homework assignment.

What steps have you taken to debug your code in order to determine why it does not achieve your objective?

Do you know how to use the Visual Studio debugger?


这篇关于我需要帮助处理订单对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆