#Duck simulator

1 messages · Page 1 of 1 (latest)

rich heath
#

https://github.com/iamagithublearner/DuckSimulator
i am trying to make a duck simulator (using factory design pattern so maybe i can learn that design pattern)
i have a duck base class , 2 sub classes , MallardDuck and RedHeadDuck
So according to the design pattern , i have to separate things that change from things that do not change.
things that change would be , the behaviors , flyingBehavior and QuackingBehavior since each duck might have diff fly and quack behaviors.
Currently the Base class has 2 instance variable: flyBehavior and quackBehavior
and there are two methods: performQuack() and performFly()
these instance variables hold a reference ro a specific behavior at runtime , for example "flyhigh" "nofly" or "loudQuack" etc..

but i think i am not implementing this correctly in the cpp code , please let me know what i am doing wrong and if i missed to provide any important info.
thank you for your time!

GitHub

Design patterns with Ducks. Contribute to iamagithublearner/DuckSimulator development by creating an account on GitHub.

vivid kiteBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

foggy fog
#

Talks I liked that seem related (without looking at your code)
https://youtu.be/motLOioLJfg
https://youtu.be/OvO2NR7pXjg

https://cppcon.org/
https://github.com/CppCon/CppCon2021

Designing good, maintainable classes is a challenge. Sometimes it even feels like there is a decision to make in every single line of code. This talk will help you master this challenge. It will explain …

  • … why small classes are beautiful;
  • … why it is so important to encapsulate v...
▶ Play video

https://cppcon.org/
https://github.com/CppCon/CppCon2021

Design Patterns have proven to be useful over several decades and knowledge about them is still very important to design robust, decoupled systems. However, in recent decades a lot of misconceptions have piled up, many based on misunderstandings about software design in general and Des...

▶ Play video