java 无法找到此类_java文件无法找到主类

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

在用eclipse的时候发现的问题,但是用控制台命令行也不能进行编译,提示一模一样的内容,找不到主类文件,代码我放在这了。。希望大佬能帮我挑一挑问题,卡了一天了就是做不出来。。编译均无问题

063f5d9864a096ed48bd693e75e015da.png

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());

}

}}}}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值