functions
i wanna know how i can use functions created in different classes inside of a other class
13 Replies
´´´cs
public static string DoMove(int Index, Pokémon target,Pokémon user)
{
Move move = user.Moves[Index];
if (move is DamageMove )
{
return ((DamageMove)move).DoDamage(user, target);
}
else if( move is HealingMove)
{
return ((HealingMove)move).DoHeal(user);
}
return ""; ´´´ the functions i want to use in here are DoDamage and DoHeal
return ""; ´´´ the functions i want to use in here are DoDamage and DoHeal
Since the methods are static...
ClassName.MethodName()
If they aren't, then you need an instancethats how i call them
?
No, you call both
DoDamage()
and DoHeal()
on an instance of Move
these functions are not static
Are they both methods of the
Move
class?so i will need a instance
Yeah
And you have one, so everything looks fine
What's the issue, then?
i also need to be able to make this code - each time when this gets used
how do i do that --PowerPoints?
(as a side note, you can have a cast automatically with an
is
operator, so your current code:)
(can just be this:)
What do you mean "make this code each time when it gets used"?
Make what code?
And what do you mean by "make", "run"?i mean make it minus
each time
off of the powerpoints
do i put in the the if and in the else if the statment --powerpoints?
Sure, try it
already did but because of the return statement it goes undetectable
also if u need more context i can show u what i need to make if that helps u
if u dont need it its fine just incase
Short description
A Pokémon can do both a damage move and a healing move.
Implementation
• Implement a function based on an index of a move and a Pokémon's information
of the execution in text
• First select the move that corresponds to the given index from the moves of the Pokémon
• Do the DoDamage execution or DoHeal execution respectively, if the move is a damage or
healingmove is
• Then enter the number of times the move can be performed (PowerPoints) with a to
downstairs
• Also return the text of the move execution in both cases