Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Node.h file , paste made by @edensheiko
- #pragma once
- #include <string>
- using namespace std;
- class Node
- {
- private:
- double _account;
- int _id;
- Node *next;
- string _name;
- static int idGenrator;
- public:
- friend void print(Node&n);
- Node();
- ~Node();
- Node(string name,double account=0.0);
- static int getidGenrator();
- string Getname()const ;
- double Getaccount()const;
- void Setaccount(double);
- };
- // node.cpp file
- #include "Node.h"
- #include <iostream>
- #include <string>
- using namespace std;
- int Node::idGenrator = 0;
- Node::Node()
- {
- }
- Node::~Node()
- {
- }
- Node::Node(string name, double account)
- {
- this->_name = name;
- this->_account = account;
- this->_id = getidGenrator();
- }
- int Node::getidGenrator()
- {
- ++idGenrator;
- // can be called insted of ++idGenrator
- return idGenrator;
- }
- string Node::Getname() const
- {
- return this->_name;
- }
- double Node::Getaccount() const
- {
- return this->_id;
- }
- void Node::Setaccount(double account) //if there is a deposit
- {
- this->_account += account > 0 ? account : 0;
- }
- void print(Node &n)
- {
- cout << "ID:" << n._id << endl;
- cout << "Name:" << n._name << endl;
- cout << "account balance:" << n._account << endl;
- }
- // main.cpp file
- #include <iostream>
- #include "Node.h"
- using namespace std;
- void main()
- {
- //sNode::getidGenrator();
- Node v1("eden",2000);
- Node v2("elon mask", 50000);
- //cout << "first name:" << v1.Getname() << endl<< "secand name:" << v2.Getname() << endl;
- //cout << "acc:" << v1.Getaccount() << endl << "acc:" << v2.Getaccount() << endl;
- //print cheack
- // Deposit//
- v1.Setaccount(10);
- print(v1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement