Game modeling

Asked

Viewed 77 times

0

EnunciadoEnunciadoThe game will be fighting between pairs of characters.

Classes that are required to implement the following: Personagem (abstract class) -> Orc / Humanos (interfaces) -> Arqueiro (Human) / Ogro (Orc).

In short, it has an abstract class Personagens, below it two interface classes (Humano and Orc) and below these classes as the classes Arqueiro, and two others that are Humanos and Ogros and two others that are Orc.

In the statement you have the attributes for each character type and the values for that.

The attributes I must define them in the abstract class Personagem or in each character’s referenced interface? Remembering that each character type has different attributes.

Unstated asks to create two 100 position vectors, one vector for each type (Orc and Humano). Can I create interface vectors? If so, how to access objects?

  • Right, I understood what you meant. Maybe I got a little confused even. I’ll put pictures of the statement to be clearer. Thank you!

  • Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful to you. You can also vote on any question or answer you find useful on the entire site

1 answer

1

What you call an attribute, and you must have learned from some material that uses the wrong name, actually is called field.

Common fields can go in the abstract class, the specifics in other derivatives. If there’s nothing in common or what you have in common is circumstantial, it makes no sense to have abstract class.

I find it strange that each type of character is an interface. Even stranger is to imply that the interfaces inherit from class, which is impossible. It may be that your question is confused, but if it is what is in the statement I think it should escape from it (indeed after the issue it is perceived that the statement).

It can create vectors of any type, including interfaces. Of course, when placing an element it needs to be concrete and it should be a type that implements this interface. Access is done normally, no difference.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.