码迷,mamicode.com
首页 > 其他好文 > 详细

第四次上机

时间:2019-04-28 20:42:27      阅读:153      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!