package com.shrimpking.t11;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2024/9/27 10:20
*/
//抽象类
abstract class Vehicle{
String type; //类型
String plateNumber; //牌照号
public abstract void driverMethod(); //抽象方法
//非抽象方法
public void printParameter(){
System.out.println("类型:" + this.type + ",牌照号:" + this.plateNumber);
}
}
//继承类
class Car extends Vehicle{
public Car(String type,String plateNumber){
super.type = type;
super.plateNumber = plateNumber;
}
//实现了抽象类中的抽象方法
@Override
public void driverMethod()
{
System.out.println("车辆驾驶中...");
}
}
public class Example3_17
{
public static void main(String[] args)
{
Car c = new Car("汽车","京A00000");
c.driverMethod();
}
}
Example3_17
最新推荐文章于 2024-11-04 20:33:37 发布