Question: Using the C++ programming language, write a program that simulates a colony of bunny rabbits. Each bunny object must have the following data members: -
Using the C++ programming language, write a program that simulates a colony of bunny rabbits. Each bunny object must have the following data members:
- sex: Male, Female (random at creation 50/50) -
color: white, brown, black, spotted -
age: 0-10 (years old) -
name: randomly chosen at creation from a list of bunny names
- radioactive_mutant_vampire_bunny: true/false (decided at time of bunny creation with 2% probability)
At program initialization, 5 bunnies must be created and given random colors. During each pass afterwards, the bunnies age by 1 year. So long as there is at least one male bunny aged 2 or older, a new bunny is created for each female bunny aged 2 or older. For example, if there is one adult male and three adult females, three new bunnies would be born. New bunnies born should be the same color as their mother. If a bunny becomes older than 10 years old, it dies. If a radioactive mutant vampire bunny is born then it will change exactly one non radioactive bunny into a radioactive vampire bunny. If there are two radioactive mutant vampire bunnies two bunnies will be changed each pass and so on. Radioactive vampire bunnies are excluded from regular breeding and do not count as adult bunnies. They do not die until they reach age 50. D
uring each pass, the program should
output a list of all the bunnies in the colony along with all the bunnies details, sorted by age
output each of the events for a pass, such as Bunny Thumper was born! Bunny Fufu was born! Radioactive Mutant Vampire Bunny Darth Maul was born! Bunny Julius Caesar died! write all screen output to a file.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
