1
Answer

Objects without an immediate common parent and polymorphism

Instructions here:
 
[img]http://i.imgur.com/Nr2o9nt.png[/img]
http://i.imgur.com/Nr2o9nt.png
 
[img]http://i.imgur.com/YwxGjhm.png[/img] 
http://i.imgur.com/YwxGjhm.png
 
Hi, If I understand the question right, the CalculateComplexityScore() method should take either a Cat, Dog or Butterfly object and perform actions on their properties (e.g. on ActionType) depending on wither the object is of Cat, Dog or Butterfly.
 
But Cat, Dog and Butterfly do not have a common immediate parents. They can't be redefined to have one. I have given CatBase, DogBase and Butterfly base a common parent: AnimalBase, but this would allow CalculateComplexityScore to take objects of CatBase, DogBase or ButterflyBase. If you read the instructions, this should not happen.
 
My attempt to solve this was to define an ActionType property as a virtual property in AnimalBase and have Cat, Dog and Butterfly override it but this is still not quite right.

Any help before tomorrow?
Answers (1)
1
Manav Pandya

Manav Pandya

NA 7.1k 24k 7y
Hello 
 
To acess such functionality , there two options :
 
1 . To use predefined method
 
2 . To use it's DLL 
 
For example please find folllowing article for brightness control with c# :
 
https://www.codeproject.com/Tips/855454/How-To-Change-Screen-Brightness-in-Csharp 
 
https://www.codeproject.com/Articles/47355/Setting-Screen-Brightness-in-C
 
Thanks 
Accepted
1
Manav Pandya

Manav Pandya

NA 7.1k 24k 7y
Hello 
 
There are different DLL's available for that 
 
Just google it and you can find many of them easily 
 
Thanks 
1
Dahen Mustafa

Dahen Mustafa

NA 11 226 7y
How about other types of native controls? Like volume,pause, print screen,esp, others.....???