如何将以下C ++代码转换为XML [英] How can i convert the following C++ code into XML

查看:90
本文介绍了如何将以下C ++代码转换为XML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include<iostream>
#include<string>
#include<stdlib.h>
#include<process.h>
#include<windows.h>

using namespace std;
class current
{
private:
	char choice;
	int x,y;

public:
	current()
	{
		
	}
	void currentcash()

	{
		char ch;
        
		cout<<"\n\n\n\n\n\n\n\n\n\nWell come to UBL\n\n";
		Sleep(3000);
		system("cls");
		cout<<"\n\n\n\n\n\n\n\n\n\nPlease enter you card and Press any key\n\n";
		cin>>choice;

		
		cout<<"\n\n\n\n\n\n\n\n\n\nHave you entered the card?\nPress 1 for 'YES' and 0 for 'NO'\n\n";
		cin>>x;
		if(x==0)
		{
			return;
		}
		
		cout<<"\n\n\n\n\n\n\n\n\n\nPlease enter your four digit pin code\n\n";
		cin>>y;
		for(y=1;y<=4;y++)
        {
			if(y>='0' && y<='9')
             {
                    cout<<"*";
             }
	    }
	}   
            
};
int total=100000;
class fastcash
{
	public: 
	
public:
	fastcash()
	{
		total=100000;
	}
	void operatecash()
	{
		int a;
		//int total;
		if(total==0)
		{
			cout<<"You have not sufficient balance";
			Sleep(6000);
			return;
		}
		cout<<"\n\nPress 1 for 'RS.500' \n";
		cout<<"Press 2 for 'RS.1000' \n";
		cout<<"Press 3 for 'RS.1500' \n";
		cout<<"Press 4 for 'RS.2000' \n";
		cout<<"Press 5 for 'RS.2500' \n";
		cout<<"Press 6 for 'RS.25000' \n";
		cout<<"Press 0 for Main Menu \n";
		cin>>a;
		if(a==1 || a==2 || a==3 || a==4 || a==5 ||a==6)
		{
			int b;
			if(a==1)
				total-=500;
			if(a==2)
				total-=1000;
			if(a==3)
				total-=1500;
			if(a==4)
				total-=2000;
			if(a==5)
				total-=2500;
			if(a=6)
				total-=25000;
			cout<<"\nDo you want to make another transection press 1?";
			cin>>b;
			if (b==1)
			{
				operatecash();
			
				}
				else
				{
					cout<<"No\n";
					cout<<"\n\n\n\nThanks for banking with UBL";
					Sleep(2000);
					{
					system("cls");
					Sleep(8000);
					return;
					//current::currentcash();
					}
				}
	    }
	}
};
class cashinquiry:public current
{
public:
	void operateinquiry()
	{
		int b;
		cout<<total;
		cout<<"\n\nDo you want to have receipt?\nPress 1 for 'Yes' else anyother key";
		cin>>b;
				if(b==1)
				{
					cout<<"Yes\n";
					Sleep(2000);
					cout<<"\n\n\n\nThanks for banking with UBL";
					Sleep(2000);
					{
					system("cls");
					Sleep(8000);
					current::currentcash();
					}
				}
				else
				{
					cout<<"No\n";
					cout<<"\n\n\n\nThanks for banking with UBL";
					Sleep(2000);
					{
					system("cls");
					Sleep(8000);
					current::currentcash();
					}
				}

    }
};
class fundtransfer:public current
{
public:
	void operatefund()
	{

		int c,d,e,f;
		cout<<"How much money do you want to transfer?\n";
		cin>>c;
		if(total<c)>
		{
			cout<<"You don't have that much money to transfer\n";
			Sleep(6000);
			return;
		}
		
		total=total-c;
		
		cout<<"Enter the account number in which you want to transfer money\n";
		cin>>d;
		cout<<"\n\nAre you sure that you want to transfer money?\n Press 1 for 'Yes' else anyother key\n\n";
		cin>>e;
				if(e==1)
				{
					cout<<"Yes\n";
				}
				else
				{
					cout<<"No\n";
				}
				cout<<"Do you want to make another money transfer?\nPress 1 for 'YES' and 0 for 'NO'\n";
				cin>>f;
				if(f==0)
				{
					system("cls");
					cout<<"\n\n\n\nThanks for banking with UBL";
					Sleep(2000);
					{
					system("cls");
					Sleep(8000);
					current::currentcash();
					}
				}
	}
};
int main()
{
	system ("color 1f");
	current c;
	fastcash fc;
	cashinquiry ci;
	fundtransfer ft;
	c.currentcash();

	int i;
	while(1)
	{
		system("cls");
		cout<<"\n\nPlease select Transection type\n\n";
		cout<<"\n\nPress 1 for 'FAST CASH' \n";
		cout<<"Press 2 for 'ACCOUNT INQUIRY' \n";
		cout<<"Press 3 for 'FUND TRANSFER' \n";
		cout<<"Press 0 for 'Exit' \n";
		cin>>i;
		switch(i)
		{
		case 1:
		fc.operatecash();
		break;
		case 2:
		ci.operateinquiry();
		break;
		case 3:
		ft.operatefund();
		break;
		case 0:
		exit(0);
	}
	}
	system("pause");
}





[edit]已添加代码块 - OriginalGriff [/ edit]



[edit]Code block added - OriginalGriff[/edit]

推荐答案

你不能。

XML是一种类似于HTML的语言,用于创建结构化文档和网页。

C ++是通用的面向对象编程语言。



你无法在C ++中轻松存储信息;您无法处理信息或使用XML编写应用程序。



请参阅此处: http ://www.w3schools.com/xml/ [ ^ ]

这里: http:/ /groups.engin.umd.umich.edu/CIS/course.des/cis400/xml/xml.html [ ^ ]
You can''t.
XML is a language similar to HTML used for creating structured documents and web pages.
C++ is a general purpose object oriented programming langusge.

You cannot comfortably store information in C++; you cannot process information or write an application in XML.

See here: http://www.w3schools.com/xml/[^]
And here: http://groups.engin.umd.umich.edu/CIS/course.des/cis400/xml/xml.html[^]


如前所述,XML不是一种编程语言,它就像HTML一种标记语言。

你能做的最好的就是把代码分成两部分,第一部分读取配置xml

和第二部分处理xml。



所以你输入用户输入的地方可以转换为配置xml,如下所示



as stated earlier by others, XML is not a programming language its like HTML a markup language.
what best you can do is break up the code in to two parts, part1 reading the configuration xml
and part2 processing the xml.

so the place where you are taking the user inputs can be converted to configuration xml like below

<atminputs>
 <transaction type="" /> <!-- 1= FASTCASH, 2 = BALANCEINQUIRY, 3 = FUNDTRANSFER -->
 <fastcash amount="" /> <!-- user needs to fill this -->
 <balanceinquiry receipt="" pincode="" />
 <fundtransdfer amount="" toaccount="" />
<atminputs>





因此这将成为您的用户输入XML,然后休息处理保持不变。

所以只需解析xml的输入然后执行其余操作。

如果用户将值设置为1,则表示标签fastcash中的readonly值并进行处理。



so this becomes your input XML from user, and then rest processing remains the same.
so just parse the inputs from the xml and then do rest of the operations.
Like if user sets value as 1, then readonly values present in tag fastcash and do the processing.


这篇关于如何将以下C ++代码转换为XML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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