在java中的输出怎么是红色的字(黑色字体是正常的)?
packagefuture;abstractclassPerson{privateStringname;privateintage;publicPerson(String...
package future;
abstract class Person{
private String name;
private int age;
public Person(String name, int age) {
this.name=name;
this.age=age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public abstract void want();
}
class Student extends Person{
private int score;
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public Student(String name, int age,int score) {
super(name, age);
this.score=score;
}
public void want() {
System.err.println("姓名:"+getName()+" 年龄:"+getAge()+" 成绩:"+getScore());
}
}
class Worker extends Person{
private int money;
public int getMoney() {
return money;
}
public void setMoney(int money) {
this.money = money;
}
public Worker(String name, int age,int money) {
super(name, age);
this.money=money;
}
public void want() {
System.err.println("姓名:"+getName()+" 年龄:"+getAge()+" 成绩:"+getMoney());
}
}
public class D01 {
public static void main(String[] args) {
Student s=new Student("熊明", 13, 100);
s.want();
Worker w=new Worker("大明", 43, 6000);
w.want();
}
} 展开
abstract class Person{
private String name;
private int age;
public Person(String name, int age) {
this.name=name;
this.age=age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public abstract void want();
}
class Student extends Person{
private int score;
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
public Student(String name, int age,int score) {
super(name, age);
this.score=score;
}
public void want() {
System.err.println("姓名:"+getName()+" 年龄:"+getAge()+" 成绩:"+getScore());
}
}
class Worker extends Person{
private int money;
public int getMoney() {
return money;
}
public void setMoney(int money) {
this.money = money;
}
public Worker(String name, int age,int money) {
super(name, age);
this.money=money;
}
public void want() {
System.err.println("姓名:"+getName()+" 年龄:"+getAge()+" 成绩:"+getMoney());
}
}
public class D01 {
public static void main(String[] args) {
Student s=new Student("熊明", 13, 100);
s.want();
Worker w=new Worker("大明", 43, 6000);
w.want();
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询