请教高手java 非法类型的开始 需要标识符
packageorg.cadenhead.ecommerce;importjava.util.*;publicclassItemimplementsCoparable{p...
package org.cadenhead.ecommerce;
import java.util.*;
public class Item implements Coparable{
private String id;
private String name;
private double retail;
private int quantity;
private double price;
Item (String idIn,String nameIn,String retailIn,String quanIn){
id=idIn;
name=nameIn;
retail=Double.parseDouble(retailIn);
quantity=Integer.parseInt(quanIn);
}
if(quantity>400)
price=retail*.5D;
else if(quantity>200)
price=retail*.6D;
else
price=retail*.7D;
price=Math.floor(price*100+.5)/100;
public int compareTo(Object obj){
Item temp=(Item)obj;
if(this.price<temp.price)
return 1;
else if(this.price>temp.price)
return -1;
else
return 0;
}
public String getId(){
return id;
}
public String getName(){
return name;
}
public double getRetail(){
return retail;
}
public int getQuantity(){
return quantity;
}
public double getPrice(){
return price;
}
}
主函数在另一个文件,编译也是这个错误~~~~ 展开
import java.util.*;
public class Item implements Coparable{
private String id;
private String name;
private double retail;
private int quantity;
private double price;
Item (String idIn,String nameIn,String retailIn,String quanIn){
id=idIn;
name=nameIn;
retail=Double.parseDouble(retailIn);
quantity=Integer.parseInt(quanIn);
}
if(quantity>400)
price=retail*.5D;
else if(quantity>200)
price=retail*.6D;
else
price=retail*.7D;
price=Math.floor(price*100+.5)/100;
public int compareTo(Object obj){
Item temp=(Item)obj;
if(this.price<temp.price)
return 1;
else if(this.price>temp.price)
return -1;
else
return 0;
}
public String getId(){
return id;
}
public String getName(){
return name;
}
public double getRetail(){
return retail;
}
public int getQuantity(){
return quantity;
}
public double getPrice(){
return price;
}
}
主函数在另一个文件,编译也是这个错误~~~~ 展开
展开全部
package org.cadenhead.ecommerce;
import java.util.*;
public class Item implements Coparable{
private String id;
private String name;
private double retail;
private int quantity;
private double price;
Item (String idIn,String nameIn,String retailIn,String quanIn){
id=idIn;
name=nameIn;
retail=Double.parseDouble(retailIn);
quantity=Integer.parseInt(quanIn);
if(quantity>400)
price=retail*.5D;
else if(quantity>200)
price=retail*.6D;
else
price=retail*.7D;
price=Math.floor(price*100+.5)/100;
}
public int compareTo(Object obj){
Item temp=(Item)obj;
if(this.price<temp.price)
return 1;
else if(this.price>temp.price)
return -1;
else
return 0;
}
public String getId(){
return id;
}
public String getName(){
return name;
}
public double getRetail(){
return retail;
}
public int getQuantity(){
return quantity;
}
public double getPrice(){
return price;
}
}
这个样子就可以了
import java.util.*;
public class Item implements Coparable{
private String id;
private String name;
private double retail;
private int quantity;
private double price;
Item (String idIn,String nameIn,String retailIn,String quanIn){
id=idIn;
name=nameIn;
retail=Double.parseDouble(retailIn);
quantity=Integer.parseInt(quanIn);
if(quantity>400)
price=retail*.5D;
else if(quantity>200)
price=retail*.6D;
else
price=retail*.7D;
price=Math.floor(price*100+.5)/100;
}
public int compareTo(Object obj){
Item temp=(Item)obj;
if(this.price<temp.price)
return 1;
else if(this.price>temp.price)
return -1;
else
return 0;
}
public String getId(){
return id;
}
public String getName(){
return name;
}
public double getRetail(){
return retail;
}
public int getQuantity(){
return quantity;
}
public double getPrice(){
return price;
}
}
这个样子就可以了
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |