Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5.  
  6. class contact{
  7. private:
  8.  
  9. string phone;
  10.  
  11. public:
  12.  
  13. contact(string p){
  14. phone=p;
  15. }
  16.  
  17. string getphone(){
  18. return phone;
  19. }
  20. };
  21. class car{
  22. private:
  23. string plate;
  24.  
  25. public:
  26.  
  27. car(string p){
  28. plate=p;
  29. }
  30. string getplate(){
  31. return plate;
  32.  
  33. }
  34. };
  35. class custemer{
  36. private:
  37.  
  38. string name;
  39. contact cont;
  40. car *ca;
  41.  
  42.  
  43. public:
  44.  
  45.  
  46. custemer( string na, string ph):cont(ph){
  47. name= na;
  48. }
  49. string getname(){
  50. return name;
  51. }
  52.  
  53. string getphonenumber(){
  54. return cont.getphone();
  55. }
  56.  
  57. string getrentedcarplate(){
  58.  
  59. return ca->getplate();
  60.  
  61. }
  62. void setrentedcar(car*c){
  63. ca=c;
  64. }
  65.  
  66.  
  67.  
  68. };
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78. int main()
  79. {
  80. custemer obj[3]= { custemer ("Ahmad Kamal", "015-75769800"), custemer ("Omar Abdullah","014-8889900"), custemer("Hassan Ali", ("012-1234567"))};
  81.  
  82. car *ca= new car("JSQ245");
  83. car *ca1= new car("NIL");
  84. car *ca2= new car("ABC890");
  85.  
  86. obj[0].setrentedcar(ca);
  87. obj[1].setrentedcar(ca1);
  88. obj[2].setrentedcar(ca2);
  89.  
  90. cout<<"custemer name: "<<obj[0].getname()<<endl;
  91. cout<<"phone number: "<< obj[0].getphonenumber()<<endl;
  92. cout<<"rented car: "<< obj[0].getrentedcarplate()<<endl;
  93. cout<< endl;
  94.  
  95. cout<<"custemer name: "<<obj[1].getname()<<endl;
  96. cout<<"phone number: "<< obj[1].getphonenumber()<<endl;
  97. cout<<"rented car: "<< obj[1].getrentedcarplate()<<endl;
  98. cout<<endl;
  99.  
  100. cout<<"custemer name: "<<obj[2].getname()<<endl;
  101. cout<<"phone number: "<< obj[2].getphonenumber()<<endl;
  102. cout<<"rented car: "<< obj[2].getrentedcarplate()<<endl;
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114. return 0;
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement