I'm writing an ATM object-oriented project in C++. I found an implementation in C# here, which I used: PDF file with implementation. I was trying to convert this project into C++ and build it in Code::Blocks. Currently I'm trying to debug the project but I get a lot of errors. I managed to solve some of them, but new ones still show up. Currently I'm stuck on something and I can't find an answer that would help me, maybe someone could explain to me what's going on here. Here's the code of the object which the error refers to:
`
ATM::ATM()
{
userAuthenticated = false;
currentAccountNumber = 0;
Screen screen;
Keypad keypad;
CashDispenser cashDispenser;
DepositSlot depositSlot;
BankDatabase bankDatabase;
}
void ATM::Run()
{
while(true)
{
while(!userAuthenticated)
{
screen.DisplayMessage("Welcome!\n");
AuthenticateUser();
}
PerformTransactions();
userAuthenticated = false;
currentAccountNumber = 0;
screen.DisplayMessage("\nThank you! Goodbye!\n");
}
}
void ATM::AuthenticateUser()
{
screen.DisplayMessage("\nPlease enter your account number: ");
int accountNumber = keypad.GetInput();
screen.DisplayMessage("\nPlease enter your PIN number: ");
int pin = keypad.GetInput();
userAuthenticated = bankDatabase.AuthenticateUser(accountNumber, pin);
if (userAuthenticated)
currentAccountNumber = accountNumber;
else
screen.DisplayMessage("Invalid account number or PIN, please try again.\n");
}
void ATM::PerformTransactions()
{
Transaction currentTransaction;
bool userExited = false;
while (!userExited)
{
int mainMenuSelection = ATM::DisplayMenu();
switch((MenuOption)mainMenuSelection)
{
case BALANCE_INQUIRY: dzialalo
case WITHDRAWAL:
case DEPOSIT:
currentTransaction = CreateTransaction(mainMenuSelection);
currentTransaction.Execute();
break;
case EXIT_ATM:
screen.DisplayMessage("Exiting the system\n");
userExited = true;
break;
default:
screen.DisplayMessage("Wrong input, try again\n");
break;
}
}
}
int ATM::DisplayMenu()
{
screen.DisplayMessage("\nMain menu: \n1. - View balance \n2. - Withdraw cash \n3. - Deposit cash \n4. - Exit \nEnter a number:\n");
return keypad.GetInput();
}
Transaction ATM::CreateTransaction(int type)
{
switch((MenuOption)type)
{
case BALANCE_INQUIRY: //MenuOption.BALANCE_INQUIRY gdyby nie dzialalo
BalanceInquiry temp(currentAccountNumber,screen,bankDatabase);
break;
case WITHDRAWAL:
Withdrawal temp(currentAccountNumber,screen,bankDatabase,keypad,cashDispenser);
break;
case DEPOSIT:
Deposit temp(currentAccountNumber,screen,bankDatabase,keypad,depositSlot);
break;
}
return temp;
}
`
I get this error when I try to run whole project: ERRORS I GET
Is the compiler telling me, that in function ATM::PerformTransactions() the object that I'm trying to create is a function? How is it possible? Isn't it possible to create an object like that? Transaction currentTransaction
Can someone tell me what's wrong? I'd really appreciate your help.