Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <string>
- #include <iostream>
- using namespace std;
- class Silnik{
- private:
- string producent;
- int pojemnosc;
- public:
- Silnik (string a, int b){
- producent = a;
- pojemnosc = b;
- };
- string producent_show(){
- return producent;
- }
- int pojemnosc_show(){
- return pojemnosc;
- }
- };
- class Device{
- private:
- const string producent;
- int obroty;
- Silnik silnik;
- public:
- Device (string producent, int c, string silnik_producent, int silnik_pojemnosc)
- :producent(producent), silnik(silnik_producent, silnik_pojemnosc)
- {
- obroty = c;
- };
- string producent_show() {
- return producent;
- }
- int obroty_show(){
- return obroty;
- }
- string silnik_producent_show(){
- return silnik.producent_show();
- }
- int silnik_pojemnosc_show(){
- return silnik.pojemnosc_show();
- }
- void Showtime(){
- cout<<"Urzadzenie:\n";
- cout<<"Producent urzadzenia: "<<producent_show()<<"\n";
- cout<<"Obroty urzadzenia: "<<obroty_show()<<"\n";
- cout<<"Producent silnika: "<<silnik_producent_show()<<"\n";
- cout<<"Pojemnosc silnika: "<<silnik_pojemnosc_show()<<"\n";
- }
- Device* szukaj(Device tab, int z)
- {
- int x = 0;
- Device* a = new Device[z];
- for ( int i = 0; i < 6; i++) {
- if(tab[i].producent_show() == tab[i].silnik_producent_show()){
- a[x] = tab[i];
- x++;
- }
- }
- return a;
- }
- };
- int zlicz(Device tab[])
- {
- int zlicz = 0;
- for ( int i = 0; i < 6; i++) {
- if(tab[i].producent_show() == tab[i].silnik_producent_show()){
- {
- zlicz++;
- }
- }
- return zlicz;
- };
- int main (){
- Device y[6] = {
- Device ("BMW", 8000, "BMW", 6),
- Device ("HONDA", 3000, "HONDA", 2),
- Device ("BMW", 6000, "HONDA", 4),
- Device ("MERCEDES", 7000, "BMW", 5),
- Device ("FORD", 5000, "FORD", 3),
- Device ("AUDI", 4000, "AUDI", 2),
- };
- int zlicz1=zlicz(y);
- Auto *a=szukaj(tab1,zlicz1);
- for (int i = 0; i < zlicz1; i++)
- {
- a[i].wypisz();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement