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

📄 testproxy.cpp

📁 financal instrument pricing using c
💻 CPP
字号:
// testProxy.cpp
//
// Program to test Proxy

#include "ProtectedAccount.hpp"
#include <iostream>

void main()
{

	// Create accounts
	Account* account1=new ProtectedAccount(100.0, "password");
	Account* account2=new ProtectedAccount(100.0, "dontknow");

	// Try to withdraw money
	try
	{
		// Withdraw some money
		std::cout<<"Withdraw 25 from account 1"<<std::endl;
		account1->Withdraw(25);
		std::cout<<"Withdraw 25 from account 2"<<std::endl;
		account2->Withdraw(25);
		std::cout<<"Withdraw 100 from account 2"<<std::endl;
		account2->Withdraw(100);
	}
	catch (NoFundsException)
	{
		std::cout<<"Not enough funds"<<std::endl;
	}
	
	// Try to access balance
	try
	{
		std::cout<<"Balance account 1: "<<account1->GetBalance()<<std::endl;
		std::cout<<"Balance account 2: "<<account2->GetBalance()<<std::endl;
	}
	catch (NoAccessException)
	{
		std::cout<<"No permission to access balance"<<std::endl;
	}


	// Clean up memory
	delete account1;
	delete account2;

}

⌨️ 快捷键说明

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