Objects not updating after passing to a function

Okay, so, making an ATM using C++ object oriented programming, but I'm having a weird problem where after I pass several "component" objects into another class to handle it's functions, once the "transaction" is done, the "component" objects loose what updates have been made to them, here is my

here is the call I make to pass the components to the transaction

Transaction T(CHOICE, accounts[working_account], KP, DROP, WINDOW, PRNT, fout);

what happens is if I call the various MYIS functions inside the transaction after updates have been made I get the correct values, however if I do

1
2
3
4
cout << "\n\n Last KP Amount: " <<  KP.MyLastAmount() << "\n\n";
		cout << "\n\n MyAmountGiven: " <<  DROP.MyAmountGiven() << "\n\n";
		cout << "\n\n AmountAccepted: " <<  WINDOW.AmountAccepted() << "\n\n";
		cout << "\n\n TypeTaken: " <<  WINDOW.TypeTaken() << "\n\n";


I get all zeroes back as if nothing had been changed, obviously there's something fundamental I'm doing wrong, but I can't figure out what, thanks to anyone who can figure this out

header for overall ATM
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 *  ATM.h
 *  ATMSim
 *
 *  Created by Philip on 10/26/08.
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
 *
 */

#ifndef _ATM
#define _ATM

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

//#include "IOMgmt.h"
//using namespace IOMgmt;

#include "Transaction.h"
using namespace Trans;

#include "ATMcomp.h"
using namespace PARTS;

#include "Account.h"
using namespace AccMgmt;

class ATM	{
	public:
		ATM();
		void StartUp( ifstream& fin , ostream& fout );									// read input file, create accounts
		string MyLocationIs() { return location;}
		string MyBankIs() { return bank;}
		ACCTPTR OpenAccountIs() { return accounts[working_account];}
		void Extract( ifstream& fin ) throw(AppError);  //Boundary mutator
		void Insert ( ostream& fout );					//Boundary output
	
	private:
		CardReader CR;
		Keypad KP;
		Dispenser DROP;
		EnvelopeWindow WINDOW;
		Printer PRNT;
		int working_account;
		string location;
		string bank;
		int num_accounts;								// number of accounts
		ACCTPTR *accounts;								// array of accounts
		void getCard();									// request and recieve card
		void getChoice();								// get user selection
		void showOptions( ostream& fout );
		void endSession( ostream& fout );								// end the session
	
	protected:
		void Get( ifstream& fin ) throw(AppError);
		void Put( ostream& fout );
};

#endif 


header for components
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
 *  ATMcomp.h
 *  ATMSim - ATM components
 *
 *  Created by Philip on 10/25/08.
 *  Copyright 2008 All rights reserved.
 *
 */

#ifndef _PARTS
#define _PARTS

#define CARD_INSERTED 1
#define NO_CARD 0
#define OPEN 1
#define CLOSED 0

#include <stdio.h>
#include <time.h>
#include <ctime>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

#include "IOMgmt.h"
using namespace IOMgmt;


namespace PARTS
{

class CardReader	{
	public:
		CardReader();
		int ReadCard(ostream& fout);
		void EJECTcard() {InsertStatus = NO_CARD;}
		void Insert ( ostream& fout );					//Boundary output
		
	
	private:
		int InsertStatus;
		int cardNUMBER;
		void Put( ostream& fout );
};

class Printer	{
	public:
		Printer();
		void print( int chosen_type, float amount, ostream& fout, string location, string bank, int account_number, float balance );
		time_t rawtime;
};


class Keypad	{
	public:
		Keypad();
		int MyLastInput()	const { return INPUT;}
		int MyLastAmount()	const { return AMOUNT;}
		int getPin( ostream& fout );
		int getSelection( ostream& fout );
		float getAmount( ostream& fout );
		void Insert ( ostream& fout );					//Boundary output
		
	private:
		int INPUT;
		float AMOUNT;
		void Get( ifstream& fin ) throw(AppError);
		void Put( ostream& fout );
};

class Dispenser	{
	public:
		Dispenser();
		int MyAmountGiven()	const { return amount_given;}
		int give( int AmountToGive, ostream& fout );
		void Insert ( ostream& fout );					//Boundary output
		
	private:
		int amount;
		int amount_given;
		void Put( ostream& fout );
};

class EnvelopeWindow	{
	public:
		EnvelopeWindow();
		void use(int deposit_type,  ostream& fout );
		string TypeTaken()  const { return type;}
		float AmountAccepted()  const { return accepted;}
		void Insert ( ostream& fout );					//Boundary output
		
	private:
		void openWindow() {/*EnvelopeWindow::*/state = OPEN;}
		void closeWindow() {/*EnvelopeWindow::*/state = CLOSED;}
		void Put( ostream& fout );
		int state;
		string type;
		float accepted;
};

}

#endif 


here is transaction
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
 *  Transaction.h
 *  ATMSim
 *
 *  Created by Philip on 10/26/08.
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
 *
 */
 
//#define FastCashDrop 20.00
#ifndef _TRANS
#define _TRANS

//#include "ATM.h"
#include <iostream>
#include <fstream>
#include <string.h>
using namespace std;

#include "Account.h"
using namespace AccMgmt;

#include "ATMcomp.h"
using namespace PARTS;


namespace Trans
{

class Transaction	{
	public:
		Transaction(int chosen_type, BankAccount *account, Keypad KP, Dispenser DROP, EnvelopeWindow WINDOW, Printer PRNT, ostream& fout );
		void Extract( ifstream& fin ) throw(AppError);  //Boundary mutator
		void Insert ( ostream& fout );					//Boundary output
		int getType()	{ return type;}
	
	private:
		BankAccount *acc;
		float amount;
		int type;
		void Inquiry( Keypad KP, Printer PRNT, ostream& fout );
		void Withdrawal( Keypad KP,  Dispenser DROP, Printer PRNT, ostream& fout );
		void FastCash( Keypad KP, Dispenser DROP, Printer PRNT, ostream& fout );
		void Deposit( Keypad KP,  EnvelopeWindow WINDOW, Printer PRNT, ostream& fout );
		void FastCashSet( Keypad KP,  Printer PRNT, ostream& fout );
		void Get( ifstream& fin ) throw(AppError);
		void Put( ostream& fout );
};
/*
class Inquiry: public Transaction	{
	public:
		Inquiry();
		void Extract( ifstream& fin ) throw(AppError);  //Boundary mutator
		void Insert ( ostream& fout );					//Boundary output
	
	private:
		void Get( ifstream& fin ) throw(AppError);
		void Put( ostream& fout );
};

class Withdrawal: public Transaction	{
	public:
		Withdrawal();
		void Extract( ifstream& fin ) throw(AppError);  //Boundary mutator
		void Insert ( ostream& fout );					//Boundary output
	
	private:
		void dispense(float Amount);
		void Get( ifstream& fin ) throw(AppError);
		void Put( ostream& fout );
};

class FastCash: public Transaction	{
	public:
		FastCash();
		void Extract( ifstream& fin ) throw(AppError);  //Boundary mutator
		void Insert ( ostream& fout );					//Boundary output
	
	private:
		float dispense(float Amount);
		void Get( ifstream& fin ) throw(AppError);
		void Put( ostream& fout );
};

class Deposit: public Transaction {
	public:
		Deposit();
		void Extract( ifstream& fin ) throw(AppError);  //Boundary mutator
		void Insert ( ostream& fout );					//Boundary output
	
	private:
		string DepositType;
		float getEnvelope();
		void Get( ifstream& fin ) throw(AppError);
		void Put( ostream& fout );
};

class FastCashSet	{
	public:
		FastCashSet();
		void Extract( ifstream& fin ) throw(AppError);  //Boundary mutator
		void Insert ( ostream& fout );					//Boundary output
	
	private:
		void Get( ifstream& fin ) throw(AppError);
		void Put( ostream& fout );

};
*/
}

#endif 



Topic archived. No new replies allowed.