package com.shrimpking.t11;
/**
* Created by IntelliJ IDEA.
*
* @Author : Shrimpking
* @create 2024/9/27 10:32
*/
interface Vehicle2{
void driveMethod(); //抽象方法
}
class Car2 implements Vehicle2{
String type; //类型
String plateNumber; //牌照号
public Car2(String type,String plateNumber){
this.type = type;
this.plateNumber = plateNumber;
}
//重写了接口的抽象方法
@Override
public void driveMethod()
{
System.out.println(this.type + "正在驾驶中...");
}
}
public class Example3_18
{
public static void main(String[] args)
{
Vehicle2 v = new Car2("红旗轿车","京A00000");
v.driveMethod();
}
}
Example3_18
最新推荐文章于 2024-11-04 20:33:37 发布