Create a Duck class. The attributes of Duck are: number and energy Implement the following methods: Duck(int); //Constructor to assign a number to duck and set its energy to 10 void eat(); //when duck eats, energy increases by 3 void swim(); //when duck swims, energy decreases by 2 void walk(); //when duck walks, energy decreases by 1 void print(); //prints energy of duck Then Create a Monkey class. The attributes of Monkey are: number and energy Implement the following methods: Monkey(int); //Constructor to assign a number to monkey and set its energy to 10 void eat(); //when monkey eats, energy increases by 10 void jump(); //when monkey jumps, energy decreases by 4 void walk(); //when monkey walks, energy decreases by 2 void print(); //prints energy of monkey You need to make a Zoo with following requirements: Duck lives in a Zoo Monkey lives in a Zoo Zoo has 10 ducks (Hint: You will need an array of pointers to Duck class) Zoo has 5 monkeys (Hint: You will need an array of pointers to Monkey class) Zoo can make all ducks eat Zoo can make all monkeys eat Zoo can make all ducks swim Zoo can make all ducks walk Zoo can print energies of all ducks Zoo can print energies of all monkeys Overload all the functions of Zoo class with 'number of ducks'/'number of monkeys' as parameter. Classes should be defined in Functions.h Additional function(s) should be written in Functions.cpp and used in main.cpp
Create a Duck class.
The attributes of Duck are: number and energy Implement the following methods: Duck(int); //Constructor to assign a number to duck and set its energy to 10 void eat(); //when duck eats, energy increases by 3 void swim(); //when duck swims, energy decreases by 2 void walk(); //when duck walks, energy decreases by 1 void print(); //prints energy of duck
Then
Create a Monkey class.
The attributes of Monkey are: number and energy Implement the following methods: Monkey(int); //Constructor to assign a number to monkey and set its energy to 10 void eat(); //when monkey eats, energy increases by 10 void jump(); //when monkey jumps, energy decreases by 4 void walk(); //when monkey walks, energy decreases by 2 void print(); //prints energy of monkey
You need to make a Zoo with following requirements:
Duck lives in a Zoo Monkey lives in a Zoo Zoo has 10 ducks (Hint: You will need an array of pointers to Duck class) Zoo has 5 monkeys (Hint: You will need an array of pointers to Monkey class) Zoo can make all ducks eat Zoo can make all monkeys eat Zoo can make all ducks swim Zoo can make all ducks walk Zoo can print energies of all ducks Zoo can print energies of all monkeys
Overload all the functions of Zoo class with 'number of ducks'/'number of monkeys' as parameter.
Classes should be defined in Functions.h
Additional function(s) should be written in Functions.cpp and used in main.cpp
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images