Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions Account/Account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ using namespace std; // Forgive me
#include "Account.h"

// Account constructor initializes data member balance
Account::Account( int initialBalance )
Account::Account( int initialBalance ):Persoana()
{
balance = 0; // assume that the balance begins at 0
/* if initialBalance is greater than 0,
/* if initialBalance is greater than 0,
set this value as the balance of the Account; otherwise, balance remains 0 */
if ( initialBalance > 0 )
balance = initialBalance;
Expand All @@ -20,7 +20,9 @@ Account::Account( int initialBalance )
if ( initialBalance < 0 )
cout << "Error: Initial balance cannot be negative.\n" << endl;
} // end Account constructor

//Account::Account(int balance): Persoana(){
// balance =0;
//}
// credit (add) an amount to the account balance
void Account::credit( int amount )
{
Expand All @@ -41,4 +43,18 @@ void Account::debit( int amount)
int Account::getBalance()
{
return balance; // gives the value of balance to the calling function
} // end function getBalance
} // end function getBalance
int Account::plata(){
int sumaPlata;
cout<<"Introduceti suma de plata: ";
cin>>sumaPlata;
cout<<"Introduceti numele beneficiarului: ";
cin>>_beneficiar;
balance-=sumaPlata;
cout<<"Plata: "<<_beneficiar<<" Suma: "<<sumaPlata<<" CONT: "<<balance<<endl;
return balance;
}
ostream& operator<<(ostream& os,const Account& cont){
os<<cont._nume<<" "<<cont._prenume<<" CONT: "<<cont.balance<<endl;
return os;
}
25 changes: 19 additions & 6 deletions Account/Account.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
#ifndef ACCOUNT_H_INCLUDED
#define ACCOUNT_H_INCLUDED
/***********************
Trevor Richardson
Account.h
***********************/
class Account
{
private:
#include <iostream>
using namespace std;
#include "../AcountMhcrnl/persoana.h"
#include <string>
class Account: public Persoana{
private:
int balance; // data member that stores the balance

public:
string _beneficiar;
public:
Account();
Account( int ); // constructor initializes balance
Account (string nume, string prenume, int balance);
void credit( int ); // add an amount to the account balance
void debit( int ); // subtract an amount to the account balance
int getBalance(); // return the account balance
}; // end class Account
int plata(void);
/**
Add friend function for print Account
*/
friend ostream& operator<<(ostream& os, const Account& cont);
}; // end class Account
#endif
47 changes: 47 additions & 0 deletions AcountMhcrnl/AcountMhcrnl.cbp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="AcountMhcrnl" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Debug">
<Option output="bin/Debug/AcountMhcrnl" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Debug/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-g" />
</Compiler>
</Target>
<Target title="Release">
<Option output="bin/Release/AcountMhcrnl" prefix_auto="1" extension_auto="1" />
<Option object_output="obj/Release/" />
<Option type="1" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O2" />
</Compiler>
<Linker>
<Add option="-s" />
</Linker>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-fexceptions" />
</Compiler>
<Unit filename="../Account/Account.cpp" />
<Unit filename="../Account/Account.h" />
<Unit filename="main.cpp" />
<Unit filename="persoana.cpp" />
<Unit filename="persoana.h" />
<Extensions>
<code_completion />
<envvars />
<debugger />
<lib_finder disable_auto="1" />
</Extensions>
</Project>
</CodeBlocks_project_file>
22 changes: 22 additions & 0 deletions AcountMhcrnl/AcountMhcrnl.depend
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# depslib dependency file v1.0
1486203966 source:c:\users\mhcrnl\desktop\cpp-6\account\account.cpp
<iostream>
"Account.h"

1486206067 c:\users\mhcrnl\desktop\cpp-6\account\account.h
<iostream>
"../AcountMhcrnl/persoana.h"
<string>

1486205614 source:c:\users\mhcrnl\desktop\cpp-6\acountmhcrnl\main.cpp
<iostream>
"../Account/Account.h"
"persoana.h"

1486204954 c:\users\mhcrnl\desktop\cpp-6\acountmhcrnl\persoana.h
<iostream>
<string>

1486202980 source:c:\users\mhcrnl\desktop\cpp-6\acountmhcrnl\persoana.cpp
"persoana.h"

30 changes: 30 additions & 0 deletions AcountMhcrnl/AcountMhcrnl.layout
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="main.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="320" topLine="0" />
</Cursor>
</File>
<File name="..\Account\Account.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1691" topLine="22" />
</Cursor>
</File>
<File name="..\Account\Account.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="360" topLine="0" />
</Cursor>
</File>
<File name="persoana.cpp" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="25" topLine="0" />
</Cursor>
</File>
<File name="persoana.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="183" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>
20 changes: 20 additions & 0 deletions AcountMhcrnl/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <iostream>
#include "../Account/Account.h"
#include "persoana.h"
using namespace std;

int main()
{
cout << "Hello world!" << endl;
Account cont(50);

cout<<cont.getBalance()<<endl;
cont.credit(178);
cout<<cont.getBalance()<<endl;
cout << cont;
cout<<cont.plata()<<endl;
cout<<cont;
//Persoana pers;
//pers.getBalance(200);
return 0;
}
18 changes: 18 additions & 0 deletions AcountMhcrnl/persoana.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#include "persoana.h"

Persoana::Persoana(){
_nume = setNume();
_prenume = setPrenume();
}

string Persoana::setNume(){
cout<<"Insert person firstname: ";
cin>>_nume;
return _nume;
}

string Persoana::setPrenume(){
cout<<"Insert person lastname: ";
cin>>_prenume;
return _prenume;
}
23 changes: 23 additions & 0 deletions AcountMhcrnl/persoana.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef PERSOANA_H_INCLUDED
#define PERSOANA_H_INCLUDED
#include <iostream>
#include <string>
//#include "../Account/Account.h"
using namespace std;
class Persoana {
protected:
string _nume;
string _prenume;
public:
/**
Constructor
*/
Persoana();
/**
get/set
*/
string setNume(void);
string setPrenume(void);
};

#endif // PERSOANA_H_INCLUDED