Mage m = new Mage( strength: 68, intelligence: 180);//实例化法师对象
System.out.println( 战士攻击造成的伤害:“+w.attack();
Mage m = new Mage(
Mage m = new Mage( strength: 68, intelligence: 180);//实例化法师对象
System.out.println( 战士攻击造成的伤害:“+w.attack(); strength: 68, intelligence: 180);//实例化法师对象
System.out.println( 战士攻击造成的伤害:“+w.attack();
给个参考例子:
public class Demo {
public static void main(String[] args) {
Person p = new Person( "小明", 12) ;
Student s = new Student ("小红", 18, 78.5) ;
}
}
class Person{
String name;
int age;
public Person(String name, int age) {
this.name= name;
this.age =age;
}
}
class Student extends Person{
double score;
public Student(String name, int age, double score) {
super(name, age);
this.score = score;
}
}
如有帮助,请采纳!