Here We Can Take a Simple Example of Credit Card Dummy Code:
//Create A headrer File Named CreditCardAccount.h Copy This code to that
ref class CreditCardAccount
{
public:
CreditCardAccount(long number, double limit);
void SetCreditLimit(double amount);
bool MakePurchase(double amount);
void MakeRepayment(double amount);
void PrintStatement();
long GetAccountNumber();
private:
long AccountNumber;
double CurrentBalance;
double CreditLimit;
};
********************************************************************
//Create A CPP File Named CreditCardAccount.CPP Copy This code to that
#include "stdafx.h"
#include "CreditCardAccount.h"
#using <mscorlib.dll>
using namespace System;
void CreditCardAccount::SetCreditLimit(double amount)
{
CreditLimit = amount;
Console::Write("\nCredited Amount:");
Console::Write(amount);
}
bool CreditCardAccount::MakePurchase(double amount)
{
if (CurrentBalance + amount > CreditLimit)
{
return false;
}
else
{
CurrentBalance += amount;
return true;
}
}
void CreditCardAccount::MakeRepayment(double amount)
{
CurrentBalance -= amount;
Console::Write("\nPaid Amount:");
Console::Write(amount);
}
void CreditCardAccount::PrintStatement()
{
Console::Write("\nCurrent Balance:");
Console::Write(CurrentBalance);
}
long CreditCardAccount::GetAccountNumber()
{
return AccountNumber;
}
CreditCardAccount::CreditCardAccount(long number, double limit)
:AccountNumber(number),CreditLimit(limit),CurrentBalance(0.0)
{
}//Member initialization lists in Constructor
##############################################################
//Create A CLR PROJECT named "CreditOrganizer " Copy This code to
// CreditOrganizer.cpp : main project file.
#include "stdafx.h"
#include "CreditCardAccount.h"
using namespace System;
int main(array<System::String ^> ^args)
{
CreditCardAccount ^myAccount;
myAccount = gcnew CreditCardAccount(1235,2500);
myAccount->SetCreditLimit(1000);
myAccount->MakePurchase(1000);
myAccount->MakeRepayment(7000);
long num = myAccount->GetAccountNumber();
Console::Write("\nAccount Number:");
Console::Write(num);
myAccount->PrintStatement();
Console::ReadKey();
return 0;
}
//Create A headrer File Named CreditCardAccount.h Copy This code to that
ref class CreditCardAccount
{
public:
CreditCardAccount(long number, double limit);
void SetCreditLimit(double amount);
bool MakePurchase(double amount);
void MakeRepayment(double amount);
void PrintStatement();
long GetAccountNumber();
private:
long AccountNumber;
double CurrentBalance;
double CreditLimit;
};
********************************************************************
//Create A CPP File Named CreditCardAccount.CPP Copy This code to that
#include "stdafx.h"
#include "CreditCardAccount.h"
#using <mscorlib.dll>
using namespace System;
void CreditCardAccount::SetCreditLimit(double amount)
{
CreditLimit = amount;
Console::Write("\nCredited Amount:");
Console::Write(amount);
}
bool CreditCardAccount::MakePurchase(double amount)
{
if (CurrentBalance + amount > CreditLimit)
{
return false;
}
else
{
CurrentBalance += amount;
return true;
}
}
void CreditCardAccount::MakeRepayment(double amount)
{
CurrentBalance -= amount;
Console::Write("\nPaid Amount:");
Console::Write(amount);
}
void CreditCardAccount::PrintStatement()
{
Console::Write("\nCurrent Balance:");
Console::Write(CurrentBalance);
}
long CreditCardAccount::GetAccountNumber()
{
return AccountNumber;
}
CreditCardAccount::CreditCardAccount(long number, double limit)
:AccountNumber(number),CreditLimit(limit),CurrentBalance(0.0)
{
}//Member initialization lists in Constructor
##############################################################
//Create A CLR PROJECT named "CreditOrganizer " Copy This code to
// CreditOrganizer.cpp : main project file.
#include "stdafx.h"
#include "CreditCardAccount.h"
using namespace System;
int main(array<System::String ^> ^args)
{
CreditCardAccount ^myAccount;
myAccount = gcnew CreditCardAccount(1235,2500);
myAccount->SetCreditLimit(1000);
myAccount->MakePurchase(1000);
myAccount->MakeRepayment(7000);
long num = myAccount->GetAccountNumber();
Console::Write("\nAccount Number:");
Console::Write(num);
myAccount->PrintStatement();
Console::ReadKey();
return 0;
}
No comments:
Post a Comment