Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- template <class Item> class Wzor{
- static const int size = 6;
- Item Tab_[size];
- int counter_;
- public:
- Wzor(){counter_ = 0;};
- Item addA(Item dodaj){
- if(counter_ <= 6){
- Tab_[counter_] = dodaj;
- counter_++;
- }
- }
- Item deleteA(int usun){
- if(usun <= 6 && counter_ >= usun){
- Tab_[usun] = Tab_[counter_];
- counter_--;
- }
- }
- };
- class Animal{
- string aName_;
- float aWeight_;
- int aBirth_;
- string aId_;
- public:
- Animal(string aName, float aWeight, int aBirth, string aId) : aName_(aName), aWeight_(aWeight), aBirth_(aBirth), aId_(aId){};
- Animal show(){
- cout << aName_ << " " << aWeight_ << " " << aBirth_ << " " << aId_ << " ";
- }
- Animal operator = (Animal tottenham){
- aName_ = tottenham.aName_;
- aWeight_ = tottenham.aWeight_;
- aBirth_ = tottenham.aBirth_;
- aId_ = tottenham.aId_;
- }
- };
- class Building{
- string bName_;
- float aGps_;
- float bGps_;
- float bHeight_;
- public:
- Building(string bName, float aGps, float bGps, float bHeight) : bName_(bName), aGps_(aGps), bGps_(bGps), bHeight_(bHeight){};
- Building show(){
- cout << bName_ << " " << aGps_ << " " << bGps_ << " " << bHeight_ << " ";
- }
- Building operator = (Building tottenham){
- bName_ = tottenham.bName_;
- aGps_ = tottenham.aGps_;
- bGps_ = tottenham.bGps_;
- bHeight_ = tottenham.bHeight_;
- }
- };
- int main()
- {
- string Aname[6], Aid[6];
- float Aweight[6];
- int Abirth[6];
- string Bname[6];
- float Bgps[6], Bbgps[6], Bheight[6];
- bool liczba;
- for(int i = 0 ; i < 4; i++){
- string temp = Aname[i];
- string tmp = Bname[i];
- do{
- liczba = 1;
- cin >> temp;
- for(int j = 0; j < temp.size(); j++){
- if(static_cast<int> (temp[j]) == 32){
- liczba = 0;
- break;
- }
- }
- }while(liczba == 0);
- Aname[i] = temp;
- do{
- bool kropka = 1;
- liczba = 1;
- cin >>temp;
- for(int j = 0; j < temp.size(); j++){
- if(static_cast<int>(temp[j]) >= 48 and static_cast<int>(temp[j]) <= 57){
- }else if(static_cast<int> (temp[j]) == 46 and kropka == 0){
- kropka = 1;
- }else{
- liczba = 0;
- break;
- }
- }
- }while(liczba == 0);
- Aweight[i] = stof(temp);
- do{
- liczba = 1;
- cin >>temp;
- for(int j = 0; j < temp.size(); j++){
- if(static_cast<int>(temp[j]) >= 48 and static_cast<int>(temp[j]) <= 57){
- }
- }
- }while(liczba == 0);
- Abirth[i] = stoi(temp);
- do{
- liczba = 1;
- cin >> temp;
- for(int j = 0; j < tmp.size(); j++){
- if(static_cast<int> (tmp[j]) == 32){
- liczba = 0;
- break;
- }
- }
- }while(liczba == 0);
- Bname[i] = tmp;
- do{
- bool kropka = 1;
- liczba = 1;
- cin >>tmp;
- for(int j = 0; j < tmp.size(); j++){
- if(static_cast<int>(tmp[j]) >= 48 and static_cast<int>(tmp[j]) <= 57){
- }else if(static_cast<int> (tmp[j]) == 46 and kropka == 0){
- kropka = 1;
- }else{
- liczba = 0;
- break;
- }
- }
- }while(liczba == 0);
- Bgps[i] = stof(tmp);
- do{
- bool kropka = 1;
- liczba = 1;
- cin >>tmp;
- for(int j = 0; j < tmp.size(); j++){
- if(static_cast<int>(tmp[j]) >= 48 and static_cast<int>(tmp[j]) <= 57){
- }else if(static_cast<int> (tmp[j]) == 46 and kropka == 0){
- kropka = 1;
- }else{
- liczba = 0;
- break;
- }
- }
- }while(liczba == 0);
- Bgps[i] = stof(tmp);
- do{
- bool kropka = 1;
- liczba = 1;
- cin >>tmp;
- for(int j = 0; j < tmp.size(); j++){
- if(static_cast<int>(tmp[j]) >= 48 and static_cast<int>(tmp[j]) <= 57){
- }else if(static_cast<int> (tmp[j]) == 46 and kropka == 0){
- kropka = 1;
- }else{
- liczba = 0;
- break;
- }
- }
- }while(liczba == 0);
- Bheight[i] = stof(tmp);
- }
- Animal a1(Aname[0], Aweight[0], Abirth[0], Aid[0]);
- Animal a2(Aname[1], Aweight[1], Abirth[1], Aid[1]);
- Animal a3(Aname[2], Aweight[2], Abirth[2], Aid[2]);
- Animal a4(Aname[3], Aweight[3], Abirth[3], Aid[3]);
- Wzor<Animal> animalList;
- animalList.addA(a1);
- animalList.addA(a2);
- animalList.addA(a3);
- animalList.addA(a4);
- Building b1(Bname[0], Bgps[0], Bbgps[0], Bheight[0]);
- Building b2(Bname[1], Bgps[1], Bbgps[1], Bheight[1]);
- Building b3(Bname[2], Bgps[2], Bbgps[2], Bheight[2]);
- Building b4(Bname[3], Bgps[3], Bbgps[3], Bheight[3]);
- Wzor<Building> buildingList;
- buildingList.addA(b1);
- buildingList.addA(b2);
- buildingList.addA(b3);
- buildingList.addA(b4);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement