public class 主函数 {
public static void main(String[] args) {
// TODO Auto-generated method stub
//面向对象编程三条主线
/*1.JAVA类及类的成员:属性,方法,构造器,代码块,内部类
属性:成员变量
方法:行为功能
2.面向对象三大特征:封装,继承,多态,(抽象)
3.其他关键字:this,super,static,final,abstract,interface,package,import
*/
Person I=new Person(); //声明对象
I.hp=100; //属性的赋值
I.mp=200;
I.outern(); //方法的调用
}
}
对象创建:
package 学习笔记;
public class 玩家类 {
}
class Person{
String name;
int sp,atk,def,luk,hp,mp;
public void outern() {
System.out.println("此单为的HP剩余量为"+this.hp);
System.out.print("此单为的MP剩余量为"+this.mp);
}
}