标签:set [] span ring word icc ast void ret
package electriccharge;
public class Power {
final double PRICE = 1.2;
private double lastmonthpower;
private double thismonthpower;
public void setlastmonthpower(double change){
this.lastmonthpower = change;
}
public double getlastmonthpower(){
return this.lastmonthpower;
}
public void setthismonthpower(double change){
this.thismonthpower = change;
}
public double getthismonthpower() {
return this.thismonthpower;
}
public double compute(double lastmonthpower,double thismonthpower){
return (thismonthpower-lastmonthpower)*PRICE;
}
}
package electriccharge;
public class Testpower {
public static void main(String[] args){
Power p1 = new Power();
Power p2 = new Power();
p1.setlastmonthpower(1000);
p1.setthismonthpower(1200);
p2.setlastmonthpower(1200);
p2.setthismonthpower(1450);
System.out.println("本月电费为:");
System.out.println (p1.compute(p1.getlastmonthpower(),p1.getthismonthpower()));
p2.setthismonthpower(1500);
System.out.println("本月电费为:");
System.out.println(p2.compute(p2.getlastmonthpower(),p2.getthismonthpower()));
}
}
标签:set [] span ring word icc ast void ret
原文地址:https://www.cnblogs.com/heguo194508/p/10786159.html