参考程序:
public class Student {private String name
public String getName() {
return name
}
public void setName(String name) {
this.name = name
}
吵档歼public void goHome(Traffic t){
System.out.println("学生:"+this.name)
t.run()
}
public Student(String name) {
this.name = name
}
}
public abstract class Traffic {
protected double speed
public void run(){
}
}
public class Bus extends Traffic{
@Override
public void run() {
System.out.println("时速为"+super.speed+"公里每小时的汽车正在嘀嗒嘀嗒的开着.")
}
public Bus(double busSpeed) {
super.speed = busSpeed
}
}
public class Train extends Traffic {
@Override
public void run() {
System.out.println("时速为"+super.speed+"公里每小时的火车正在况且况且的开着.")
升冲 }
public Train(double trainSpeed) {
super.speed = trainSpeed
}
}
public class 蠢碰AirPlan extends Traffic {
@Override
public void run() {
System.out.println("时速为"+super.speed+"公里每小时的飞机正在吴屋吴屋的开着.")
}
public AirPlan(double airPlanSpeed) {
super.speed = airPlanSpeed
}
}
public class Test {
public static void main(String[] args) {
Traffic traffic1 = new Bus(40)
Student student = new Student("小明")
student.goHome(traffic1)
Traffic traffic2 = new Train(120)
Student student2 = new Student("小花")
student2.goHome(traffic2)
Traffic traffic3 = new AirPlan(300)
Student student3 = new Student("小红")
student3.goHome(traffic3)
}
}
如果你开发的是java窗口应用程序,那么输入密码的文件框使用:JPasswordField jPasswordField = new JPasswordField()如果你是做的jsp开发,那么输入密码的文本框使用:<input type ="滑袜password" name = "password"/>
这样颂仔输入的野让汪密码就会被.......代替。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)