Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Dog{
- friend class Person;
- string name;
- bool hungry;
- public:
- Dog(string imiePsa);
- string getName();
- bool isHungry();
- void zmianaCzyGlodny();
- };
- Dog::Dog(string imiePsa){
- name = imiePsa;
- hungry = true;
- };
- string Dog::getName() {
- return name;
- };
- bool Dog::isHungry() {
- return hungry;
- };
- void Dog::zmianaCzyGlodny() {
- hungry=false;
- }
- class Person{
- string name;
- Dog *dogs[5];
- int ileMamPsow;
- public:
- Person(string imieOsoba);
- void feedDog(int idPsa);
- void feedAllDogs();
- void addDog(Dog * wskPies);
- void removeDog(int idPsa);
- Dog *getDog(int idPsa);
- void printDogNames();
- };
- Person::Person(string imieOsoba) {
- name = imieOsoba;
- ileMamPsow=0;
- };
- void Person::feedDog(int idPsa) {
- dogs[idPsa]->zmianaCzyGlodny();
- }
- void Person::feedAllDogs() {
- for(int i=0; i<ileMamPsow; i++){
- dogs[i]->zmianaCzyGlodny();
- }
- }
- void Person::addDog(Dog *wskPies) {
- dogs[ileMamPsow]=wskPies;
- ileMamPsow++;
- }
- void Person::removeDog(int idPsa) {
- dogs[idPsa]=NULL;
- for(int i=idPsa; i<=ileMamPsow; i++){
- if(i==5){
- dogs[4]= dogs[5];
- dogs[5]=NULL;
- }else{
- dogs[i]=dogs[i+1];
- }
- }
- ileMamPsow--;
- }
- Dog* Person::getDog(int idPsa) {
- return dogs[idPsa];
- }
- void Person::printDogNames() {
- for(int i =0; i<ileMamPsow; i++) {
- cout << dogs[i]->getName();
- }
- }
- int main() {
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement