JAVA的问题g

来源:百度知道 编辑:UC知道 时间:2024/06/16 03:29:10
编写一个交通方式接口,名为Transportmethod,在该接口中有两个抽象方法,启动(start)和刹车(break),编写一个汽车类(Car)用该类实现这个接口,并覆盖掉接口中的抽象方法,在main函数中打印输出启动信息(”the car is starting”)和刹车信息(“the car is breaking”)。在JCreator Pro运行

interface TransportMethod {

void start() ;

void _break() ;
}

class Car implements TransportMethod {

public void start() {
System.out.println ("the car is starting") ;
}

public void _break() {
System.out.println ("the car is breaking") ;
}
}

public class InterfaceTester {

public static void main(String args[]) {

TransportMethod tm = new Car() ;
tm.start() ;
tm._break() ;

}
}

public interface Transportmethod{
public void start();
public void break();
}
public class Car implements Transportmethod {
public void start() {
System.out.println("the car is starting");
}

public void break () {
System.out.println("the car is breaking");
}
public static void main(String[] args)