This's my actual code...I'm having a bit of difficulty about some coding: in class autoreg defined de <map> as public...Should I put them has private instead?Another thing,once I have in autoreg a method in_ov(...) whose arguments are the objects of vehicle and owner(since that way it's easier to be,instead of sending all the attribute parameters ' of the classes like name,address,etc.),I have created a autoreg.cpp so that I can call that function from main .
In main I want to call that function,since user introduced data before,I would like to send them to the method in autoreg.cpp so that it could keep the data in the variables created created within the classes vehicle and owner and,later on,in that same function,create pair between the vehicles and owners association...I just don't have a clue how will I send all these data on the function since what I have there are the objects of both classes(owner and vehicle).
Could someone please help me out a bit with my code?
Just one last question: Is it necessary for constructors to exist in clas owner and vehicle given that who will manage that is the autoreg class throught their own add,clear methods?
Code:
#include<iostream>
#include <string>
using namespace std;
class vehicle
{
private:
string license;
string brand;
string color;
string model;
long cil;
long ccv;
long nowner;
public:
vehicle();
vehicle(string str_ license,string str_brand,string str_color,string str_model,long n_cil,long n_ccv,long n_nowner);
string get license(void) const;
void set license(string str_ license);
string getbrand(void) const;
void setbrand(string str_brand);
string getcolor(void) const;
void setcolor(string str_color);
string getmodel(void) const;
void setmodel(string str_model);
long getcil(void) const;
void setcil(unsigned long n_cil);
long getccv(void) const;
void setccv(long n_ccv);
long getnowner(void) const;
void setnowner(long n_nowner);
};
Code:
#include <iostream>
#include <string>
using namespace std;
class owner
{
private:
string name;
long id;
string address;
long phone;
public:
owner();
owner(string str_name,long sid,string str_address,long sphone);
string getname(void) const;
void setname(string str_name);
string getaddress(void) const;
void setaddress(string str_address);
long getid(void) const;
void setid(long sid);
long getphone(void) const;
void setphone(long sphone);
};
Code:
#include <iostream>
#include <map>
#include <string>
#include "vehicle.h"
#include "owner.h"
using namespace std;
class autoreg
{
public:
map<string,vehicle>;
map<long, owner>;
multimap<long, string>;
map<string, long>;
void in_ov(vehicle v,owner p);
void er_vehicle(vehicle v);
void er_ov(vehicle v,owner p);
search(vehicle v,owner p);
}
autoreg.cpp
Code:
#include "autoreg.h"
using namespace std;
cra::void in_ov(vehicle v,owner p)
{
}
cra::er_vehicle(vehicle v);
{
}
cra::er_ov(vehicle v,owner p);
{
}
cra::search(vehicle v,owner p);
{
}
Code:
#include <stdlib.h>
#include <iostream>
#include <string>
#include "autoreg.h"
#include "vehicle.h"
#include "owner.h"
void main()
{
char input;
string name,add,brand,model,color,lic;
long id,ph,cil,ccv,nrowner;
vehicle v;
owner p;
cra r;
cout << "AutoREG" "\n"<< endl;
while( 1 )
{
cout << "Add client and vehicle(a):""\n"<< endl;
cout << "Remove owner(r):""\n"<< endl;
cout << "Remove vehicle(x):""\n"<<endl ;
cout << "Refresh owners and vehicles(z):""\n"<<endl ;
cout << "List vehicles(v):" "\n"<<endl;
cout << "List owners(o):""\n"<< endl;
cout << "Exit(e): ""\n"<< endl;
cin >> input;
switch( input )
{
case 'a':
{
cout <<"Name: " <<endl;
cin>>name;
cout<<"ID: "<<endl;
cin >>id;
cout<<"Address: "<<endl;
cin>>add;
cout<<"Phone: "<<endl;
cin >>ph;
cout <<"Brand: "<<endl;
cin >>brand;
cout << "License: "<<endl;
cin >>lic;
cout << "Color: "<<endl;
cin >>colorr;
cout << "Model: "<<endl;
cin >>model;
cout << "Cil: "<<endl;
cin >>cil;
cout<<"ccv: "<<endl;
cin >>pot;
cout<<"Nr de old owners: "<<endl;
cin >>nrowner;
r.in_ov(v,p);
}
continue;
case 's':
exit(0);
default:
cout << "Error: Input valid char " << input << '\n';
break;
}
}
}
[B]Owner.cppB]
Code:
#include <iostream>
#include <string>
#include "owner.h"
owner::owner(string str_name,long sid,string str_address,long sphone)
{
name = str_name;
id=sid;
phone=sphone;
adress = str_adress;
}
string owner::getname() const
{
return name;
};
void owner::setname(string str_name)
{
name=str_name;
};
string owner::getadress() const
{
return adress;
};
void owner::setadress(string str_adress)
{
adress=str_adress;
};
long owner::getid() const
{
return id;
};
void owner::setid(long sbi)
{
id=sid;
};
long owner::getphone() const
{
return phone;
};
void owner::setphone(long sphone)
{
phone=sphone;
};
Code:
#include<iostream>
#include<string>
#include "vehicle.h"
vehicle::vehicle(string str_ license,string str_brand,string str_color,string str_model,long n_cil,long n_ccv,long n_nowner)
{
license=str_license;
brand=str_brand;
color=str_color;
model=str_model;
cil=n_cil;
ccv=n_ccv;
nowner=n_nowner;
}
PS:Feel free to give suggestions or point out if there's code which isn't necessary,or even suggest corrections!