java object-oriented - Using explain LOL

Introducing the basic concepts of object-oriented (introducing only)

I believe you certainly played DOTA or LOL, never played, must have heard around a lot of friends playing the game

Suppose that we want to design a LOL this game, using the object-oriented thinking to design, how to do?

Step 1: Design This class hero

LOL There are a lot of heroes, such as

Blind monk, team battles can be lost, Timo must die, Galen, piano woman

All of these heroes, there are some common state
, for example, they all have names , the HP , armor , movement speed , and so on
so that we can design a thing called class representatives hero a thing
like : Hero (Hero)
state : name, blood, armor, speed

NOTE: This embodiment uses three kinds of data types are String (String), a float (float), int (integer), expand back
NOTE: This class is not the main method, do not attempt to run it. Not all classes are the main method.
Here Insert Picture Description

public class Hero {
     
    String name; //姓名
     
    float hp; //血量
     
    float armor; //护甲
     
    int moveSpeed; //移动速度
}
Released two original article · won praise 0 · Views 90

Guess you like

Origin blog.csdn.net/pikaqiu123_/article/details/104738507