Advertisement
Alx09

Tema Lab1 POO

Sep 28th, 2020 (edited)
1,303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5.  
  6. class Data {
  7. private:
  8.     char nume[20], Pren[20], adresa[20], tele[20];
  9.     int age;
  10. public:
  11.     void Citire();
  12.     void Print();
  13. };
  14. void Data::Citire() {
  15.     cout << "nume = "; cin >> nume;
  16.     cout << "Prename = "; cin >> Pren;
  17.     cout << "Adresa = "; cin >> adresa;
  18.     cout << "Numar de telefon  = "; cin >> tele;
  19.     cout << "age = "; cin >> age;
  20.     cout << endl;
  21. }
  22.  
  23. void Data::Print() {
  24.     cout << "nume: " << nume << "\n";
  25.     cout << "Prename: " << Pren << "\n";
  26.     cout << "Adresa: " << adresa << "\n";
  27.     cout << "Numar telefon: " << tele << "\n";
  28.     cout << "age: " << age << "\n\n";
  29. }
  30.  
  31. class Sofer {
  32. private:
  33.     char nume[20], cnp[20], adresa[20];
  34.     int age;
  35.  
  36. public:
  37.     void Citire();
  38.     void Print();
  39.  
  40. };
  41.  
  42.  
  43. void Sofer::Citire() {
  44.  
  45.     cout << "nume= "; cin >> nume;
  46.     cout << "CNP = "; cin >> cnp;
  47.     cout << "Adresa = "; cin >> adresa;
  48.     cout << "age = "; cin >> age;
  49.     cout << endl;
  50.  
  51. }
  52.  
  53. void Sofer::Print() {
  54.     cout << "Nume Sofer: " << nume << "\n";
  55.     cout << "CNP: " << cnp << "\n";
  56.     cout << "Adresa: " << adresa << "\n";
  57.     cout << "age: " << age << "\n\n";
  58. }
  59.  
  60. class Masina {
  61. private:
  62.     char model[20], producator[20];
  63.     int an_Fab;
  64.     Sofer Driver;
  65. public:
  66.  
  67.     void Print();
  68.     void Citire();
  69. };
  70. void Masina::Print() {
  71.     cout << "Producator: " << producator << "\n";
  72.     cout << "Model: " << model << "\n";
  73.     cout << "Adresa: " << an_Fab << "\n\n";
  74.     Driver.Print();
  75.  
  76. }
  77.  
  78. void Masina::Citire() {
  79.  
  80.     cout << "Producator = "; cin >> producator;
  81.     cout << "Model = "; cin >> model;
  82.     cout << "An fabricate = "; cin >> an_Fab;
  83.     cout << endl;
  84.  
  85.     Driver.Citire();
  86. }
  87.  
  88.  
  89. int main() {
  90.     Data student;
  91.     student.Citire();
  92.     student.Print();
  93.     Masina Au;
  94.     Au.Citire();
  95.     Au.Print();
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement