我正在为家庭作业创建一个程序,该程序计算出使用界面的火车旅行的成本:
Train Class:
public class Train implements MassTransit {
public void getCapacity() {
int capacity = 100;
}//end get Capacity
public int getRoundTripCost(int leave, int return_time){
int cost = 0;
cost = (return_time - leave) * 100;
return cost;
} //end getRoundtrip
public static void main(String[] args) {
Train train = new Train();
train.getRoundTripCost(20,25);
}//end of main method
}//end train class
和大众运输方法
public interface MassTransit {
public void getCapacity();
public void getRoundTripCost(int leave, int return_time);
}//end of MassTransit interface
当我尝试编译 Train 类时,我得到的错误是“Train.java:6: error: Train is not abstract and does not override abstract method getRoundTripCost(int,int) in MassTransit”
和
“Train.java:19:错误:Train 中的 getRoundTripCost(int,int) 无法在 MassTransit 中实现 getRoundTripCost(int,int)”
我是一个完整的 Java 新手,但我仍然不熟悉 Java 接口。我做错什么了?