I have an “Enemy” object that has a lot of “pistols.” Each pistol can fire a bullet. Storage "guns" uses an array. when the gun is launched, a bullet will be created. And the enemy object will have an array to store the "bullet".
So, I am thinking of the fire method. I think I'm creating firebulletFromGun in "enemy". It must have a parameter: "gun". while this method is called. The enemy pulp will be added to the array.
Another design is the "gun" method of fire. The "enemy" uses the "gun" method of fire. And the “gun” will return the “bullet” object, and it will be added to the “enemy” array.
Both methods may work, but which way is better? or are they the same? plx drop ur ideas / suggestions. THz
It depends on whether you want the bullet to remain “owned” by the enemy or gun.
, ( , " ", , ). " " , , , ( ) , . , , , . , .
, , , - , , , , . , , ( 1- , ), , , , .
, (.. , , ).
, "".
, " , ". , , . , , attack(), - fire() Gun, stab() .
attack()
fire()
stab()
. .
gun.fire(); // bang!
, , .
.
, - , . , , .
, , , .
, Enemy Gun. Fire BulletCount BulletMovement, .
Enemy
Gun
Fire
BulletCount
BulletMovement
, . , .
. , , - Gun. , , , gun.fire(), enemy.fire()
, . , . .
Source: https://habr.com/ru/post/1742593/More articles:Relative paths in C # - c #java Swing Listeners: components listening to each other - javaxslt broken: template does not match - xmlКак назначить значение параметра переменной в UNIX? - variablesКомпилировать/использовать источник unrar С++ для приложения iphone? - c++Using Third-Party RSS Feeds - rssPassing a string from C # to cpp using COM - c ++https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1742596/transformation-of-uml-diagrams-to-specification-z-using-xsl-transformation&usg=ALkJrhgv9G0CB_0ztYmBObIKxHyrpCwAsAA fast, Unicode-compatible, cross-platform text-based program editor that shows invisible ones like ZWSP? - cross-platformHow to create git in Red Hat Enterprise Linux 3? - gitAll Articles