美文网首页
非机动车辆

非机动车辆

作者: 哈迪斯Java | 来源:发表于2023-06-06 23:08 被阅读0次

    class Traffic {
    String actor;

    public Traffic(String actor) {
        this.actor = actor;
    }
    
    public final String obey() {
        return this.actor + "在行至有交通信号灯的路口时,要遵守“红灯停、绿灯行”的交通规则。";
    }
    

    }

    class Passerby extends Traffic {
    public Passerby(String actor) {
    super(actor);
    }
    }

    class NonMotorVehicle extends Traffic {
    public NonMotorVehicle(String actor) {
    super(actor);
    }
    }

    class MotorVehicle extends Traffic {
    public MotorVehicle(String actor) {
    super(actor);
    }
    }

    public class TrafficRegulations {
    public static void main(String[] args) {
    Passerby armedPolice = new Passerby("行人");
    System.out.println(armedPolice.obey());
    NonMotorVehicle peoplePolice = new NonMotorVehicle("非机动车辆");
    System.out.println(peoplePolice.obey());
    MotorVehicle trafficPolice = new MotorVehicle("机动车辆");
    System.out.println(trafficPolice.obey());
    }
    }

    相关文章

      网友评论

          本文标题:非机动车辆

          本文链接:https://www.haomeiwen.com/subject/qzphddtx.html