该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
在用eclipse的时候发现的问题,但是用控制台命令行也不能进行编译,提示一模一样的内容,找不到主类文件,代码我放在这了。。希望大佬能帮我挑一挑问题,卡了一天了就是做不出来。。编译均无问题
package carweight;
interface ComputerWeight {
public double computeWeight();
}
class Television implements ComputerWeight {
public double computeWeight() {return 3.5;} //重写computeWeight()方法
class Computer implements ComputerWeight {
public double computeWeight() {return 2.67;} //重写computeWeight()方法
class WashMachine implements ComputerWeight {
public double computeWeight() {return 13.8;} //重写computeWeight()方法
class Truck {
ComputerWeight [] goods;
double totalWeights=0;
Truck(ComputerWeight[] goods) {
this.goods=goods;
}
public void setGoods(ComputerWeight[] goods) {
this.goods=goods;
}
public double getTotalWeights() {
totalWeights=0;
for (int i=0;i
return totalWeights;
}
}
public class CheckCarWeight {
public void main(String args[]) {
ComputerWeight[] goods=new ComputerWeight[650]; //650件货物
for(int i=0;i
if(i%3==0)
goods[i]=new Television();
else if(i%3==1)
goods[i]=new Computer();
else if(i%3==2)
goods[i]=new WashMachine();
}
Truck truck=new Truck(goods);
System.out.printf("\n货车装载的货物重量:%-8.5f kg\n",truck.getTotalWeights());
goods=new ComputerWeight[68]; //68件货物
for(int i=0;i
if(i%2==0)
goods[i]=new Television();
else
goods[i]=new WashMachine();
}
truck.setGoods(goods);
System.out.printf("货车装载的货物重量:%-8.5f kg\n",truck.getTotalWeights());
}
}}}}