apple.java
来自「大学java作业源程序」· Java 代码 · 共 29 行
JAVA
29 行
package problem_11_1;
//Apple.java
public class Apple {
private double weight; //重量
private double sugarAmount; //含糖量
private double vitaminAmount; //含维生素量
public Apple(double weight){
this.weight = weight;
sugarAmount = 0.15 * weight; //默认苹果含糖率为0.15
vitaminAmount = 0.00005 * weight; //默认苹果含维生素率为0.000005
}
//返回含糖量
public double getSugarAmount(){
return sugarAmount;
}
//返回含维生素量
public double getVitaminAmount(){
return vitaminAmount;
}
//返回重量
public double getWeight(){
return weight;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?